커뮤니티

수식 문의 드립니다.

프로필 이미지
제이크
2016-07-11 11:52:33
149
글번호 99941
답변완료
안녕하세요. 늘 빠르고 정확한 답변에 감사드리고 싶습니다. 아래 로직에서 추가하고 싶은게 있어서 문의드립니다. 1. 강제 청산 조건에서 현재 20일 이평 만날 경우, 강제 청산으로 되어 있는데, 진입 가격대비 (15틱 이상 멀어질 경우--> 물타기를 하여 2계약 진입이 된 상태에서)를 추가하여, 두 가지 조건중, 조건을 먼저 만족하는 경우 강제 청산을 하는 로직을 추가하고 싶습니다. 2. 해당 로직은 현재 4틱 이상 상승후, 되돌림하여 +2틱이 되면 수익청산을 하게끔 되어 있는데, 6틱 이상 상승후 되돌림하여 +3틱이 되면 수익 청산이 되게끔 수정을 할려면, 아래 수식에서 해당 숫자를 아래와 같이 6과 3으로 변경하면 되는지요? (제가 일부 변경하여 적용해봤는데, 여전히 이전 조건으로 청산이 되는거 같습니다.) if var1 >= EntryPrice+PriceScale*6 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*3); #4틱이상 상승후 진입가+2틱에 도달하면 매수청산 if var1 >= EntryPrice+PriceScale*4 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*2); 늘 감사하게 생각하고 있습니다. 무더위에 조심하세요. _._ ======================================================================================= 수정 반영분. input : P1(5),P2(20); var : D1(0),MM(0),mav(0); MM = stime%100; D1 = C/ma(C,P1); mav = ma(C,p2); #이격이 99.5이하인 시점에 매수진입 if CrossDown(d1,99.5) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then buy("b",OnClose,def,1); #이격이 100.5이상인 시점에 매도진입 if crossup(d1,100.50) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then sell("s",OnClose,def,1); #매수진입후 if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then var1 = H; if H > var1 Then var1 = H; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 하락하면 1계약 추가매수진입 buy("bb",atlimit,EntryPrice-PriceScale*15,1); #진입가+10틱에 청산 ExitLong("bp1",Atlimit,EntryPrice+PriceScale*10); #4틱이상 상승후 진입가+2틱에 도달하면 매수청산 if var1 >= EntryPrice+PriceScale*4 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ #청산이 아직 발생하지 않은 경우 평단가+4틱 수익이면 1계약청 if CurrentContracts == MaxContracts Then ExitLong("bp21",Atlimit,avgEntryPrice+PriceScale*4,"",1,1); #일부청산이 된 경우 if CurrentContracts < MaxContracts Then #평단가 +10틱이상이면 나머지 청산 ExitLong("bp22",Atlimit,AvgEntryPrice+PriceScale*10); #평단가 +4틱이상 상승후 하락해서 평단가+4틱에 도달하면 나머지 청산 if var1 > AvgEntryPrice+PriceScale*4 Then exitlong("bx2",AtStop,EntryPrice+PriceScale*4); } if H < mav Then exitlong("bx21",AtLimit,mav); if L > mav Then exitlong("bx22",AtStop,mav); } #매도진입후 if MarketPosition == -1 Then{ if CurrentContracts > CurrentContracts[1] Then var2 = L; if L < var2 Then var2 = L; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 상승하면 1계약 추가매도진입 sell("ss",atlimit,EntryPrice+PriceScale*15,1); #진입가-10틱에 청산 ExitShort("sp1",Atlimit,EntryPrice-PriceScale*10); #4틱 하락 후 진입가-2틱에 도달하면 매도청산 if var2 <= EntryPrice-PriceScale*4 Then ExitShort("sx1",AtStop,EntryPrice-PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ if CurrentContracts == MaxContracts Then ExitShort("sp21",Atlimit,avgEntryPrice-PriceScale*4); if CurrentContracts < MaxContracts Then ExitShort("sp22",Atlimit,AvgEntryPrice-PriceScale*10); if var2 < AvgEntryPrice-PriceScale*4 Then ExitShort("sx2",AtStop,EntryPrice-PriceScale*4); } if L > mav Then ExitShort("sx21",AtLimit,mav); if H < mav Then ExitShort("sx22",AtStop,mav); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2016-07-12 16:15:40

