커뮤니티

수식 검토부탁드립니다.

프로필 이미지
파쿠3
2013-10-01 13:10:10
168
글번호 68011
답변완료

첨부 이미지

5분 챠트를 열어놓고, 15분봉을 보고 매매를 하는 시스템입니다. 18번 매매식은 양봉 5개이면 매수 29번은 음봉 5개이면 매도 입니다. 여기서 이상한 점은 29번의 SetStopProfittarget(0.15,PointStop); 을 0.06, 0.09, 0.15로 바꾸면, 18번 이익프로핏이 0.13이 아니라 29번 프로핏타켓과 같은 값으로 청산을 합니다. 항상 그런것은 아니고, 29번 매 뒤에 18번 매매가 올 경우에 그렇습니다. 그리고, 29번 뒤에 18번 거래가 나올경우에는 반대로 29번의 이익틱이 18번 거래에 적용됩니다. 번거로우시겠지만, 수식 검토좀 부탁드립니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); } } If EntryName == "B_15m_md18" or EntryName == "S_15m_md18" Then { SetStopProfittarget(0.13,PointStop); SetStopLoss(0.36,PointStop); } If EntryName == "B_15m_md29" or EntryName == "S_15m_md29" Then { SetStopProfittarget(0.15,PointStop); SetStopLoss(0.40,PointStop); }
시스템
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2013-10-01 17:35:54

안녕하세요 예스스탁입니다. 해당식 풀어서 사용하셔야 합니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP18",atlimit,C+0.13); ExitLong("BL18",AtStop,C-0.36); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP18",Atlimit,C-0.13); ExitShort("SL18",AtStop,C+0.36); } } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP29",atlimit,C+0.15); ExitLong("BL29",AtStop,C-0.40); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP29",Atlimit,C-0.15); ExitShort("SL29",AtStop,C+0.40); } } } if MarketPosition == 1 Then{ if IsEntryName("B_15m_md18") == true Then{ ExitLong("BP1",Atlimit,EntryPrice+0.13); ExitLong("BL1",AtStop,EntryPrice-0.36); } if IsEntryName("B_15m_md29") == true Then{ ExitLong("BP2",Atlimit,EntryPrice+0.15); ExitLong("BL2",AtStop,EntryPrice-0.40); } } if MarketPosition == -1 Then{ if IsEntryName("S_15m_md18") == true Then{ ExitShort("SP1",Atlimit,EntryPrice-0.13); ExitShort("SL1",AtStop,EntryPrice+0.36); } if IsEntryName("S_15m_md29") == true Then{ ExitShort("SP2",Atlimit,EntryPrice-0.15); ExitShort("SL2",AtStop,EntryPrice+0.40); } } 강제청산을 제어하는 if문이 봉완성시이고 if조건이 만족하는 봉이 하나가 완성이 되어야 지정된 값으로 셋팅이 변경이 됩니다. 수식에서 특정조건은 if문으로 지정하는 방법뿐이 없고 if문은 봉완성이라 신호가 발생하고 다음봉이 완성이 되어야 셋팅값이 변경되므로 신호발생하고 다음봉에서는 이전의 설정이 적용이 됩니다. 즉 새로운 설정이 적용이 될려면 신호가 발생하고 최소 완성봉이 하나는 생겨야 하기 때문입니다. 작성하신 식이 피라미딩이 가능하게 되어 있고 피라미딩을 하신다면 기존의 식을 사용하셔야 합니다. 각 진입별로 손절이나 목표수익을 가져가게 하려면 강제청산 함수를 사용할수 밖에 없습니다. 즐거운 하루되세요 > 파쿠3 님이 쓴 글입니다. > 제목 : 수식 검토부탁드립니다. > 5분 챠트를 열어놓고, 15분봉을 보고 매매를 하는 시스템입니다. 18번 매매식은 양봉 5개이면 매수 29번은 음봉 5개이면 매도 입니다. 여기서 이상한 점은 29번의 SetStopProfittarget(0.15,PointStop); 을 0.06, 0.09, 0.15로 바꾸면, 18번 이익프로핏이 0.13이 아니라 29번 프로핏타켓과 같은 값으로 청산을 합니다. 항상 그런것은 아니고, 29번 매 뒤에 18번 매매가 올 경우에 그렇습니다. 그리고, 29번 뒤에 18번 거래가 나올경우에는 반대로 29번의 이익틱이 18번 거래에 적용됩니다. 번거로우시겠지만, 수식 검토좀 부탁드립니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); } } If EntryName == "B_15m_md18" or EntryName == "S_15m_md18" Then { SetStopProfittarget(0.13,PointStop); SetStopLoss(0.36,PointStop); } If EntryName == "B_15m_md29" or EntryName == "S_15m_md29" Then { SetStopProfittarget(0.15,PointStop); SetStopLoss(0.40,PointStop); }
프로필 이미지

