커뮤니티

수식 변경부탁드립니다.

프로필 이미지
미완
2019-01-10 10:35:26
185
글번호 125108
답변완료
아래 서식으로 시스템매매 했을시 매수,매도 합산 수익금액이나 손실금액이 목표치에 도달했을 때 거래를 멈추게 되어있는데 매도 진입 후 수익금액이나 손실금액이 만족되었을 시에는 종료 타이틀이 정상적으로 금일종료(수익), 금일종료1(손실)로 나오는데 매수진입 후 수익금액이나 손실금액이 만족되었을 시에는 매수청산1로 나오는데 이것도 매도시와 마찬가지로 금일종료2(수익)나 금일종료3(손실)로 명칭이 나오게끔 수식 변경 부탁드립니다. 당일수익 = PriceScale*당일수익틱수; 당일손실 = PriceScale*당일목표손실; if (sdate != sdate[1] and stime >= b_time1) or (sdate == sdate[1] and stime >= b_time1 and stime[1] < b_time1) Then { Tcond = true; Xcond = false; N1 = NetProfit; } daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] Then { if (IsExitName("금일종료",1) == true or IsExitName("금일종료1",1) == true or IsExitName("금일종료",1) == true or IsExitName("금일종료1",1) == true) then Xcond = true; if daypl >= 당일수익 or daypl <= -당일손실 Then Xcond = true; } value1 = ma(C, shortPeriod); value2 = ma(C, longPeriod); If b_time1<=sTime and sTime<= e_time1 Then { stoK = StochasticsK(stoK_p11,stoK_p12); stoD = StochasticsD(stoK_p11,stoK_p12,stoK_p13); If countif(ma(C,ma_Period11)[1] < ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] <= ma(C,ma_Period13)[1] and ma(C,ma_Period12) > ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] < ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] < ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] < ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] < ma(C,ma_Period17),1) == 1 Then { T1 = 1; } If countif(ma(C,ma_Period11)[1] > ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] >= ma(C,ma_Period13)[1] and ma(C,ma_Period12) < ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] > ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] > ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] > ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] > ma(C,ma_Period17),1) == 1 Then { T1 = -1; } If countif(ma(C,ma_Period21)[1] < ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] <= ma(C,ma_Period23)[1] and ma(C,ma_Period22) > ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] < ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] < ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] < ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] < ma(C,ma_Period27),1) == 1 Then { T2 = 2; } If countif(ma(C,ma_Period21)[1] > ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] >= ma(C,ma_Period23)[1] and ma(C,ma_Period22) < ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] > ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] > ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] > ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] > ma(C,ma_Period27),1) == 1 Then { T2 = -2; } } if Xcond == false and MarketPosition == 0 and T1 == -1 and T2 == -2 and Crossup(stok,상단) and MarketPosition >= 0 then sell("매도",AtMarket); if MarketPosition == -1 Then { ExitShort("금일종료",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); ExitShort("금일종료1",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==1 and T2==2 then ExitShort("매도청산",AtMarket); if Crossdown(stok,하단) and C <= EntryPrice Then ExitShort("매도청산1",AtMarket); } if Xcond == false and MarketPosition == 0 and T1 == 1 and T2 == 2 and Crossdown(stok,하단) and MarketPosition <= 0 then buy("매수",AtMarket); if MarketPosition == 1 Then { ExitShort("금일종료2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); ExitShort("금일종료3",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==-1 and T2==-2 then Exitlong("매수청산",AtMarket); if Crossup(stok,상단) and C >= EntryPrice Then Exitlong("매수청산1",AtMarket); } SetStopProfittarget(PriceScale*익절틱수,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2019-01-10 14:02:26

안녕하세요 예스스탁입니다. 매수포지션 청산은 exitlong 함수입니다. 현재 exitshort으로 되어 있어 신호가 발생하지 않았습니다 수정한 식입니다. 당일수익 = PriceScale*당일수익틱수; 당일손실 = PriceScale*당일목표손실; if (sdate != sdate[1] and stime >= b_time1) or (sdate == sdate[1] and stime >= b_time1 and stime[1] < b_time1) Then { Tcond = true; Xcond = false; N1 = NetProfit; } daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] Then { if (IsExitName("금일종료",1) == true or IsExitName("금일종료1",1) == true or IsExitName("금일종료2",1) == true or IsExitName("금일종료3",1) == true) then Xcond = true; if daypl >= 당일수익 or daypl <= -당일손실 Then Xcond = true; } value1 = ma(C, shortPeriod); value2 = ma(C, longPeriod); If b_time1<=sTime and sTime<= e_time1 Then { stoK = StochasticsK(stoK_p11,stoK_p12); stoD = StochasticsD(stoK_p11,stoK_p12,stoK_p13); If countif(ma(C,ma_Period11)[1] < ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] <= ma(C,ma_Period13)[1] and ma(C,ma_Period12) > ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] < ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] < ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] < ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] < ma(C,ma_Period17),1) == 1 Then { T1 = 1; } If countif(ma(C,ma_Period11)[1] > ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] >= ma(C,ma_Period13)[1] and ma(C,ma_Period12) < ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] > ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] > ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] > ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] > ma(C,ma_Period17),1) == 1 Then { T1 = -1; } If countif(ma(C,ma_Period21)[1] < ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] <= ma(C,ma_Period23)[1] and ma(C,ma_Period22) > ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] < ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] < ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] < ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] < ma(C,ma_Period27),1) == 1 Then { T2 = 2; } If countif(ma(C,ma_Period21)[1] > ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] >= ma(C,ma_Period23)[1] and ma(C,ma_Period22) < ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] > ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] > ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] > ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] > ma(C,ma_Period27),1) == 1 Then { T2 = -2; } } if Xcond == false and MarketPosition == 0 and T1 == -1 and T2 == -2 and Crossup(stok,상단) and MarketPosition >= 0 then sell("매도",AtMarket); if MarketPosition == -1 Then { ExitShort("금일종료",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); ExitShort("금일종료1",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==1 and T2==2 then ExitShort("매도청산",AtMarket); if Crossdown(stok,하단) and C <= EntryPrice Then ExitShort("매도청산1",AtMarket); } if Xcond == false and MarketPosition == 0 and T1 == 1 and T2 == 2 and Crossdown(stok,하단) and MarketPosition <= 0 then buy("매수",AtMarket); if MarketPosition == 1 Then { ExitLong("금일종료2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); Exitlong("금일종료3",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==-1 and T2==-2 then Exitlong("매수청산",AtMarket); if Crossup(stok,상단) and C >= EntryPrice Then Exitlong("매수청산1",AtMarket); } SetStopProfittarget(PriceScale*익절틱수,PointStop); 즐거운 하루되세요 > 미완 님이 쓴 글입니다. > 제목 : 수식 변경부탁드립니다. > 아래 서식으로 시스템매매 했을시 매수,매도 합산 수익금액이나 손실금액이 목표치에 도달했을 때 거래를 멈추게 되어있는데 매도 진입 후 수익금액이나 손실금액이 만족되었을 시에는 종료 타이틀이 정상적으로 금일종료(수익), 금일종료1(손실)로 나오는데 매수진입 후 수익금액이나 손실금액이 만족되었을 시에는 매수청산1로 나오는데 이것도 매도시와 마찬가지로 금일종료2(수익)나 금일종료3(손실)로 명칭이 나오게끔 수식 변경 부탁드립니다. 당일수익 = PriceScale*당일수익틱수; 당일손실 = PriceScale*당일목표손실; if (sdate != sdate[1] and stime >= b_time1) or (sdate == sdate[1] and stime >= b_time1 and stime[1] < b_time1) Then { Tcond = true; Xcond = false; N1 = NetProfit; } daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] Then { if (IsExitName("금일종료",1) == true or IsExitName("금일종료1",1) == true or IsExitName("금일종료",1) == true or IsExitName("금일종료1",1) == true) then Xcond = true; if daypl >= 당일수익 or daypl <= -당일손실 Then Xcond = true; } value1 = ma(C, shortPeriod); value2 = ma(C, longPeriod); If b_time1<=sTime and sTime<= e_time1 Then { stoK = StochasticsK(stoK_p11,stoK_p12); stoD = StochasticsD(stoK_p11,stoK_p12,stoK_p13); If countif(ma(C,ma_Period11)[1] < ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] <= ma(C,ma_Period13)[1] and ma(C,ma_Period12) > ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] < ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] < ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] < ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] < ma(C,ma_Period17),1) == 1 Then { T1 = 1; } If countif(ma(C,ma_Period11)[1] > ma(C,ma_Period11),1) == 1 and (ma(C,ma_Period12)[1] >= ma(C,ma_Period13)[1] and ma(C,ma_Period12) < ma(C,ma_Period13)) and countif(ma(C,ma_Period14)[1] > ma(C,ma_Period14),1) == 1 and countif(ma(C,ma_Period15)[1] > ma(C,ma_Period15),1) == 1 and countif(ma(C,ma_Period16)[1] > ma(C,ma_Period16),1) == 1 and countif(ma(C,ma_Period17)[1] > ma(C,ma_Period17),1) == 1 Then { T1 = -1; } If countif(ma(C,ma_Period21)[1] < ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] <= ma(C,ma_Period23)[1] and ma(C,ma_Period22) > ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] < ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] < ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] < ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] < ma(C,ma_Period27),1) == 1 Then { T2 = 2; } If countif(ma(C,ma_Period21)[1] > ma(C,ma_Period21),1) == 1 and (ma(C,ma_Period22)[1] >= ma(C,ma_Period23)[1] and ma(C,ma_Period22) < ma(C,ma_Period23)) and countif(ma(C,ma_Period24)[1] > ma(C,ma_Period24),1) == 1 and countif(ma(C,ma_Period25)[1] > ma(C,ma_Period25),1) == 1 and countif(ma(C,ma_Period26)[1] > ma(C,ma_Period26),1) == 1 and countif(ma(C,ma_Period27)[1] > ma(C,ma_Period27),1) == 1 Then { T2 = -2; } } if Xcond == false and MarketPosition == 0 and T1 == -1 and T2 == -2 and Crossup(stok,상단) and MarketPosition >= 0 then sell("매도",AtMarket); if MarketPosition == -1 Then { ExitShort("금일종료",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); ExitShort("금일종료1",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==1 and T2==2 then ExitShort("매도청산",AtMarket); if Crossdown(stok,하단) and C <= EntryPrice Then ExitShort("매도청산1",AtMarket); } if Xcond == false and MarketPosition == 0 and T1 == 1 and T2 == 2 and Crossdown(stok,하단) and MarketPosition <= 0 then buy("매수",AtMarket); if MarketPosition == 1 Then { ExitShort("금일종료2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); ExitShort("금일종료3",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts)); if T1==-1 and T2==-2 then Exitlong("매수청산",AtMarket); if Crossup(stok,상단) and C >= EntryPrice Then Exitlong("매수청산1",AtMarket); } SetStopProfittarget(PriceScale*익절틱수,PointStop);