답변완료
수고하십니다
항상 좋은 일만 있으시기 바랍니다 아래수식중 3등분4등분라인을 바로 잡아 주시길 요청 합니다Input : af(0.02), maxAF(0.2),굵기(5); var : t(0),tl(0),tl1(0),tl2(0),tl3(0),tl4(0),tl5(0),tl6(0),tx1(0),tx2(0),color(0); var : hh(0),hd(0),ht(0),hh1(0),tl11(0); var : ll(0),ld(0),lt(0),ll1(0),tl22(0); var : S(0),box1(0),box2(0); var : btl1(0),btl2(0),btl3(0),btl4(0),btl5(0),btl6(0),btl7(0); var : stl1(0),stl2(0),stl3(0),stl4(0),stl5(0),stl6(0),stl7(0); var1 = SAR(af,maxAF); if C < var1 Then S = -1; Else S = 1; if S == 1 and S != S[1] Then { T = 1; hh = h; hh1 = hh[1]; hd = sDate; ht = sTime; if ll > 0 Then { tl = TL_New(ld,lt,ll,hd,ht,hh); tl11 = tl1[1]; TL_SetEnd(tl11,Sdate[1],Stime[1],hh1); if hh1 == 0 or (hh1 > 0 and hh > hh1) Then color = Red; box1 = box_new(ld,lt,ll,hd,ht,hh); Box_SetColor(box1,Red); btl1 = TL_New(ld,lt,hh,hd,ht,hh); btl2 = TL_New(ld,lt,(hh+ll)/2,hd,ht,(hh+ll)/2); btl3 = TL_New(ld,lt,ll,hd,ht,ll); btl4 = TL_New(ld,lt,hh-(hh-ll)/4,hd,ht,hh-(hh-ll)/4); btl5 = TL_New(ld,lt,hh-(hh-ll)/4*3,hd,ht,hh-(hh-ll)/4*3); btl6 = TL_New(ld,lt,hh-(hh-ll)/3,hd,ht,hh-(hh-ll)/3); btl7 = TL_New(ld,lt,hh-(hh-ll)/3*2,hd,ht,hh-(hh-ll)/3*2); TL_SetColor( btl1,RED); TL_SetColor( btl2,RED); TL_SetColor( btl3,RED); TL_SetExtRight(stl1,False); TL_SetExtRight(stl2,False); TL_SetExtRight(stl3,false); TL_SetExtRight(stl4,False); TL_SetExtRight(stl5,False); TL_SetExtRight(stl6,false); TL_SetExtRight(stl7,False); TL_SetExtRight(btl1,true); TL_SetExtRight(btl2,true); TL_SetExtRight(btl3,true); TL_SetExtRight(btl4,true); TL_SetExtRight(btl5,true); TL_SetExtRight(btl6,true); TL_SetExtRight(btl7,true); } } else if S == -1 and S != S[1] Then { T = -1; ll = l; ll1 = ll[1]; ld = sDate; lt = sTime; if hh > 0 Then { tl = TL_New(hd,ht,hh,ld,lt,ll); tl22 = tl2[1]; TL_SetEnd(tl22,Sdate[1],Stime[1],ll1); if ll1 == 0 or (ll1 > 0 and ll < ll1) Then color = Blue; box2 = box_new(hd,ht,hh,ld,lt,ll); Box_SetColor(box2,Blue); stl1 = TL_New(hd,ht,hh,ld,lt,hh); stl2 = TL_New(hd,ht,(hh+ll)/2,ld,lt,(hh+ll)/2); stl3 = TL_New(hd,ht,ll,ld,lt,ll); btl4 = TL_New(hd,ht,hh-(hh-ll)/4,ld,lt,hh-(hh-ll)/4); btl5 = TL_New(hd,ht,hh-(hh-ll)/4*3,ld,lt,hh-(hh-ll)/4*3); btl6 = TL_New(hd,ht,hh-(hh-ll)/3,ld,lt,hh-(hh-ll)/3); btl7 = TL_New(hd,ht,hh-(hh-ll)/3*2,ld,lt,hh-(hh-ll)/3*2); TL_SetColor(stl1 ,BLUE); TL_SetColor(stl2 ,BLUE); TL_SetColor(stl3 ,BLUE); TL_SetExtRight(btl1,False); TL_SetExtRight(btl2,False); TL_SetExtRight(btl3,false); TL_SetExtRight(btl4,False); TL_SetExtRight(btl5,False); TL_SetExtRight(btl6,false); TL_SetExtRight(btl7,False); TL_SetExtRight(stl1,true); TL_SetExtRight(stl2,true); TL_SetExtRight(stl3,true); TL_SetExtRight(stl4,true); TL_SetExtRight(stl5,true); TL_SetExtRight(stl6,true); TL_SetExtRight(stl7,true); } } Else { if t == 1 then { if h > hh Then { hh = h; hd = sDate; ht = sTime; TL_SetEnd(tl,hd,ht,hh); TL_SetBegin(tl1,hd,ht,hh); TL_SetEnd(tl11,Sdate[1],Stime[1],hh1); if (hh1 > 0 and hh > hh1) Then color = Red; Box_SetEnd(box1,hd,ht,hh); TL_SetBegin(btl1,ld,lt,hh); TL_SetBegin(btl2,ld,lt,(hh+ll)/2); TL_SetBegin(btl3,ld,lt,ll); TL_SetBegin(btl4,ld,lt,hh-(hh-ll)/4); TL_SetBegin(btl5,ld,lt,hh-(hh-ll)/4*3); TL_SetBegin(btl6,ld,lt,hh-(hh-ll)/3); TL_SetBegin(btl7,ld,lt,hh-(hh-ll)/3*2); TL_SetEnd(btl1,sDate,stime,hh); TL_SetEnd(btl2,sDate,sTime,(hh+ll)/2); TL_SetEnd(btl3,sDate,sTime,ll); TL_SetEnd(btl4,sDate,sTime,hh-(hh-ll)/4); TL_SetEnd(btl5,sDate,sTime,hh-(hh-ll)/4*3); TL_SetEnd(btl6,sDate,sTime,hh-(hh-ll)/3); TL_SetEnd(btl7,sDate,sTime,hh-(hh-ll)/3*2); } } if t == -1 then { if l < ll Then { ll = l; ld = sDate; lt = sTime; TL_SetEnd(tl,ld,lt,ll); TL_SetBegin(tl2,ld,lt,ll); TL_SetEnd(tl22,Sdate[1],Stime[1],ll1); if (ll1 > 0 and ll < ll1) Then color = Blue; Box_SetEnd(box2,ld,lt,ll); TL_SetBegin(stl1,hd,ht,hh); TL_SetBegin(stl2,hd,ht,(hh+ll)/2); TL_SetBegin(stl3,hd,ht,ll); TL_SetBegin(stl4,hd,ht,hh-(hh-ll)/4); TL_SetBegin(stl5,hd,ht,hh-(hh-ll)/4*3); TL_SetBegin(stl6,hd,ht,hh-(hh-ll)/3); TL_SetBegin(stl7,hd,ht,hh-(hh-ll)/3*2); TL_SetEnd(stl1,sdate,sTime,hh); TL_SetEnd(stl2,sDate,sTime,(hh+ll)/2); TL_SetEnd(stl3,sDate,sTime,ll); TL_SetEnd(stl4,sDate,sTime,hh-(hh-ll)/4); TL_SetEnd(stl5,sDate,sTime,hh-(hh-ll)/4*3); TL_SetEnd(stl6,sDate,sTime,hh-(hh-ll)/3); TL_SetEnd(stl7,sDate,sTime,hh-(hh-ll)/3*2); } } } TL_SetEnd(tl1,NextBarSdate,NextBarStime,hh); TL_SetEnd(tl2,NextBarSdate,NextBarStime,ll); TL_SetEnd(tl3,NextBarSdate,NextBarStime,hh-(hh-ll)/4); TL_SetEnd(tl4,NextBarSdate,NextBarStime,hh-(hh-ll)/4*3); TL_SetEnd(tl5,NextBarSdate,NextBarStime,hh-(hh-ll)/3); TL_SetEnd(tl6,NextBarSdate,NextBarStime,hh-(hh-ll)/3*2); ########################################################### ###########################################################
답변완료
문의드립니다
input : atrMult(4.5);input : atrlen(12);input : rsmlen(3);input : tplen(14);var : i(0),sum(0),source(0);var : alpha(0),atrValue1(0),upperLevel(0),lowerLevel(0);var : previousLowerLevel(0),previousUpperLevel(0);var : trendDirection(Nan),superTrendValue(Nan);var : previousTrend(0);if CurrentBar > 1 Then { sum = 0; for i = 0 to rsmlen-1 { sum = sum + c[i]*c[i]; } source = sqrt(sum/rsmlen); alpha = 1 / atrlen ; atrValue1 = IFf(IsNan(atrValue1[1]) == true, ma(TrueRange,atrlen) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue1[1])==true,0,atrValue1[1])); upperLevel = source + atrMult * atrValue1; lowerLevel = source - atrMult * atrValue1; previousLowerLevel = iff(isnan(lowerLevel[1])==true,0,lowerLevel[1]); previousUpperLevel = iff(isnan(upperLevel[1])==true,0,upperLevel[1]); // Ensure continuity of lower and upper bands lowerLevel = iff(lowerLevel > previousLowerLevel or source[1] < previousLowerLevel , lowerLevel , previousLowerLevel); upperLevel = iff(upperLevel < previousUpperLevel or source[1] > previousUpperLevel , upperLevel , previousUpperLevel); // Determine direction and SuperTrend previousTrend = superTrendValue[1]; // Initialize direction if IsNan(atrValue1[1]) == true Then trendDirection = 1; else if previousTrend == previousUpperLevel Then trendDirection = iff(source > upperLevel , -1 , 1); else trendDirection = iff(source < lowerLevel , 1 , -1); // Set SuperTrend value based on direction superTrendValue = iff(trendDirection == -1 , lowerLevel , upperLevel);}plot1(superTrendValue,"ST", iff(trendDirection > 0 , red,green));Plot2((C+O)/2,"bodyMiddle");var : dist(0),chg(0),lvlCol(0);var : tp1(0),tp2(0),tp3(0),tp4(0),tp5(0),tp6(0),tp7(0);var : printedtp1(0),printedtp2(0),printedtp3(0),printedtp4(0),printedtp5(0),printedtp6(0),printedtp7(0);dist = abs(close-superTrendValue);lvlCol = iff(trendDirection > 0 , red , green);var : key1(0);var : key2(0);var : key3(0);var : key4(0);var : key5(0);var : key6(0);var : key7(0);if CrossUp(trendDirection, 0) or CrossDown(trendDirection, 0) Then{ //TL_Delete(keys); printedtp1 = 0; printedtp2 = 0; printedtp3 = 0; printedtp4 = 0; printedtp5 = 0; printedtp6 = 0; printedtp7 = 0; chg = abs(superTrendValue-superTrendValue[1]); tp1 = superTrendValue[1] + IFF(trendDirection > 0 , -chg , chg); tp2 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 2 , chg * 2); tp3 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 3 , chg * 3); tp4 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 4 , chg * 4); tp5 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 5 , chg * 5); tp6 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 6 , chg * 6); tp7 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 7 , chg * 7); key1 = TL_new(sdate[1],stime[1],tp1, sDate,sTime, tp1); TL_SetColor(Key1,lvlCol); TL_SetSize(Key1,2); printedtp1 = 1;}Else TL_SetEnd(key1,sDate,sTime,TP1); var : u(0),d(0),alp(0),ur(0),dr(0),rs(0),R(0),tp(False);u = max(dist - dist[1], 0);d = max(dist[1] - dist, 0);alp = 1/tplen;ur = IFf(IsNan(ur[1]) == true, ma(u,tplen) , alp * u + (1 - alp) * IFf(isnan(ur[1])==true,0,ur[1]));dr = IFf(IsNan(dr[1]) == true, ma(d,tplen) , alp * d + (1 - alp) * IFf(isnan(dr[1])==true,0,dr[1]));rs = ur / dr;R = 100 - 100 / (1 + rs);tp = CrossDown(R, 60);var : extreme(0);var : extreme_tp1_dist(0);var : extreme_tp2_dist(0);var : extreme_tp3_dist(0);var : extreme_tp4_dist(0);var : extreme_tp5_dist(0);var : extreme_tp6_dist(0);var : extreme_tp7_dist(0);extreme = iff(trendDirection > 0 , low , high);extreme_tp1_dist = abs(extreme - tp1);extreme_tp2_dist = abs(extreme - tp2);extreme_tp3_dist = abs(extreme - tp3);extreme_tp4_dist = abs(extreme - tp4);extreme_tp5_dist = abs(extreme - tp5);extreme_tp6_dist = abs(extreme - tp6);extreme_tp7_dist = abs(extreme - tp7);var : tx(0);if tp and trendDirection > 0 Then{ tx = Text_New(sDate,sTime,L,"X"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); Text_SetSize(tx,20); Text_SetBold(tx,1);}if tp and trendDirection < 0 Then{ tx = Text_New(sDate,sTime,H,"X"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Green); Text_SetSize(tx,20); Text_SetBold(tx,1);}if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist Then{ key2 = TL_new(sdate[1],stime[1],tp2, sDate,sTime, tp2); TL_SetColor(Key2,lvlCol); TL_SetSize(Key2,2); printedtp2 = 1;}Else{ if printedtp2 == 1 Then TL_SetEnd(key2,sDate,sTime,TP2);}if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist Then{ key3 = TL_new(sdate[1],stime[1],tp3, sDate,sTime, tp3); TL_SetColor(Key3,lvlCol); TL_SetSize(Key3,2); printedtp3 = 1;}Else{ if printedtp3 == 1 Then TL_SetEnd(key3,sDate,sTime,TP3);}if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist Then{ key4 = TL_new(sdate[1],stime[1],tp4, sDate,sTime, tp4); TL_SetColor(Key4,lvlCol); TL_SetSize(Key4,2); printedtp4 = 1;}Else{ if printedtp4 == 1 Then TL_SetEnd(key4,sDate,sTime,TP4);}if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist Then{ key5 = TL_new(sdate[1],stime[1],tp5, sDate,sTime, tp5); TL_SetColor(Key5,lvlCol); TL_SetSize(Key5,2); printedtp5 = 1;}Else{ if printedtp5 == 1 Then TL_SetEnd(key5,sDate,sTime,TP5);}if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist Then{ key6 = TL_new(sdate[1],stime[1],tp6, sDate,sTime, tp6); TL_SetColor(Key6,lvlCol); TL_SetSize(Key6,2); printedtp6 = 1;}Else{ if printedtp6 == 1 Then TL_SetEnd(key6,sDate,sTime,TP6);}if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist Then{ key7 = TL_new(sdate[1],stime[1],tp7, sDate,sTime, tp7); TL_SetColor(Key7,lvlCol); TL_SetSize(Key7,2); printedtp7 = 1;}Else{ if printedtp7 == 1 Then TL_SetEnd(key7,sDate,sTime,TP7);}수고많으십니다 문의드릴 내용은 위 수식에서 Red색 X표시가 나오면매수진입 매도청산 Red색 X표시가 계속 나오면 최대 10개까지 계속 매수진입 Green색 X표시가 나오면매도진입 매수청산 Green색 X표시가 계속 나오면 최대 10개까지 계속 매도진입이런 수식을 부탁드립니다 감사합니다