커뮤니티

추가 문의드립니다.

프로필 이미지
고르면상한가
2021-04-05 18:09:17
1101
글번호 147705
답변완료
안녕하세요 아래와 같이 알려주셨는데요 여기에 혹시 추가적으로 2계약중에서 1계약만 청산된 상태에서 반대 시그널이 발생했을때 보유하고 있던 모든 계약을 청산시키고 발생된 시그널 방향으로 진입하는 부분이 궁금합니다.. 1 input : Per1(10),Per2(25); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*65 Then ExitLong("bx1",AtStop,BH-(BH-EntryPrice)*(Per1/100),"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitLong("bx2",AtStop,BH-(BH-EntryPrice)*(Per2/100),"",1,1); } if MarketPosition == -1 Then { SL = Lowest(L,BarsSinceEntry); if SL <= EntryPrice-PriceScale*65 Then ExitShort("sx1",AtStop,SL+(EntryPrice-SL)*(Per1/100),"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitShort("sx2",AtStop,SL+(EntryPrice-SL)*(Per2/100),"",1,1); } 2 input : tick1(10),Tick2(25); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*65 Then ExitLong("bx1",AtStop,BH-Tick1*PriceScale,"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitLong("bx2",AtStop,BH-Tick2*PriceScale,"",1,1); } if MarketPosition == -1 Then { SL = Lowest(L,BarsSinceEntry); if SL <= EntryPrice-PriceScale*65 Then ExitShort("sx1",AtStop,SL+Tick1*PriceScale,"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitShort("sx2",AtStop,SL+Tick2*PriceScale,"",1,1); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-04-06 11:14:13

안녕하세요 예스스탁입니다. 올려주신 내용은 청산식에 추가하는 부분이 아닙니다. 수식상 진입식에 별도로 포지션 제한이 없으면 자동으로 반대조건 만족시에 스위칭이 됩니다. if MarketPosition <= 0 and 매수진입조건 Then Buy("B",OnClose,DEF,2); if MarketPosition >= 0 and 매도진입조건 Then sell("S",OnClose,DEF,2); 진입이 위와 같이 작성되어 있거나 혹은 아래와 같이 작성이 되어 있으면 포지션 진입중에 반대포지션이 만족하면 자동으로 스위칭이 됩니다. 즉 2계약 모두 청산이 안되있어도 반대조건이 만족하면 청산하고 반대방향으로 진입하게 됩니다. if 매수진입조건 Then Buy("B",OnClose,DEF,2); if 매도진입조건 Then sell("S",OnClose,DEF,2); 만약 스위칭 조건이 2계약 중 1계약만 청산된 상태에서만 발생해야 한다면 아래와 같이 지정하시면 됩니다. if 매수진입조건 Then { if MarketPosition == 0 or (MarketPosition == -1 and CurrentContracts < MaxContracts) Then Buy("B",OnClose,DEF,2); } if 매도진입조건 Then { if MarketPosition == 0 or (MarketPosition == 1 and CurrentContracts < MaxContracts) Then sell("S",OnClose,DEF,2); } 즐거운 하루되세요 > 고르면상한가 님이 쓴 글입니다. > 제목 : 추가 문의드립니다. > 안녕하세요 아래와 같이 알려주셨는데요 여기에 혹시 추가적으로 2계약중에서 1계약만 청산된 상태에서 반대 시그널이 발생했을때 보유하고 있던 모든 계약을 청산시키고 발생된 시그널 방향으로 진입하는 부분이 궁금합니다.. 1 input : Per1(10),Per2(25); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*65 Then ExitLong("bx1",AtStop,BH-(BH-EntryPrice)*(Per1/100),"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitLong("bx2",AtStop,BH-(BH-EntryPrice)*(Per2/100),"",1,1); } if MarketPosition == -1 Then { SL = Lowest(L,BarsSinceEntry); if SL <= EntryPrice-PriceScale*65 Then ExitShort("sx1",AtStop,SL+(EntryPrice-SL)*(Per1/100),"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitShort("sx2",AtStop,SL+(EntryPrice-SL)*(Per2/100),"",1,1); } 2 input : tick1(10),Tick2(25); var : BH(0),SL(0); if MarketPosition == 1 Then { BH = highest(H,BarsSinceEntry); if BH >= EntryPrice+PriceScale*65 Then ExitLong("bx1",AtStop,BH-Tick1*PriceScale,"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitLong("bx2",AtStop,BH-Tick2*PriceScale,"",1,1); } if MarketPosition == -1 Then { SL = Lowest(L,BarsSinceEntry); if SL <= EntryPrice-PriceScale*65 Then ExitShort("sx1",AtStop,SL+Tick1*PriceScale,"",1,1); if BH >= EntryPrice+PriceScale*185 Then ExitShort("sx2",AtStop,SL+Tick2*PriceScale,"",1,1); }