답변완료
파라볼릭 박스
아래 차트의 선만 있을 때는 박스 오류가 안보이는데, (근본적인 한계인지?)윗 차트의 박스를 주가 상하단에 맞춰 왼쪽으로 옮기니, 상하가 일치하지 않습니다.선물 400틱 차트입니다. 검토 부탁드립니다.Input : af(0.02), maxAF(0.2);var : T(0),TL(0),B(0),S(0),tx(0),txx(0),HH(0),HD(0),HT(0),LL(0),LD(0),LT(0),box(0);var : B1(0),B2(0),S1(0),S2(0),H1(0),H2(0),L1(0),L2(0);var : tx1(0),tx2(0),tx3(0),tx4(0),tx5(0),tx6(0);var1 = CSar(af,maxAF);plot1(var1, "CSAR",IFF(c>var1,Red,Green)); if CrossUp(C,var1) Then{ B = var1; T = 1; B1 = B[1]; B2 = B1[1]; HD = sDate; HT = sTime; HH = H; H1 = HH[1]; H2 = H1[1]; if LL > 0 Then box = Box_New(LD,LT,LL,HD,HT,HH); if abs(S-LL) < 1.25 Then Text_Delete(tx); tx = Text_New(sDate,sTime,HH,NumToStr(abs(HH-B),2)); Text_SetColor(tx,Red); Text_SetSize(tx,22); Text_SetStyle(tx,1,1); Text_SetBold(tx,1); Condition1 = False;}if CrossDown(C,var1) Then{ S = var1; T = -1; S1 = S[1]; S2 = S1[1]; LD = sDate; LT = sTime; LL = L; L1 = LL[1]; L2 = L1[1]; if HH > 0 Then box = Box_New(HD,HT,HH,LD,LT,LL); if abs(B-HH) < 1.25 Then Text_Delete(tx); tx = Text_New(sDate,sTime,LL,NumToStr(abs(LL-S),2)); Text_SetColor(tx,Blue); Text_SetSize(tx,22); Text_SetStyle(tx,1,0); Text_SetBold(tx,1); Condition1 = False; }Else{ if T == 1 Then { if H >= HH Then { HD = sDate; HT = sTime; HH = H; } Text_SetString(tx,NumToStr(abs(HH-B),2)); Text_SetLocation(tx,sDate,sTime,HH); Box_SetEnd(box,HD,HT,HH); if HH < LL+1.5 Then { Box_SetColor(box,Magenta); Box_SetFill(box,true,60); } Else if HH >= LL+1.5 and HH < LL+3.5 Then { Box_SetColor(box,Gray); Box_SetFill(box,true,60); } Else { Box_SetColor(box,Orange); Box_SetFill(box,true,40); } if abs(HH-LL) >= 2 Then { if Condition1 == False Then { Condition1 = true; tx1 = Text_New(HD,HT,HH+abs(HH-LL)*0.618,"●"); tx2 = Text_New(HD,HT,HH+abs(HH-LL)*1.000,"●"); tx3 = Text_New(HD,HT,HH+abs(HH-LL)*1.618,"●"); Text_SetStyle(tx1,2,2); Text_SetStyle(tx2,2,2); Text_SetStyle(tx3,2,2); Text_SetColor(tx1,Red); Text_SetColor(tx2,Blue); Text_SetColor(tx3,Red); tx4 = Text_New(HD,HT,LL-abs(HH-LL)*0.618,"●"); tx5 = Text_New(HD,HT,LL-abs(HH-LL)*1.000,"●"); tx6 = Text_New(HD,HT,LL-abs(HH-LL)*1.618,"●"); Text_SetStyle(tx4,2,2); Text_SetStyle(tx5,2,2); Text_SetStyle(tx6,2,2); Text_SetColor(tx4,Red); Text_SetColor(tx5,Blue); Text_SetColor(tx6,Red); } Else { Text_SetLocation(tx1,HD,HT,HH+abs(HH-LL)*0.618); Text_SetLocation(tx2,HD,HT,HH+abs(HH-LL)*1.000); Text_SetLocation(tx3,HD,HT,HH+abs(HH-LL)*1.618); Text_SetLocation(tx4,HD,HT,LL-abs(HH-LL)*0.618); Text_SetLocation(tx5,HD,HT,LL-abs(HH-LL)*1.000); Text_SetLocation(tx6,HD,HT,LL-abs(HH-LL)*1.618); } } } if T == -1 Then { if L <= LL Then { LD = sDate; LT = sTime; LL = L; } Text_SetString(tx,NumToStr(abs(LL-S),2)); Text_SetLocation(tx,sDate,sTime,LL); Box_SetEnd(box,LD,LT,LL); if LL > HH-1.5 Then { Box_SetColor(box,Lime); Box_SetFill(box,true,80); } Else if LL <= HH-1.5 and LL > HH-3.5 Then { Box_SetColor(box,Cyan); Box_SetFill(box,true,70); } Else { Box_SetColor(box,Cyan); Box_SetFill(box,true,50); } if abs(HH-LL) >= 2 Then { if Condition1 == False Then { Condition1 = true; tx1 = Text_New(LD,LT,HH+abs(HH-LL)*0.618,"●"); tx2 = Text_New(LD,LT,HH+abs(HH-LL)*1.000,"●"); tx3 = Text_New(LD,LT,HH+abs(HH-LL)*1.618,"●"); Text_SetStyle(tx1,2,2); Text_SetStyle(tx2,2,2); Text_SetStyle(tx3,2,2); Text_SetColor(tx1,Red); Text_SetColor(tx2,Blue); Text_SetColor(tx3,Red); tx4 = Text_New(LD,LT,LL-abs(HH-LL)*0.618,"●"); tx5 = Text_New(LD,LT,LL-abs(HH-LL)*1.000,"●"); tx6 = Text_New(LD,LT,LL-abs(HH-LL)*1.618,"●"); Text_SetStyle(tx4,2,2); Text_SetStyle(tx5,2,2); Text_SetStyle(tx6,2,2); Text_SetColor(tx4,Red); Text_SetColor(tx5,Blue); Text_SetColor(tx6,Red); } Else { Text_SetLocation(tx1,LD,LT,HH+abs(HH-LL)*0.618); Text_SetLocation(tx2,LD,LT,HH+abs(HH-LL)*1.000); Text_SetLocation(tx3,LD,LT,HH+abs(HH-LL)*1.618); Text_SetLocation(tx4,LD,LT,LL-abs(HH-LL)*0.618); Text_SetLocation(tx5,LD,LT,LL-abs(HH-LL)*1.000); Text_SetLocation(tx6,LD,LT,LL-abs(HH-LL)*1.618); } } }}
답변완료
시스템매매로 변환부탁드립니다...
아래 수식은 예스 지표수식입니다...청색라인에서 매수 하는 시스템 매매로 변환 부탁드립니다..input : ATRperiod(14);input : BBperiod(20);input : BBdeviation(1.5);input : UseATRfilter(true);input : showsignals(true);var : BBupper(0),BBlower(0),alpha(0),atrValue(0);var : FollowLine(Nan),BBSignal(0),iTrend(0);BBUpper = ma(close, BBperiod) + std(close, BBperiod) * BBdeviation;BBLower = ma(close, BBperiod) - std(close, BBperiod) * BBdeviation;alpha = 1 / ATRperiod ;atrValue = IFf(IsNan(atrValue[1]) == true, ma(TrueRange,ATRperiod) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue[1])==true,0,atrValue[1]));if (close > BBUpper) Then BBSignal = 1;else if (close < BBLower) Then BBSignal = -1;if (BBSignal == 1) Then{ if (UseATRfilter) Then { FollowLine = low - atrValue; } else { FollowLine = low; } if (FollowLine < iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); }}if (BBSignal == -1) Then{ if (UseATRfilter) Then { FollowLine = high + atrValue; } else { FollowLine = high; } if (FollowLine > iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); }}if iff(IsNan(FollowLine)==true,0,FollowLine) > iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = 1;else if iff(IsNan(FollowLine)==true,0,FollowLine) < iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = -1;var : lineColor(0),B(0),S(0),tx(0);lineColor = iff(iTrend > 0 , Gold , Blue);b = iff(iTrend[1]==-1 and iTrend==1 , 1 , 0);s = iff(iTrend[1]==1 and iTrend==-1 , 1 , 0);plot1(FollowLine, "Follow Line", lineColor);if B == 1 and showsignals Then{ tx = text_new(sDate,stime,L,"▲"); Text_SetColor(tx,ReD); Text_SetStyle(tx,2,0);}if S == 1 and showsignals Then{ tx = text_new(sDate,stime,H,"▼"); Text_SetColor(tx,WhitE); Text_SetStyle(tx,2,1);}