커뮤니티
수식수정
2017-03-23 13:15:24
112
글번호 108132
1. 전에 올려주신 수식을 약간 수정해서 사용중인데요. 제가 잘못설정한것인지 어떤지 잘 모르겠지만 4회까지까지 매수하면 전부 매수한 금액이 투자금액과 비슷해야 하는거 아닌가요?
시스템을 돌려보면 투자금액을 훨씬 웃도는 현상이 발생합니다. 수식에 잘못된 부분이 있으면 수정좀 부탁드립니다..
2. 매도신호가 떴으나 매도가 되지 않는경우, 매수신호가 떴으나 매수가 되지 않는경우는 자동정정을 안해서 그런건가요?
매번 항상 감사드립니다.
Input : 투자금액(1000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24),P3(99), 시작일(20170323),시작시간(90000);
Input : LENGTH(10),loss(5);
var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false);
Var : TCHAN(0), BCHAN(0),T1(0),T2(0);
var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0),Cma3(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
MAv = ma(C,Period);
MACDV = MACD(Short,long);
MACDS = ema(MACDV,sig);
MACDO = MACDV-MACDS;
Vma = ma(v,VP);
Cma1 = ma(C,P1);
Cma2 = ma(C,P2);
Cma3 = ma(C,P3);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
vv[0] = floor((투자금액*0.1)/C);
vv[1] = floor((투자금액*0.2)/C);
vv[2] = floor((투자금액*0.3)/C);
vv[3] = floor((투자금액*0.4)/C);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if Tcond == true then{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{
if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2
and dayhigh < DayClose(1)*1.18 and stime < 150000 Then
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] Then{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.08 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-3%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}
}
답변 1
예스스탁 예스스탁 답변
2017-03-23 15:17:41
안녕하세요
예스스탁입니다.
1
수량은 봉완성시 종가로 계산하고
신호는 다음봉 시가가격으로 되어 있어 오차가 있었습니다.
수량 산정을 봉완성이 되는 다음봉 시가로 수정했습니다.
2
시스템은 지정한 조건이면 주문만 발생합니다.
주문이후의 미체결부분은 수식안에서 알수가 없습니다.
해당 부분은 부가기능의 시간자동정정을 이용해 보셔야 하고
그래도 체결이 안되면 수동으로 관리해 주셔야 합니다.
3 수정한 식입니다.
Input : 투자금액(1000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24),P3(99), 시작일(20170323),시작시간(90000);
Input : LENGTH(10),loss(5);
var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false);
Var : TCHAN(0), BCHAN(0),T1(0),T2(0);
var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0),Cma3(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
MAv = ma(C,Period);
MACDV = MACD(Short,long);
MACDS = ema(MACDV,sig);
MACDO = MACDV-MACDS;
Vma = ma(v,VP);
Cma1 = ma(C,P1);
Cma2 = ma(C,P2);
Cma3 = ma(C,P3);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
vv[0] = floor((투자금액*0.1)/NextBarOpen);
vv[1] = floor((투자금액*0.2)/NextBarOpen);
vv[2] = floor((투자금액*0.3)/NextBarOpen);
vv[3] = floor((투자금액*0.4)/NextBarOpen);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if Tcond == true then{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{
if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2
and dayhigh < DayClose(1)*1.18 and stime < 150000 Then
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] Then{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.08 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-3%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}
}
즐거운 하루되세요
> 바나 님이 쓴 글입니다.
> 제목 : 수식수정
> 1. 전에 올려주신 수식을 약간 수정해서 사용중인데요. 제가 잘못설정한것인지 어떤지 잘 모르겠지만 4회까지까지 매수하면 전부 매수한 금액이 투자금액과 비슷해야 하는거 아닌가요?
시스템을 돌려보면 투자금액을 훨씬 웃도는 현상이 발생합니다. 수식에 잘못된 부분이 있으면 수정좀 부탁드립니다..
2. 매도신호가 떴으나 매도가 되지 않는경우, 매수신호가 떴으나 매수가 되지 않는경우는 자동정정을 안해서 그런건가요?
매번 항상 감사드립니다.
Input : 투자금액(1000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24),P3(99), 시작일(20170323),시작시간(90000);
Input : LENGTH(10),loss(5);
var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false);
Var : TCHAN(0), BCHAN(0),T1(0),T2(0);
var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0),Cma3(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
MAv = ma(C,Period);
MACDV = MACD(Short,long);
MACDS = ema(MACDV,sig);
MACDO = MACDV-MACDS;
Vma = ma(v,VP);
Cma1 = ma(C,P1);
Cma2 = ma(C,P2);
Cma3 = ma(C,P3);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
vv[0] = floor((투자금액*0.1)/C);
vv[1] = floor((투자금액*0.2)/C);
vv[2] = floor((투자금액*0.3)/C);
vv[3] = floor((투자금액*0.4)/C);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if Tcond == true then{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{
if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2
and dayhigh < DayClose(1)*1.18 and stime < 150000 Then
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] Then{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and C >=dayclose(1) and CrossUp(ma(C,5), ma(C,24)) and stime < 150000 Then{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.08 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-3%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}
}
다음글
이전글