안녕하세요 예스스탁입니다. 1. input : P1(5),P2(20); var : D1(0),MM(0),mav(0); MM = stime%100; D1 = C/ma(C,P1); mav = ma(C,p2); #이격이 99.5이하인 시점에 매수진입 if CrossDown(d1,99.5) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then buy("b",OnClose,def,1); #이격이 100.5이상인 시점에 매도진입 if crossup(d1,100.50) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then sell("s",OnClose,def,1); #매수진입후 if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then var1 = H; if H > var1 Then var1 = H; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 하락하면 1계약 추가매수진입 buy("bb",atlimit,EntryPrice-PriceScale*15,1); #진입가+10틱에 청산 ExitLong("bp1",Atlimit,EntryPrice+PriceScale*10); #4틱이상 상승후 진입가+2틱에 도달하면 매수청산 if var1 >= EntryPrice+PriceScale*4 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ #청산이 아직 발생하지 않은 경우 평단가+4틱 수익이면 1계약청 if CurrentContracts == MaxContracts Then ExitLong("bp21",Atlimit,avgEntryPrice+PriceScale*4,"",1,1); #일부청산이 된 경우 if CurrentContracts < MaxContracts Then #평단가 +10틱이상이면 나머지 청산 ExitLong("bp22",Atlimit,AvgEntryPrice+PriceScale*10); #평단가 +4틱이상 상승후 하락해서 평단가+4틱에 도달하면 나머지 청산 if var1 > AvgEntryPrice+PriceScale*4 Then exitlong("bx2",AtStop,EntryPrice+PriceScale*4); } if MaxEntries == 2 then{ if H < mav Then exitlong("bx21",AtLimit,mav); if L > mav Then exitlong("bx22",AtStop,mav); } } #매도진입후 if MarketPosition == -1 Then{ if CurrentContracts > CurrentContracts[1] Then var2 = L; if L < var2 Then var2 = L; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 상승하면 1계약 추가매도진입 sell("ss",atlimit,EntryPrice+PriceScale*15,1); #진입가-10틱에 청산 ExitShort("sp1",Atlimit,EntryPrice-PriceScale*10); #4틱 하락 후 진입가-2틱에 도달하면 매도청산 if var2 <= EntryPrice-PriceScale*4 Then ExitShort("sx1",AtStop,EntryPrice-PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ if CurrentContracts == MaxContracts Then ExitShort("sp21",Atlimit,avgEntryPrice-PriceScale*4); if CurrentContracts < MaxContracts Then ExitShort("sp22",Atlimit,AvgEntryPrice-PriceScale*10); if var2 < AvgEntryPrice-PriceScale*4 Then ExitShort("sx2",AtStop,EntryPrice-PriceScale*4); } if MaxEntries == 2 then{ if L > mav Then ExitShort("sx21",AtLimit,mav); if H < mav Then ExitShort("sx22",AtStop,mav); } } 2 예 수정하신 내용이 맞습니다. if var1 >= EntryPrice+PriceScale*6 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*3); if var2 <= EntryPrice-PriceScale*6 Then ExitShort("sx1",AtStop,EntryPrice-PriceScale*3); 즐거운 하루되세요 > 제이크 님이 쓴 글입니다. > 제목 : 수식 문의 드립니다. > 안녕하세요. 늘 빠르고 정확한 답변에 감사드리고 싶습니다. 아래 로직에서 추가하고 싶은게 있어서 문의드립니다. 1. 강제 청산 조건에서 현재 20일 이평 만날 경우, 강제 청산으로 되어 있는데, 진입 가격대비 (15틱 이상 멀어질 경우--> 물타기를 하여 2계약 진입이 된 상태에서)를 추가하여, 두 가지 조건중, 조건을 먼저 만족하는 경우 강제 청산을 하는 로직을 추가하고 싶습니다. 2. 해당 로직은 현재 4틱 이상 상승후, 되돌림하여 +2틱이 되면 수익청산을 하게끔 되어 있는데, 6틱 이상 상승후 되돌림하여 +3틱이 되면 수익 청산이 되게끔 수정을 할려면, 아래 수식에서 해당 숫자를 아래와 같이 6과 3으로 변경하면 되는지요? (제가 일부 변경하여 적용해봤는데, 여전히 이전 조건으로 청산이 되는거 같습니다.) if var1 >= EntryPrice+PriceScale*6 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*3); #4틱이상 상승후 진입가+2틱에 도달하면 매수청산 if var1 >= EntryPrice+PriceScale*4 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*2); 늘 감사하게 생각하고 있습니다. 무더위에 조심하세요. _._ ======================================================================================= 수정 반영분. input : P1(5),P2(20); var : D1(0),MM(0),mav(0); MM = stime%100; D1 = C/ma(C,P1); mav = ma(C,p2); #이격이 99.5이하인 시점에 매수진입 if CrossDown(d1,99.5) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then buy("b",OnClose,def,1); #이격이 100.5이상인 시점에 매도진입 if crossup(d1,100.50) and ((MM >= 0 and MM < 25) or (MM >= 30 and MM < 55)) Then sell("s",OnClose,def,1); #매수진입후 if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then var1 = H; if H > var1 Then var1 = H; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 하락하면 1계약 추가매수진입 buy("bb",atlimit,EntryPrice-PriceScale*15,1); #진입가+10틱에 청산 ExitLong("bp1",Atlimit,EntryPrice+PriceScale*10); #4틱이상 상승후 진입가+2틱에 도달하면 매수청산 if var1 >= EntryPrice+PriceScale*4 Then exitlong("bx1",AtStop,EntryPrice+PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ #청산이 아직 발생하지 않은 경우 평단가+4틱 수익이면 1계약청 if CurrentContracts == MaxContracts Then ExitLong("bp21",Atlimit,avgEntryPrice+PriceScale*4,"",1,1); #일부청산이 된 경우 if CurrentContracts < MaxContracts Then #평단가 +10틱이상이면 나머지 청산 ExitLong("bp22",Atlimit,AvgEntryPrice+PriceScale*10); #평단가 +4틱이상 상승후 하락해서 평단가+4틱에 도달하면 나머지 청산 if var1 > AvgEntryPrice+PriceScale*4 Then exitlong("bx2",AtStop,EntryPrice+PriceScale*4); } if H < mav Then exitlong("bx21",AtLimit,mav); if L > mav Then exitlong("bx22",AtStop,mav); } #매도진입후 if MarketPosition == -1 Then{ if CurrentContracts > CurrentContracts[1] Then var2 = L; if L < var2 Then var2 = L; #진입이 1번일경우 if MaxEntries == 1 Then{ #15틱 상승하면 1계약 추가매도진입 sell("ss",atlimit,EntryPrice+PriceScale*15,1); #진입가-10틱에 청산 ExitShort("sp1",Atlimit,EntryPrice-PriceScale*10); #4틱 하락 후 진입가-2틱에 도달하면 매도청산 if var2 <= EntryPrice-PriceScale*4 Then ExitShort("sx1",AtStop,EntryPrice-PriceScale*2); } #진입이 2번일 경우 if MaxEntries == 2 Then{ if CurrentContracts == MaxContracts Then ExitShort("sp21",Atlimit,avgEntryPrice-PriceScale*4); if CurrentContracts < MaxContracts Then ExitShort("sp22",Atlimit,AvgEntryPrice-PriceScale*10); if var2 < AvgEntryPrice-PriceScale*4 Then ExitShort("sx2",AtStop,EntryPrice-PriceScale*4); } if L > mav Then ExitShort("sx21",AtLimit,mav); if H < mav Then ExitShort("sx22",AtStop,mav); }