커뮤니티

질문드립니다.

프로필 이미지
stockric
2018-10-31 18:13:46
305
글번호 123242
답변완료

첨부 이미지

이전 59828질문의 연속인 것 같습니다. 나름대로 구현해보았는데요. input : P1(5),P2(10),P3(20),P4(50),P5(100); var : count1(0),sumV1(0), sumV2(0), sumV3(0), sumV4(0), sumV5(0); array : 이평[5](0),이평_txt[5](0),이평명[5](""); sumV1 = 0; sumV2 = 0; sumV3 = 0; sumV4 = 0; sumV5 = 0; for count1 = 0 to P5{ if count1 < P1 Then sumV1 = sumV1+DayClose(count1); if count1 < P2 Then sumV2 = sumV2+DayClose(count1); if count1 < P3 Then sumV3 = sumV3+DayClose(count1); if count1 < P4 Then sumV4 = sumV4+DayClose(count1); if count1 < P5 Then sumV5 = sumV5+DayClose(count1); } 이평[1] = sumV1/P1; 이평[2] = sumV2/P2; 이평[3] = sumV3/P3; 이평[4] = sumV4/P4; 이평[5] = sumV5/P5; 이평명[1] = numtostr(P1,0); 이평명[2] = numtostr(P2,0); 이평명[3] = numtostr(P3,0); 이평명[4] = numtostr(P4,0); 이평명[5] = numtostr(P5,0); Var : af(0.02), maxAF(0.2),추세선두께(5),추세선색1(RED),추세선색2(BLUE),연장선두께(2),연장선색(blue); Var : 텍스트출력(1); var : T(0),HH(0),LL(0),HD(0),HT(0),LD(0),LT(0); var : HH1(0),LL1(0),HD1(0),HT1(0),LD1(0),LT1(0); var : TL1(0),TL2(0),cnt(0),count(0); var : TL3(0),TL4(0),TL5(0),TL6(0),tx1(0),tx2(0),tx11(0),tx22(0); var : upcross(0),dncross(0),HBD(0),HBD1(0),LBD(0),LBD1(0),tx3(0), spc(""); Var : cross1(0), cross2(0), cross3(0), cross4(0), cross5(0), cross6(0); var1 = CSar(af,maxAF); if Bdate != Bdate[1] Then { upcross = 0; dncross = 0; cross1 = 0; cross2 = 0; cross3 = 0; cross4 = 0; cross5 = 0; cross6 = 0; } if crossup(c,var1) Then { T = 1; HH = H; HD = sdate; HT = stime; HBD = Bdate; HH1 = HH[1]; HD1 = HD[1]; HT1 = HT[1]; HBD1 = HBD[1]; if LL > 0 Then { Condition3 = False; if Condition3 == false and LL < 이평[1] and HH > 이평[1] and HBD == bdate and LL1 < 이평[1] and LBD1 == bdate and countif(CrossUp(H,이평[1]),20) >= 1 Then { Condition3 = true; cross1 = cross1+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross1,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition4 = False; if Condition4 == false and LL < 이평[2] and HH > 이평[2] and HBD == bdate and LL1 < 이평[2] and LBD1 == bdate and countif(CrossUp(H,이평[2]),10) >= 1 Then { Condition4 = true; cross2 = cross2+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross2,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition5 = False; if Condition5 == false and LL < 이평[3] and HH > 이평[3] and HBD == bdate and LL1 < 이평[3] and LBD1 == bdate and countif(CrossUp(H,이평[3]),10) >= 1 Then { Condition5 = true; cross3 = cross3+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross3,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition6 = False; if Condition6 == false and LL < 이평[4] and HH > 이평[4] and HBD == bdate and LL1 < 이평[4] and LBD1 == bdate and countif(CrossUp(H,이평[4]),10) >= 1 Then { Condition6 = true; cross4 = cross4+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross4,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition7 == false and LL < 이평[5] and HH > 이평[5] and HBD == bdate and LL1 < 이평[5] and LBD1 == bdate and countif(CrossUp(H,이평[5]),10) >= 1 Then { Condition7 = true; cross5 = cross5+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross5,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } } } if CrossDown(c,var1) Then { T = -1; LL = L; LD = sdate; LT = stime; LBD = Bdate; LL1 = LL[1]; LD1 = LD[1]; LT1 = LT[1]; LBD1 = LBD[1]; if HH > 0 Then { } } if T == 1 then { if H > HH Then { HH = H; HD = sdate; HT = stime; HBD = bdate; } } if T == -1 then { if L < LL Then { LL = L; LD = sdate; LT = stime; LBD = Bdate; } } 이렇게 짜보았습니다. 그런데 사진을 보시면, 직접적으로 크로스업하지 않은 구간에서 나오지 않네요. 아마 if crossup(c,var1) then 아마 파라볼릭이 크로스업다운한 것으로 보이는데요. 59828의 추세선신호가 완성되고, 완성된 추세선신호에서 고가가 이평을 뚫었으면, 신호가 나왔으면 하는데, 파라볼릭때문에 그런 것일까요? 사진에 보시면 아시겠지만, 되레 나와야할 구간에서는 나와주지않네요. countif로 크로스업신호를 추가했는데도 안떠서 다소 당황스럽습니다. 로직에 문제가무엇인지.. if crossup(c,이평) 을 넣게되면, 그냥 크로스업한 구간에만 번호가 나오게됩니다. 사진한장 첨부하겠습니다. 신호구간은 나스닥18년10월22일입니다. 노고에 감사드립니다.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2018-11-01 14:07:43

안녕하세요 예스스탁입니다. 이전수식은 고정값인 당일시초가이므로 단순히 고점과 저점을 시초가와 비교만하면 가능했지만 일간이평은 봉마다 값이 다릅니다. 종가가 파라볼릭보다 큰구간과 작은구간에에 이평을 터치했는지 여부를 별도로 체크하는 내용이 있어야 합니다. 아래 내용을 참고하셔서 수정보완해 사용하시기 바랍니다. input : P1(5),P2(10),P3(20),P4(50),P5(100); var : count1(0),sumV1(0), sumV2(0), sumV3(0), sumV4(0), sumV5(0); array : 이평[5](0),이평_txt[5](0),이평명[5](""); sumV1 = 0; sumV2 = 0; sumV3 = 0; sumV4 = 0; sumV5 = 0; for count1 = 0 to P5 { if count1 < P1 Then sumV1 = sumV1+DayClose(count1); if count1 < P2 Then sumV2 = sumV2+DayClose(count1); if count1 < P3 Then sumV3 = sumV3+DayClose(count1); if count1 < P4 Then sumV4 = sumV4+DayClose(count1); if count1 < P5 Then sumV5 = sumV5+DayClose(count1); } 이평[1] = sumV1/P1; 이평[2] = sumV2/P2; 이평[3] = sumV3/P3; 이평[4] = sumV4/P4; 이평[5] = sumV5/P5; 이평명[1] = numtostr(P1,0); 이평명[2] = numtostr(P2,0); 이평명[3] = numtostr(P3,0); 이평명[4] = numtostr(P4,0); 이평명[5] = numtostr(P5,0); Var : af(0.02), maxAF(0.2),추세선두께(5),추세선색1(RED),추세선색2(BLUE),연장선두께(2),연장선색(blue); Var : 텍스트출력(1); var : T(0),HH(0),LL(0),HD(0),HT(0),LD(0),LT(0); var : HH1(0),LL1(0),HD1(0),HT1(0),LD1(0),LT1(0); var : TL1(0),TL2(0),cnt(0),count(0); var : TL3(0),TL4(0),TL5(0),TL6(0),tx1(0),tx2(0),tx11(0),tx22(0); var : upcross(0),dncross(0),HBD(0),HBD1(0),LBD(0),LBD1(0),tx3(0), spc(""); Var : cross1(0), cross2(0), cross3(0), cross4(0), cross5(0), cross6(0); var : dn1(false),dn2(false),dn3(false),dn4(false),dn5(false); var : dn11(false),dn21(false),dn31(false),dn41(false),dn51(false); var : up1(false),up2(false),up3(false),up4(false),up5(false); var : up11(false),up21(false),up31(false),up41(false),up51(false); var1 = CSar(af,maxAF); if Bdate != Bdate[1] Then { upcross = 0; dncross = 0; cross1 = 0; cross2 = 0; cross3 = 0; cross4 = 0; cross5 = 0; cross6 = 0; } if crossup(c,var1) Then { T = 1; HH = H; HD = sdate; HT = stime; HBD = Bdate; HH1 = HH[1]; HD1 = HD[1]; HT1 = HT[1]; HBD1 = HBD[1]; up1 = false; up2 = false; up3 = false; up4 = false; up5 = false; up11 = up1[1]; up21 = up2[1]; up31 = up3[1]; up41 = up4[1]; up51 = up5[1]; if LL > 0 Then { Condition3 = False; if Condition3 == false and HH > 이평[1] and dn1 == true and up11 == true Then { Condition3 = true; cross1 = cross1+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross1,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition4 = False; if Condition4 == false and HH > 이평[2] and dn2 == true and up21 == true Then { Condition4 = true; cross2 = cross2+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross2,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition5 = False; if Condition5 == false and HH > 이평[3] and dn3 == true and up31 == true Then { Condition5 = true; cross3 = cross3+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross3,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition6 = False; if Condition6 == false and HH > 이평[4] and dn4 == true and up41 == true Then { Condition6 = true; cross4 = cross4+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross4,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition7 = False; if Condition7 == false and HH > 이평[5] and dn5 == true and up51 == true Then { Condition7 = true; cross5 = cross5+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross5,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } } } if CrossDown(c,var1) Then { T = -1; LL = L; LD = sdate; LT = stime; LBD = Bdate; LL1 = LL[1]; LD1 = LD[1]; LT1 = LT[1]; LBD1 = LBD[1]; dn1 = false; dn2 = false; dn3 = false; dn4 = false; dn5 = false; dn11 = dn1[1]; dn21 = dn2[1]; dn31 = dn3[1]; dn41 = dn4[1]; dn51 = dn5[1]; } if T == 1 then { if H > 이평[1] Then up1 = true; if H > 이평[2] Then up2 = true; if H > 이평[3] Then up3 = true; if H > 이평[4] Then up4 = true; if H > 이평[5] Then up5 = true; if H > HH Then { HH = H; HD = sdate; HT = stime; HBD = bdate; if Condition3 == false and HH > 이평[1] and dn1 == true and up1 == true Then { Condition3 = true; cross1 = cross1+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross1,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition4 == false and HH > 이평[2] and dn2 == true and up2 == true Then { Condition4 = true; cross2 = cross2+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross2,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition5 == false and HH > 이평[3] and dn3 == true and up3 == true Then { Condition5 = true; cross3 = cross3+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross3,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition6 == false and HH > 이평[4] and dn4 == true and up4 == true Then { Condition6 = true; cross4 = cross4+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross4,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition7 == false and HH > 이평[5] and dn5 == true and up5 == true Then { Condition7 = true; cross5 = cross5+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross5,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } } } if T == -1 then { if L < 이평[1] Then dn1 = true; if L < 이평[2] Then dn2 = true; if L < 이평[3] Then dn3 = true; if L < 이평[4] Then dn4 = true; if L < 이평[5] Then dn5 = true; if L < LL Then { LL = L; LD = sdate; LT = stime; LBD = Bdate; } } plot1(var1,"파라",iff(C>var1,RED,blue)); plot2(이평[1]); plot3(이평[2]); plot4(이평[3]); plot5(이평[4]); plot6(이평[5]); 즐거운 하루되세요 > stockric 님이 쓴 글입니다. > 제목 : 질문드립니다. > 이전 59828질문의 연속인 것 같습니다. 나름대로 구현해보았는데요. input : P1(5),P2(10),P3(20),P4(50),P5(100); var : count1(0),sumV1(0), sumV2(0), sumV3(0), sumV4(0), sumV5(0); array : 이평[5](0),이평_txt[5](0),이평명[5](""); sumV1 = 0; sumV2 = 0; sumV3 = 0; sumV4 = 0; sumV5 = 0; for count1 = 0 to P5{ if count1 < P1 Then sumV1 = sumV1+DayClose(count1); if count1 < P2 Then sumV2 = sumV2+DayClose(count1); if count1 < P3 Then sumV3 = sumV3+DayClose(count1); if count1 < P4 Then sumV4 = sumV4+DayClose(count1); if count1 < P5 Then sumV5 = sumV5+DayClose(count1); } 이평[1] = sumV1/P1; 이평[2] = sumV2/P2; 이평[3] = sumV3/P3; 이평[4] = sumV4/P4; 이평[5] = sumV5/P5; 이평명[1] = numtostr(P1,0); 이평명[2] = numtostr(P2,0); 이평명[3] = numtostr(P3,0); 이평명[4] = numtostr(P4,0); 이평명[5] = numtostr(P5,0); Var : af(0.02), maxAF(0.2),추세선두께(5),추세선색1(RED),추세선색2(BLUE),연장선두께(2),연장선색(blue); Var : 텍스트출력(1); var : T(0),HH(0),LL(0),HD(0),HT(0),LD(0),LT(0); var : HH1(0),LL1(0),HD1(0),HT1(0),LD1(0),LT1(0); var : TL1(0),TL2(0),cnt(0),count(0); var : TL3(0),TL4(0),TL5(0),TL6(0),tx1(0),tx2(0),tx11(0),tx22(0); var : upcross(0),dncross(0),HBD(0),HBD1(0),LBD(0),LBD1(0),tx3(0), spc(""); Var : cross1(0), cross2(0), cross3(0), cross4(0), cross5(0), cross6(0); var1 = CSar(af,maxAF); if Bdate != Bdate[1] Then { upcross = 0; dncross = 0; cross1 = 0; cross2 = 0; cross3 = 0; cross4 = 0; cross5 = 0; cross6 = 0; } if crossup(c,var1) Then { T = 1; HH = H; HD = sdate; HT = stime; HBD = Bdate; HH1 = HH[1]; HD1 = HD[1]; HT1 = HT[1]; HBD1 = HBD[1]; if LL > 0 Then { Condition3 = False; if Condition3 == false and LL < 이평[1] and HH > 이평[1] and HBD == bdate and LL1 < 이평[1] and LBD1 == bdate and countif(CrossUp(H,이평[1]),20) >= 1 Then { Condition3 = true; cross1 = cross1+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross1,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition4 = False; if Condition4 == false and LL < 이평[2] and HH > 이평[2] and HBD == bdate and LL1 < 이평[2] and LBD1 == bdate and countif(CrossUp(H,이평[2]),10) >= 1 Then { Condition4 = true; cross2 = cross2+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross2,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition5 = False; if Condition5 == false and LL < 이평[3] and HH > 이평[3] and HBD == bdate and LL1 < 이평[3] and LBD1 == bdate and countif(CrossUp(H,이평[3]),10) >= 1 Then { Condition5 = true; cross3 = cross3+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross3,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } Condition6 = False; if Condition6 == false and LL < 이평[4] and HH > 이평[4] and HBD == bdate and LL1 < 이평[4] and LBD1 == bdate and countif(CrossUp(H,이평[4]),10) >= 1 Then { Condition6 = true; cross4 = cross4+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross4,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } if Condition7 == false and LL < 이평[5] and HH > 이평[5] and HBD == bdate and LL1 < 이평[5] and LBD1 == bdate and countif(CrossUp(H,이평[5]),10) >= 1 Then { Condition7 = true; cross5 = cross5+1; tx3 = text_new(HD[1],HT[1],HH[1], NumToStr(cross5,0)+NewLine+NewLine); Text_SetStyle(tx3,2,1); text_setcolor(tx3,BLUE); } } } if CrossDown(c,var1) Then { T = -1; LL = L; LD = sdate; LT = stime; LBD = Bdate; LL1 = LL[1]; LD1 = LD[1]; LT1 = LT[1]; LBD1 = LBD[1]; if HH > 0 Then { } } if T == 1 then { if H > HH Then { HH = H; HD = sdate; HT = stime; HBD = bdate; } } if T == -1 then { if L < LL Then { LL = L; LD = sdate; LT = stime; LBD = Bdate; } } 이렇게 짜보았습니다. 그런데 사진을 보시면, 직접적으로 크로스업하지 않은 구간에서 나오지 않네요. 아마 if crossup(c,var1) then 아마 파라볼릭이 크로스업다운한 것으로 보이는데요. 59828의 추세선신호가 완성되고, 완성된 추세선신호에서 고가가 이평을 뚫었으면, 신호가 나왔으면 하는데, 파라볼릭때문에 그런 것일까요? 사진에 보시면 아시겠지만, 되레 나와야할 구간에서는 나와주지않네요. countif로 크로스업신호를 추가했는데도 안떠서 다소 당황스럽습니다. 로직에 문제가무엇인지.. if crossup(c,이평) 을 넣게되면, 그냥 크로스업한 구간에만 번호가 나오게됩니다. 사진한장 첨부하겠습니다. 신호구간은 나스닥18년10월22일입니다. 노고에 감사드립니다.