커뮤니티

수식문의드립니다.

프로필 이미지
베비슬립
2019-07-12 07:22:14
119
글번호 130266
답변완료
아래는 예전에 만들어주셨던 당일청산되는식인데 2계약중 1계약이 조건만족하여 청산되고 나머지 1계약은 오버나잇되었다면 나머지1계약이 청산되기전까지 새로진입이 안되게 부탁드립니다 감사합니다 input : xtime(050000); var : R2(0),R1(0),S1(0),S2(0),entry(0); var : Tcond(false),BX1(false),BX2(false),SX1(false),SX2(false); if bdate != bdate[1] then { Tcond = true; entry = 0; } if (sdate != sdate[1] and stime >= xtime) or (sdate == sdate[1] and stime >= xtime and stime[1] < xtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("BX"); if MarketPosition == -1 Then ExitShort("SX"); } R2 = DayLow+PriceScale*200; R1 = DayLow+PriceScale*100; S1 = DayHigh-PriceScale*100; S2 = DayHigh-PriceScale*200; if MarketPosition(0) != 0 and MarketPosition(0) != MarketPosition(0)[1] Then entry = entry+1; if Tcond == true then { if MarketPosition <= 0 and entry < 1 Then { if H < S1 Then buy("b1",AtStop,S1,3); if L > S1 then buy("b2",AtLimit,S1,3); } if MarketPosition >= 0 and entry < 1 Then { if L > R1 Then sell("R1",AtStop,R1,3); if H < R1 Then sell("R2",AtLimit,R1,3); } if MarketPosition == 1 then { if CurrentContracts > CurrentContracts[1] Then { BX1 = false; BX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "bx11" or LatestExitName(0) == "bx12") Then BX1 = true; if (LatestExitName(0) == "bx21" or LatestExitName(0) == "bx22") Then BX2 = true; } if BX1 == false Then { if H < R1 Then ExitLong("bx11",AtLimit,R1,"",1,1); if L > R1 Then ExitLong("bx12",AtStop,R1,"",1,1); } if BX2 == false Then { if H < R2 Then ExitLong("bx21",AtLimit,R2,"",1,1); if L > R2 Then ExitLong("bx22",AtStop,R2,"",1,1); } if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*35 Then ExitLong("bx3",AtStop,EntryPrice); } if MarketPosition == -1 then { if CurrentContracts > CurrentContracts[1] Then { SX1 = false; SX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "sx11" or LatestExitName(0) == "sx12") Then SX1 = true; if (LatestExitName(0) == "sx21" or LatestExitName(0) == "sx22") Then SX2 = true; } if SX1 == False then { if L > S1 Then ExitShort("sx11",AtLimit,S1,"",1,1); if H < S1 Then ExitShort("sx12",AtStop,S1,"",1,1); } if SX2 == false then { if L > S2 Then ExitShort("sx21",AtLimit,S2,"",1,1); if H < S2 Then ExitShort("sx22",AtStop,S2,"",1,1); } if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*35 Then ExitShort("sx3",AtStop,EntryPrice); } } SetStopLoss(PriceScale*20,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2019-07-12 09:26:45

안녕하세용 예스스탁입니다. 현재 수식이 스위칭이 가능한 수식입니다. 진입조건에 현재 포지션 상태가 모두 0(무포지션)일때 진입하게 수정하시면 됩니다. input : xtime(050000); var : R2(0),R1(0),S1(0),S2(0),entry(0); var : Tcond(false),BX1(false),BX2(false),SX1(false),SX2(false); if bdate != bdate[1] then { Tcond = true; entry = 0; } if (sdate != sdate[1] and stime >= xtime) or (sdate == sdate[1] and stime >= xtime and stime[1] < xtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("BX"); if MarketPosition == -1 Then ExitShort("SX"); } R2 = DayLow+PriceScale*200; R1 = DayLow+PriceScale*100; S1 = DayHigh-PriceScale*100; S2 = DayHigh-PriceScale*200; if MarketPosition(0) != 0 and MarketPosition(0) != MarketPosition(0)[1] Then entry = entry+1; if Tcond == true then { if MarketPosition == 0 and entry < 1 Then { if H < S1 Then buy("b1",AtStop,S1,3); if L > S1 then buy("b2",AtLimit,S1,3); } if MarketPosition == 0 and entry < 1 Then { if L > R1 Then sell("R1",AtStop,R1,3); if H < R1 Then sell("R2",AtLimit,R1,3); } if MarketPosition == 1 then { if CurrentContracts > CurrentContracts[1] Then { BX1 = false; BX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "bx11" or LatestExitName(0) == "bx12") Then BX1 = true; if (LatestExitName(0) == "bx21" or LatestExitName(0) == "bx22") Then BX2 = true; } if BX1 == false Then { if H < R1 Then ExitLong("bx11",AtLimit,R1,"",1,1); if L > R1 Then ExitLong("bx12",AtStop,R1,"",1,1); } if BX2 == false Then { if H < R2 Then ExitLong("bx21",AtLimit,R2,"",1,1); if L > R2 Then ExitLong("bx22",AtStop,R2,"",1,1); } if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*35 Then ExitLong("bx3",AtStop,EntryPrice); } if MarketPosition == -1 then { if CurrentContracts > CurrentContracts[1] Then { SX1 = false; SX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "sx11" or LatestExitName(0) == "sx12") Then SX1 = true; if (LatestExitName(0) == "sx21" or LatestExitName(0) == "sx22") Then SX2 = true; } if SX1 == False then { if L > S1 Then ExitShort("sx11",AtLimit,S1,"",1,1); if H < S1 Then ExitShort("sx12",AtStop,S1,"",1,1); } if SX2 == false then { if L > S2 Then ExitShort("sx21",AtLimit,S2,"",1,1); if H < S2 Then ExitShort("sx22",AtStop,S2,"",1,1); } if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*35 Then ExitShort("sx3",AtStop,EntryPrice); } } SetStopLoss(PriceScale*20,PointStop); 즐거운 하루되세요 > 베비슬립 님이 쓴 글입니다. > 제목 : 수식문의드립니다. > 아래는 예전에 만들어주셨던 당일청산되는식인데 2계약중 1계약이 조건만족하여 청산되고 나머지 1계약은 오버나잇되었다면 나머지1계약이 청산되기전까지 새로진입이 안되게 부탁드립니다 감사합니다 input : xtime(050000); var : R2(0),R1(0),S1(0),S2(0),entry(0); var : Tcond(false),BX1(false),BX2(false),SX1(false),SX2(false); if bdate != bdate[1] then { Tcond = true; entry = 0; } if (sdate != sdate[1] and stime >= xtime) or (sdate == sdate[1] and stime >= xtime and stime[1] < xtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("BX"); if MarketPosition == -1 Then ExitShort("SX"); } R2 = DayLow+PriceScale*200; R1 = DayLow+PriceScale*100; S1 = DayHigh-PriceScale*100; S2 = DayHigh-PriceScale*200; if MarketPosition(0) != 0 and MarketPosition(0) != MarketPosition(0)[1] Then entry = entry+1; if Tcond == true then { if MarketPosition <= 0 and entry < 1 Then { if H < S1 Then buy("b1",AtStop,S1,3); if L > S1 then buy("b2",AtLimit,S1,3); } if MarketPosition >= 0 and entry < 1 Then { if L > R1 Then sell("R1",AtStop,R1,3); if H < R1 Then sell("R2",AtLimit,R1,3); } if MarketPosition == 1 then { if CurrentContracts > CurrentContracts[1] Then { BX1 = false; BX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "bx11" or LatestExitName(0) == "bx12") Then BX1 = true; if (LatestExitName(0) == "bx21" or LatestExitName(0) == "bx22") Then BX2 = true; } if BX1 == false Then { if H < R1 Then ExitLong("bx11",AtLimit,R1,"",1,1); if L > R1 Then ExitLong("bx12",AtStop,R1,"",1,1); } if BX2 == false Then { if H < R2 Then ExitLong("bx21",AtLimit,R2,"",1,1); if L > R2 Then ExitLong("bx22",AtStop,R2,"",1,1); } if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*35 Then ExitLong("bx3",AtStop,EntryPrice); } if MarketPosition == -1 then { if CurrentContracts > CurrentContracts[1] Then { SX1 = false; SX2 = false; } if CurrentContracts < CurrentContracts[1] then { if (LatestExitName(0) == "sx11" or LatestExitName(0) == "sx12") Then SX1 = true; if (LatestExitName(0) == "sx21" or LatestExitName(0) == "sx22") Then SX2 = true; } if SX1 == False then { if L > S1 Then ExitShort("sx11",AtLimit,S1,"",1,1); if H < S1 Then ExitShort("sx12",AtStop,S1,"",1,1); } if SX2 == false then { if L > S2 Then ExitShort("sx21",AtLimit,S2,"",1,1); if H < S2 Then ExitShort("sx22",AtStop,S2,"",1,1); } if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*35 Then ExitShort("sx3",AtStop,EntryPrice); } } SetStopLoss(PriceScale*20,PointStop);