파쿠3

2013-10-01 18:16:14

피라미딩까지 고려하고 있다보니. 강제청산식을 유지하고자 합니다. 아래 답변주신 내용중에, 완성봉이 하나는 생겨야 한다는 것은, 예를 들어, 현재 5분봉의 크기가 이전 설정의 profittarget 값보다 작다면,, 완성봉이 하나 생긴거니, 제대로 작동을 한다는 뜻인가요? 예를들어. 이전 설정의 프로핏타켓이 15이고, 현재 설정의 타켓이 10 일경우, 현재봉이 완성되기 전에 청산이 안되면(현재봉에서 15틱까지 변동없음), 현재설정의 타켓대로 10에서 청산이 된다는 뜻인가요? -------------- 강제청산을 제어하는 if문이 봉완성시이고 if조건이 만족하는 봉이 하나가 완성이 되어야 지정된 값으로 셋팅이 변경이 됩니다. 수식에서 특정조건은 if문으로 지정하는 방법뿐이 없고 if문은 봉완성이라 신호가 발생하고 다음봉이 완성이 되어야 셋팅값이 변경되므로 신호발생하고 다음봉에서는 이전의 설정이 적용이 됩니다. 즉 새로운 설정이 적용이 될려면 신호가 발생하고 최소 완성봉이 하나는 생겨야 하기 때문입니다. 작성하신 식이 피라미딩이 가능하게 되어 있고 피라미딩을 하신다면 기존의 식을 사용하셔야 합니다. 각 진입별로 손절이나 목표수익을 가져가게 하려면 강제청산 함수를 사용할수 밖에 없습니다. 즐거운 하루되세요 > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 검토부탁드립니다. > 안녕하세요 예스스탁입니다. 해당식 풀어서 사용하셔야 합니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP18",atlimit,C+0.13); ExitLong("BL18",AtStop,C-0.36); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP18",Atlimit,C-0.13); ExitShort("SL18",AtStop,C+0.36); } } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP29",atlimit,C+0.15); ExitLong("BL29",AtStop,C-0.40); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP29",Atlimit,C-0.15); ExitShort("SL29",AtStop,C+0.40); } } } if MarketPosition == 1 Then{ if IsEntryName("B_15m_md18") == true Then{ ExitLong("BP1",Atlimit,EntryPrice+0.13); ExitLong("BL1",AtStop,EntryPrice-0.36); } if IsEntryName("B_15m_md29") == true Then{ ExitLong("BP2",Atlimit,EntryPrice+0.15); ExitLong("BL2",AtStop,EntryPrice-0.40); } } if MarketPosition == -1 Then{ if IsEntryName("S_15m_md18") == true Then{ ExitShort("SP1",Atlimit,EntryPrice-0.13); ExitShort("SL1",AtStop,EntryPrice+0.36); } if IsEntryName("S_15m_md29") == true Then{ ExitShort("SP2",Atlimit,EntryPrice-0.15); ExitShort("SL2",AtStop,EntryPrice+0.40); } } 강제청산을 제어하는 if문이 봉완성시이고 if조건이 만족하는 봉이 하나가 완성이 되어야 지정된 값으로 셋팅이 변경이 됩니다. 수식에서 특정조건은 if문으로 지정하는 방법뿐이 없고 if문은 봉완성이라 신호가 발생하고 다음봉이 완성이 되어야 셋팅값이 변경되므로 신호발생하고 다음봉에서는 이전의 설정이 적용이 됩니다. 즉 새로운 설정이 적용이 될려면 신호가 발생하고 최소 완성봉이 하나는 생겨야 하기 때문입니다. 작성하신 식이 피라미딩이 가능하게 되어 있고 피라미딩을 하신다면 기존의 식을 사용하셔야 합니다. 각 진입별로 손절이나 목표수익을 가져가게 하려면 강제청산 함수를 사용할수 밖에 없습니다. 즐거운 하루되세요 > 파쿠3 님이 쓴 글입니다. > 제목 : 수식 검토부탁드립니다. > 5분 챠트를 열어놓고, 15분봉을 보고 매매를 하는 시스템입니다. 18번 매매식은 양봉 5개이면 매수 29번은 음봉 5개이면 매도 입니다. 여기서 이상한 점은 29번의 SetStopProfittarget(0.15,PointStop); 을 0.06, 0.09, 0.15로 바꾸면, 18번 이익프로핏이 0.13이 아니라 29번 프로핏타켓과 같은 값으로 청산을 합니다. 항상 그런것은 아니고, 29번 매 뒤에 18번 매매가 올 경우에 그렇습니다. 그리고, 29번 뒤에 18번 거래가 나올경우에는 반대로 29번의 이익틱이 18번 거래에 적용됩니다. 번거로우시겠지만, 수식 검토좀 부탁드립니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); } } If EntryName == "B_15m_md18" or EntryName == "S_15m_md18" Then { SetStopProfittarget(0.13,PointStop); SetStopLoss(0.36,PointStop); } If EntryName == "B_15m_md29" or EntryName == "S_15m_md29" Then { SetStopProfittarget(0.15,PointStop); SetStopLoss(0.40,PointStop); }
프로필 이미지

