예스스탁
예스스탁 답변
2021-04-29 15:20:59
안녕하세요
예스스탁입니다.
input : howmany(5),pause(26);
input : n1(1), n2(1), n3(2),n4(3),n5(4);
Input: k1(2), k2(3), k3(3), k4(4), k익절(5), k손절(6), k중립(5), k유리(6);
var : upp(false), dnn(false), T(0), Left(3), right(3);
var : ATRV(0),HH(0),LL(0),SHV(0),SHI(0),SLV(0),SLi(0);
var : HC(0),LC(0),EP1(0),EP2(0),EP3(0),EP4(0),중심선(0),neutral(False);
중심선 = (highest(H,96) + lowest(L,96))/2 ;
upp = ma(c,15) > ma(C,60) and ma(c,60) > ma(c,150);
dnn= ma(c,15) < ma(C,60) and ma(c,60) < ma(c,150);
neutral = upp == False and dnn == False;
ATRV = ATR(96);
if upp Then
{
T = 1;
if MarketPosition == -1 Then
ExitShort();
}
if dnn Then
{
T = -1;
if MarketPosition == 1 Then
exitlong();
}
if neutral Then
t = 0;
if SwingHigh(1,h,Left,right,Left+right+1) != -1 Then
{
SHV = H[3];
SHI = 0;
}
if SwingLow(1,l,Left,right,Left+right+1) != -1 Then
{
SLV = L[3];
SLI = 0;
}
SHI = SHI+1;
SLI = SLI+1;
if T == 1 and T != T[1] Then // HH == upp로 바뀐 이후의 최고값
HH = H;
if T == -1 and T != T[1] Then // LL == dnn으로 바뀐 이후의 최저값
LL = L;
if T == 1 Then
{
if H > HH Then
HH = H;
if T[1] != 1 Then
buy("b1",OnClose,def,n1);
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] or (MarketPosition != MarketPosition(0)[1]) Then
{
HC = C;
EP1 = LatestEntryPrice(0);
EP2 = EP1[1];
EP3 = EP2[1];
EP4 = EP3[1];
}
if HC > 0 and C > HC Then // 그러니까 HC 는 Highest of C 정도 되겠구나. C들의 최고값치!
HC = C;
if CurrentEntries == 1 Then
{
if CurrentEntries < Howmany and
((C < LatestEntryPrice(0) - k1*Atrv && C>O) or
(C < LatestEntryPrice(0) - k2*Atrv) or
(C < HC - k3*Atrv) or
(C < HC - k4*ATrv and C > O)) Then
Buy("b2",OnClose,DEf,n2);
}
if CurrentEntries == 2 Then
{
if Howmany >= 2 Then
ExitLong("b2p2",AtLimit,LatestEntryPrice(0) + k익절*ATrv,"b2");
if Howmany == 2 Then
ExitLong("b2L2",Atstop,LatestEntryPrice(0) - k손절*ATrv,"b2");
if CurrentEntries < Howmany and
((C < LatestEntryPrice(0) - k3*Atrv && C > O) or
(C < LatestEntryPrice(0) - k4*ATrv)) Then
Buy("b3",OnClose,DEf,n3);
}
if CurrentEntries == 3 Then // 현재까지 총 3번 진입했다면, 즉, 신호대로 n1개 및 물타기 2번에 걸친 n2, n3개 진입되었다면
{
if Howmany >= 3 Then
{
ExitLong("b3p2",AtLimit,(n2*EP1+n1*EP2)/(n1+n2) + k익절*ATrv,"b2"); // 수정했다!
ExitLong("b3p3",AtLimit,(n2*EP1+n1*EP2)/(n1+n2) + k익절*ATrv,"b3");
}
if Howmany == 3 Then
{
ExitLong("b3l2",Atstop, EP1 - k손절*ATrv,"b2"); // 수정했다!!
ExitLong("b3l3",Atstop, EP1 - k손절*ATrv,"b3");
}
if CurrentEntries < Howmany and
((C < LatestEntryPrice(0) - k3*Atrv && C > O) or
(C < LatestEntryPrice(0) - k4*ATrv)) Then
Buy("b4",OnClose,DEf,n4);
}
if CurrentEntries == 4 Then
{
if Howmany >= 4 Then
{
ExitLong("b4p2",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) + k익절*ATrv,"b2"); // 수정했다
ExitLong("b4p3",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) + k익절*ATrv,"b3");
ExitLong("b4p4",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) + k익절*ATrv,"b4");
}
if Howmany == 4 Then
{
ExitLong("b4l2",Atstop, EP1 - k손절*ATrv,"b2"); // 수정했다.
ExitLong("b4l3",Atstop, EP1 - k손절*ATrv,"b3");
ExitLong("b4l4",Atstop, EP1 - k손절*ATrv,"b4");
}
if CurrentEntries < Howmany and
((C < LatestEntryPrice(0) - k3*Atrv && C > O) or
(C < LatestEntryPrice(0) - k4*ATrv)) Then
Buy("b5",OnClose,DEf,n5);
}
if CurrentEntries == 5 Then
{
exitLong("b5p2",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) + k익절*ATrv,"b2");
exitLong("b5p3",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) + k익절*ATrv,"b3");
exitLong("b5p4",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) + k익절*ATrv,"b4");
exitLong("b5p5",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) + k익절*ATrv,"b5");
exitLong("b5l2",AtStop,LatestEntryPrice(0) - k손절*ATrv,"b2");
exitLong("b5l3",AtStop,LatestEntryPrice(0) - k손절*ATrv,"b3");
exitLong("b5l4",AtStop,LatestEntryPrice(0) - k손절*ATrv,"b4");
exitLong("b5l5",AtStop,LatestEntryPrice(0) - k손절*ATrv,"b5");
}
}
}
if T == -1 Then
{
if L < LL Then
LL = L;
if T[1] != -1 Then
Sell("s1",OnClose,def,n1);
if MarketPosition == -1 Then
{
if CurrentContracts > CurrentContracts[1] or (MarketPosition != MarketPosition(0)[1]) Then
{
LC = L;
EP1 = LatestEntryPrice(0);
EP2 = EP1[1];
EP3 = EP2[1];
EP4 = EP3[1];
}
if LC > 0 and C < LC Then
LC = C;
if CurrentEntries == 1 Then
{
if CurrentEntries < Howmany and
((C > LatestEntryPrice(0) + k1*Atrv && C < O) or
(C > LatestEntryPrice(0) + k2*Atrv) or
(C > LC + k3*Atrv) or
(C > LC + k4*ATrv and C < O)) Then
Sell("s2",OnClose,DEf,n2);
}
if CurrentEntries == 2 Then
{
if Howmany >= 2 Then
ExitShort("s2p2",AtLimit,LatestEntryPrice(0) - k익절*ATrv,"s2");
if Howmany == 2 Then
ExitShort("s2l2",Atstop,LatestEntryPrice(0) + k손절*ATrv,"s2");
if CurrentEntries < Howmany and
((C > LatestEntryPrice(0) + k3*Atrv && C < O) or
(C > LatestEntryPrice(0) + k4*ATrv)) Then
Sell("s3",OnClose,DEf,n3);
}
if CurrentEntries == 3 Then
{
if Howmany >= 3 Then
{
ExitShort("s3p2",AtLimit,(n2*EP1+n1*EP2)/(n1+n2) - k익절*ATrv,"s2"); // 수정했다
ExitShort("s3p3",AtLimit,(n2*EP1+n1*EP2)/(n1+n2) - k익절*ATrv,"s3");
}
if Howmany == 3 Then
{
ExitShort("s3l2",Atstop, EP1 + k손절*ATrv,"s2"); // 수정했다
ExitShort("s3l3",Atstop, EP1 + k손절*ATrv,"s3");
}
if CurrentEntries < Howmany and
((C > LatestEntryPrice(0) + k3*Atrv && C < O) or
(C > LatestEntryPrice(0) + k4*ATrv)) Then
Sell("s4",OnClose,DEf,n4);
}
if CurrentEntries == 4 Then
{
if Howmany >= 4 Then
{
ExitShort("s4p2",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) - k익절*ATrv,"s2"); // 수정했다
ExitShort("s4p3",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) - k익절*ATrv,"s3");
ExitShort("s4p4",AtLimit,(n3*EP1+n2*EP2+n1*EP3)/(n1+n2+n3) - k익절*ATrv,"s4");
}
if Howmany == 4 Then
{
ExitShort("s4l2",Atstop, EP1 + k손절*ATrv,"s2"); // 수정했다
ExitShort("s4l3",Atstop, EP1 + k손절*ATrv,"s3");
ExitShort("s4l4",Atstop, EP1 + k손절*ATrv,"s4");
}
if CurrentEntries < Howmany and
((C > LatestEntryPrice(0) + k3*Atrv && C < O) or
(C > LatestEntryPrice(0) + k4*ATrv)) Then
Sell("s5",OnClose,DEf,n5);
}
if CurrentEntries == 5 Then
{
ExitShort("s5p2",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) - k익절*ATrv,"s2"); // 수정했다
ExitShort("s5p3",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) - k익절*ATrv,"s3");
ExitShort("s5p4",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) - k익절*ATrv,"s4");
ExitShort("s5p5",AtLimit,(n4*EP1+n3*EP2+n2*EP3+n1*EP4)/(n1+n2+n3+n4) - k익절*ATrv,"s5");
ExitShort("s5l2",AtStop,LatestEntryPrice(0) + k손절*ATrv,"s2");
ExitShort("s5l3",AtStop,LatestEntryPrice(0) + k손절*ATrv,"s3");
ExitShort("s5l4",AtStop,LatestEntryPrice(0) + k손절*ATrv,"s4");
ExitShort("s5l5",AtStop,LatestEntryPrice(0) + k손절*ATrv,"s5");
}
}
}
if t == 0 Then
{
if (MarketPosition == 0 and IsExitName("nbl",1) == False) or
(MarketPosition == 0 and IsExitName("nbl",1) == true and BarsSinceExit(1) >= pause) or
MarketPosition == -1 Then
{
if C < (중심선 - k중립*Atrv) Then
{
Buy("nb",OnClose,DEF,1);
}
}
if MarketPosition == 0 and IsExitName("nbl",1) == true Then
{
if C < (LatestExitPrice(1) - k유리*Atrv) Then
{
Buy("nb1",OnClose,DEF,1);
}
}
if MarketPosition == 1 Then
{
if C <= LatestEntryPrice(0)-k3*Atrv and MaxContracts < Howmany Then
Buy("nbb",OnClose,DEf,1);
if MaxContracts == Howmany Then
ExitLong("nbl",AtStop,LatestEntryPrice(0)-k손절*Atrv);
ExitLong("nbp",AtLimit,avgEntryPrice+k유리*Atrv);
}
if (MarketPosition == 0 and IsExitName("nsl",1) == False) or
(MarketPosition == 0 and IsExitName("nsl",1) == true and BarsSinceExit(1) >= pause) or
MarketPosition == 1 Then
{
if C > (중심선 + k중립*Atrv) Then
Sell("ns",OnClose,DEF,1);
}
if MarketPosition == 0 and IsExitName("nsl",1) == true Then
{
if C > (LatestExitPrice(1) + k유리*Atrv) Then
{
Sell("ns1",OnClose,DEF,1);
}
}
if MarketPosition == -1 Then
{
if C >= LatestEntryPrice(0)+k3*Atrv and MaxContracts < Howmany Then
Sell("nss",OnClose,DEf,1);
if MaxContracts == Howmany Then
ExitShort("nsl",AtStop,LatestEntryPrice(0)+k손절*Atrv);
ExitShort("nsp",AtLimit,avgEntryPrice-k유리*Atrv);
}
}
즐거운 하루되세요
> 에구머니 님이 쓴 글입니다.
> 제목 : 수식 문의
> 안녕하세요?
수식 수정 부탁드립니다.
참, 중심선은 96기간의 최고값과 최저값의 평균입니다.
감사합니다.