커뮤니티
수식 문의드립니다.
2016-07-12 18:15:33
136
글번호 100001
안녕하세요.
앞에서 아래 질문에 대한 답변이 빠진것 같아 재문의 드립니다.
1. 강제 청산 조건에서
현재 20일 이평 만날 경우, 강제 청산으로 되어 있는데,
진입 가격대비 15틱 이상 멀어질 경우 강제청산 조건을 추가하여,
두 가지 조건중, 조건을 먼저 만족하는 경우 강제 청산을 하는 로직을 추가하고 싶습니다.
감사합니다.
=======================================================================================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);
}
}
답변 1
예스스탁 예스스탁 답변
2016-07-13 10:55:26
안녕하세요
예스스탁입니다.
현재 기존수식에 진입 후 15틱 하락/상승하면 추가매수/추가매도가
되게 식이 구성되어 있습니다.
15틱 강제청산과 추가 진입조건이 같습니다.
또한 15틱이 멀어지는 방향이 수익인지 손실인지 정확치 않습니다.
추가진입이후 최근 진입가격대비 15틱 손실이면 청산하게 추가해 드립니다.
현재 수식이 수익/손실등에 대한 내용이 모두 있습니다.
수식 내용 참고하셔서 위 내용이 아니시면 수정보완하시기 바랍니다.
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{
ExitLong("bx",AtStop,LatestEntryPrice-PriceScale*15);
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{
ExitShort("sx",AtStop,LatestEntryPrice+PriceScale*15);
if L > mav Then
ExitShort("sx21",AtLimit,mav);
if H < mav Then
ExitShort("sx22",AtStop,mav);
}
}
즐거운 하루되세요
> 제이크 님이 쓴 글입니다.
> 제목 : 수식 문의드립니다.
> 안녕하세요.
앞에서 아래 질문에 대한 답변이 빠진것 같아 재문의 드립니다.
1. 강제 청산 조건에서
현재 20일 이평 만날 경우, 강제 청산으로 되어 있는데,
진입 가격대비 15틱 이상 멀어질 경우 강제청산 조건을 추가하여,
두 가지 조건중, 조건을 먼저 만족하는 경우 강제 청산을 하는 로직을 추가하고 싶습니다.
감사합니다.
=======================================================================================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);
}
}
이전글