예스스탁 예스스탁 답변

2013-10-01 20:06:30

안녕하세요 예스스탁입니다. 작성하신 시스템에서 신호타입은 onclose입니다. onclose는 봉완성시(다음봉 시가수신)에 if조건만족봉에 신호가 표시가 되는 타입이고 즉 시가가 들어올때 직전봉이 조건이 만족했으면 신호와 함께 주문이 집행되는데 신호를 직전봉의 종가에 표시합니다. [신호표시봉]->[1봉]->[2봉] 그러므로 진입의 이름을 파악할수 있는 봉이 최소 1봉완성시 입니다. 1봉이 완성되면 새로운 설정으로 강제청산이 셋팅이 되므로 2봉후 부터 새로운 설정으로 감시하며 1봉은 이전 셋팅된 값이 적용이 됩니다. 만약 이전의 목표수익이 15이고 변경할 목표수익은 10이고 현재 진입을 100에 했다면 1봉까지는 15가 적용이 되고 2번째 봉부터 10이 적용이 됩니다. 1봉이 이전에 지정한 손절이나 목표수익에 미치지 못하면 2봉 뒤부터는 의도하시는 새로운 설정으로 적용이 됩니다. 피라미딩을 하신다면 이전에 작성한 식을 그대로 사용하셔야 합니다. 답변으로 드린 식인 피라미딩이 아닐때만 사용가능합니다. 즐거운 하루되세요 > 파쿠3 님이 쓴 글입니다. > 제목 : Re : Re : 수식 검토부탁드립니다. > 피라미딩까지 고려하고 있다보니. 강제청산식을 유지하고자 합니다. 아래 답변주신 내용중에, 완성봉이 하나는 생겨야 한다는 것은, 예를 들어, 현재 5분봉의 크기가 이전 설정의 profittarget 값보다 작다면,, 완성봉이 하나 생긴거니, 제대로 작동을 한다는 뜻인가요? 예를들어. 이전 설정의 프로핏타켓이 15이고, 현재 설정의 타켓이 10 일경우, 현재봉이 완성되기 전에 청산이 안되면(현재봉에서 15틱까지 변동없음), 현재설정의 타켓대로 10에서 청산이 된다는 뜻인가요? -------------- 강제청산을 제어하는 if문이 봉완성시이고 if조건이 만족하는 봉이 하나가 완성이 되어야 지정된 값으로 셋팅이 변경이 됩니다. 수식에서 특정조건은 if문으로 지정하는 방법뿐이 없고 if문은 봉완성이라 신호가 발생하고 다음봉이 완성이 되어야 셋팅값이 변경되므로 신호발생하고 다음봉에서는 이전의 설정이 적용이 됩니다. 즉 새로운 설정이 적용이 될려면 신호가 발생하고 최소 완성봉이 하나는 생겨야 하기 때문입니다. 작성하신 식이 피라미딩이 가능하게 되어 있고 피라미딩을 하신다면 기존의 식을 사용하셔야 합니다. 각 진입별로 손절이나 목표수익을 가져가게 하려면 강제청산 함수를 사용할수 밖에 없습니다. 즐거운 하루되세요 > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 검토부탁드립니다. > 안녕하세요 예스스탁입니다. 해당식 풀어서 사용하셔야 합니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP18",atlimit,C+0.13); ExitLong("BL18",AtStop,C-0.36); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP18",Atlimit,C-0.13); ExitShort("SL18",AtStop,C+0.36); } } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitLong("BP29",atlimit,C+0.15); ExitLong("BL29",AtStop,C-0.40); } } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); if MarketPosition == 0 Then{ ExitShort("SP29",Atlimit,C-0.15); ExitShort("SL29",AtStop,C+0.40); } } } if MarketPosition == 1 Then{ if IsEntryName("B_15m_md18") == true Then{ ExitLong("BP1",Atlimit,EntryPrice+0.13); ExitLong("BL1",AtStop,EntryPrice-0.36); } if IsEntryName("B_15m_md29") == true Then{ ExitLong("BP2",Atlimit,EntryPrice+0.15); ExitLong("BL2",AtStop,EntryPrice-0.40); } } if MarketPosition == -1 Then{ if IsEntryName("S_15m_md18") == true Then{ ExitShort("SP1",Atlimit,EntryPrice-0.13); ExitShort("SL1",AtStop,EntryPrice+0.36); } if IsEntryName("S_15m_md29") == true Then{ ExitShort("SP2",Atlimit,EntryPrice-0.15); ExitShort("SL2",AtStop,EntryPrice+0.40); } } 강제청산을 제어하는 if문이 봉완성시이고 if조건이 만족하는 봉이 하나가 완성이 되어야 지정된 값으로 셋팅이 변경이 됩니다. 수식에서 특정조건은 if문으로 지정하는 방법뿐이 없고 if문은 봉완성이라 신호가 발생하고 다음봉이 완성이 되어야 셋팅값이 변경되므로 신호발생하고 다음봉에서는 이전의 설정이 적용이 됩니다. 즉 새로운 설정이 적용이 될려면 신호가 발생하고 최소 완성봉이 하나는 생겨야 하기 때문입니다. 작성하신 식이 피라미딩이 가능하게 되어 있고 피라미딩을 하신다면 기존의 식을 사용하셔야 합니다. 각 진입별로 손절이나 목표수익을 가져가게 하려면 강제청산 함수를 사용할수 밖에 없습니다. 즐거운 하루되세요 > 파쿠3 님이 쓴 글입니다. > 제목 : 수식 검토부탁드립니다. > 5분 챠트를 열어놓고, 15분봉을 보고 매매를 하는 시스템입니다. 18번 매매식은 양봉 5개이면 매수 29번은 음봉 5개이면 매도 입니다. 여기서 이상한 점은 29번의 SetStopProfittarget(0.15,PointStop); 을 0.06, 0.09, 0.15로 바꾸면, 18번 이익프로핏이 0.13이 아니라 29번 프로핏타켓과 같은 값으로 청산을 합니다. 항상 그런것은 아니고, 29번 매 뒤에 18번 매매가 올 경우에 그렇습니다. 그리고, 29번 뒤에 18번 거래가 나올경우에는 반대로 29번의 이익틱이 18번 거래에 적용됩니다. 번거로우시겠지만, 수식 검토좀 부탁드립니다. Input : M15_md18(1), CDTY_15m_md18(1), Deal_15m_md18(0), N_15m_md18(5); Input : M15_md29(1), CDTY_15m_md29(0), Deal_15m_md29(1), N_15m_md29(5); Var : TF_15m(0), OpenV_15m(0), CloseV_15m(0), Cnt_15m(0), dealcond_15m(False); Var : count11_15m(0), count12_15m(0); Var : A1max_15m(0), A2max_15m(0); Array : D1_15m[20](0), A1_15m[20](0), D2_15m[20](0), A2_15m[20](0), CC_15m[20](0), OO_15m[20](0); If M15_md18 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; #initial value is False count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md18 - 1 { If D1_15m[Cnt_15m] == 1 Then # D1 : posi. candle numbers count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then # D1 : nega. candle numbers count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md18 == 0 Then { dealcond_15m = count12_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } If CDTY_15m_md18 == 1 Then { dealcond_15m = count11_15m == N_15m_md18 and A1_15m[N_15m_md18 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md18", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md18 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md18", OnClose, DEF, 1); } } If M15_md29 == 1 Then { TF_15m = TimeToMinutes(sTime)%15; If DayIndex == 0 or (TF_15m < TF_15m[1] and stime > stime[1]) Then { OpenV_15m = O; } CloseV_15m = C; If TF_15m == 10 Then { If CloseV_15m > OpenV_15m Then { # C > O : posi.candle CC_15m[0] = CloseV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = 1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } If CloseV_15m < OpenV_15m Then { # C < O : nega.candle CC_15m[0] = closeV_15m; OO_15m[0] = OpenV_15m; D1_15m[0] = -1; A1_15m[0] = Abs(OpenV_15m - CloseV_15m); For Cnt_15m = 1 to 19 { CC_15m[Cnt_15m] = CC_15m[Cnt_15m - 1][1]; OO_15m[Cnt_15m] = OO_15m[Cnt_15m - 1][1]; D1_15m[Cnt_15m] = D1_15m[Cnt_15m - 1][1]; A1_15m[Cnt_15m] = A1_15m[Cnt_15m - 1][1]; } } } dealcond_15m = False; count11_15m = 0; count12_15m = 0; A1max_15m = 0; A2max_15m = 0; For Cnt_15m = 0 to N_15m_md29 - 1 { If D1_15m[Cnt_15m] == 1 Then count11_15m = count11_15m + 1; If D1_15m[Cnt_15m] == -1 Then count12_15m = count12_15m + 1; If A1_15m[Cnt_15m] > A1max_15m Then A1max_15m = A1_15m[Cnt_15m]; If A2_15m[Cnt_15m] > A2max_15m Then A2max_15m = A2_15m[Cnt_15m]; } If CDTY_15m_md29 == 0 Then { dealcond_15m = count12_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } If CDTY_15m_md29 == 1 Then { dealcond_15m = count11_15m == N_15m_md29 and A1_15m[N_15m_md29 - 1] == A1max_15m; } /************************* // enter section // *************************/ If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 0 and (MarketPosition == 0 or MarketPosition == 1) Then { Buy("B_15m_md29", OnClose, DEF, 1); } If TF_15m == 10 and dealcond_15m == True and Deal_15m_md29 == 1 and (MarketPosition == 0 or MarketPosition == -1) Then { Sell("S_15m_md29", OnClose, DEF, 1); } } If EntryName == "B_15m_md18" or EntryName == "S_15m_md18" Then { SetStopProfittarget(0.13,PointStop); SetStopLoss(0.36,PointStop); } If EntryName == "B_15m_md29" or EntryName == "S_15m_md29" Then { SetStopProfittarget(0.15,PointStop); SetStopLoss(0.40,PointStop); }