커뮤니티
부탁합니다
2017-06-28 20:21:56
108
글번호 110806
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(12),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
if (CrossDown(value1, value2)) or (CrossDown(value3, value4)) or (mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18) Then
ExitLong("bx");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 < value4 and mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
if (crossup(value1, value2)) or (crossup(value3, value4)) or (mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18) Then
ExitShort("sx");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
위 수식에서
매수진입 b2 추가하고 기존의 피라미딩 bb1,bb2 적용하고 청산수식 bx2을 추가하고자 하며,
반대로 매도진입 s2 추가하고 기존의 피라미딩 ss1,ss2 적용하고 청산수식 sx2을 추가하고자 합니다
정리를 하면
b2------ (value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) 신규 적용
기존의 피라미딩 bb1,bb2 적용
bx2--------(CrossDown(value5, value6)) 적용(b2로 진입한 것은 bx2청산하고자 합니다)
s2-------(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) 신규 적용
기존의 피라미딩 ss1,ss2 적용
sx2--------(crossup(value5, value6)) 적용(s2로 진입한 것은 sx2청산하고자 합니다)
아래 수식은 제가 수식을 수정하였으나 에러 발생합니다
어디에 문제가 있는지 모르겠습니다
수정하여 주시기 바랍니다 감사합니다
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(12),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b1",OnClose,def,1);
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) Then
buy("b2",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
}
if MarketPosition == 1 Then{
if (CrossDown(value1, value2)) or (CrossDown(value3, value4)) or (mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18) Then
exitlong("bx1",OnClose,def,"b1");
if (CrossDown(value5, value6)) Then
exitlong("bx2",OnClose,def,"b2");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and Sxcond == false and
(value1 < value2 and value3 < value4 and mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s1",OnClose,def,1);
if MarketPosition >= 0 and Sxcond == false and
(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) Then
sell("s2",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
}
if MarketPosition == -1 Then{
if (crossup(value1, value2)) or (crossup(value3, value4)) or (mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18) Then
exitlong("sx1",OnClose,def,"s1");
if (crossup(value5, value6)) Then
exitlong("sx2",OnClose,def,"s2");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
답변 3
예스스탁 예스스탁 답변
2017-06-29 11:39:06
안녕하세요
예스스탁입니다.
1
수식은 따로 변경한 부분은 없고 청산식만 조정했습니다.
청산함수에 이름을 지정하면 해당 이름으로 진입된 수량만 청산하고
추가로 진입된 수량은 남게 됩니다.
작성하신 의도가 해당 진입의 수량만 청산이 맞으면 작성하신 내용이 맞고
지정한 이름으로 진입하고 추가로 진입된 수량도 모두 청산이면
if문에서 이름확인하고 전량청산하게 하셔야 합니다.'
2
위와 별게로 b2나 s2가 진입하지 않는 것은 조건이 맞지 않기 때문입니다.
작성하신 식을 보시면
Input : Period(12),sigPeriod(9);
input : Period33(12),sigPeriod34(9)
2개의 trix가 기간이 같아 같은 값입니다.
근데 추가한 수식에는
value1 > value2 and value3 < value4
서로 반대조건이므로 조건자체가 성립되지 않는 것입니다.
기간값을 겹치지 않게 하셔야 합니다.
3
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(15),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and
mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and
mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b1",OnClose,def,1);
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) Then
buy("b2",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
if IsEntryName("b1") == true and (
(CrossDown(value1, value2)) or (CrossDown(value3, value4)) or
(mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and
mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18)) Then
ExitLong("bx1");
if IsEntryName("b2") == true and CrossDown(value5, value6) Then
ExitLong("bx2");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 < value4 and
mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and
mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s1",OnClose,def,1);
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) Then
sell("s2",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
if IsExitName("s1") == true and
((crossup(value1, value2)) or (crossup(value3, value4)) or
(mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and
mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18)) Then
ExitShort("sx1");
if IsExitName("s2") == true and
(crossup(value5, value6)) Then
ExitShort("sx2");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
즐거운 하루되세요
> 남산 님이 쓴 글입니다.
> 제목 : 부탁합니다
> input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(12),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
if (CrossDown(value1, value2)) or (CrossDown(value3, value4)) or (mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18) Then
ExitLong("bx");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 < value4 and mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
if (crossup(value1, value2)) or (crossup(value3, value4)) or (mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18) Then
ExitShort("sx");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
위 수식에서
매수진입 b2 추가하고 기존의 피라미딩 bb1,bb2 적용하고 청산수식 bx2을 추가하고자 하며,
반대로 매도진입 s2 추가하고 기존의 피라미딩 ss1,ss2 적용하고 청산수식 sx2을 추가하고자 합니다
정리를 하면
b2------ (value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) 신규 적용
기존의 피라미딩 bb1,bb2 적용
bx2--------(CrossDown(value5, value6)) 적용(b2로 진입한 것은 bx2청산하고자 합니다)
s2-------(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) 신규 적용
기존의 피라미딩 ss1,ss2 적용
sx2--------(crossup(value5, value6)) 적용(s2로 진입한 것은 sx2청산하고자 합니다)
아래 수식은 제가 수식을 수정하였으나 에러 발생합니다
어디에 문제가 있는지 모르겠습니다
수정하여 주시기 바랍니다 감사합니다
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(12),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b1",OnClose,def,1);
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) Then
buy("b2",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
}
if MarketPosition == 1 Then{
if (CrossDown(value1, value2)) or (CrossDown(value3, value4)) or (mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18) Then
exitlong("bx1",OnClose,def,"b1");
if (CrossDown(value5, value6)) Then
exitlong("bx2",OnClose,def,"b2");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and Sxcond == false and
(value1 < value2 and value3 < value4 and mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s1",OnClose,def,1);
if MarketPosition >= 0 and Sxcond == false and
(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) Then
sell("s2",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
}
if MarketPosition == -1 Then{
if (crossup(value1, value2)) or (crossup(value3, value4)) or (mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18) Then
exitlong("sx1",OnClose,def,"s1");
if (crossup(value5, value6)) Then
exitlong("sx2",OnClose,def,"s2");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
남산
2017-06-29 15:04:57
작성된 수식은 b1, b2, s1,s2 만 진입수량만 청산입니다
추가로 진입된 수량도 모두 청산하려고 하려면 수식으로 변경하여 주시면 고맙겠습니다 실력 부족합니다 매번 감사합니다
b1-bb1-bb2 ====== bx1 모두청산
b2-bb1-bb2 ====== bx2 모두청산
s1-ss1-ss2 ====== sx1 모두청산
s2-ss1-ss2 ====== sx2 모두청산
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(15),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and
mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and
mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b1",OnClose,def,1);
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) Then
buy("b2",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
if IsEntryName("b1") == true and (
(CrossDown(value1, value2)) or (CrossDown(value3, value4)) or
(mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and
mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18)) Then
ExitLong("bx1");
if IsEntryName("b2") == true and CrossDown(value5, value6) Then
ExitLong("bx2");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 < value4 and
mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and
mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s1",OnClose,def,1);
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) Then
sell("s2",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
if IsExitName("s1") == true and
((crossup(value1, value2)) or (crossup(value3, value4)) or
(mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and
mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18)) Then
ExitShort("sx1");
if IsExitName("s2") == true and
(crossup(value5, value6)) Then
ExitShort("sx2");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}
예스스탁 예스스탁 답변
2017-06-29 15:45:56
안녕하세요
예스스탁입니다.
b1-bb1-bb2 ====== bx1 모두청산
b2-bb1-bb2 ====== bx2 모두청산
s1-ss1-ss2 ====== sx1 모두청산
s2-ss1-ss2 ====== sx2 모두청산
기존 답변의 3번으로 답변드린 수식이
올리신 내용과 같이 청산되는 식입니다.
즐거운 하루되세요
> 남산 님이 쓴 글입니다.
> 제목 : Re : Re : 부탁합니다
> 작성된 수식은 b1, b2, s1,s2 만 진입수량만 청산입니다
추가로 진입된 수량도 모두 청산하려고 하려면 수식으로 변경하여 주시면 고맙겠습니다 실력 부족합니다 매번 감사합니다
b1-bb1-bb2 ====== bx1 모두청산
b2-bb1-bb2 ====== bx2 모두청산
s1-ss1-ss2 ====== sx1 모두청산
s2-ss1-ss2 ====== sx2 모두청산
input : 시작시간(090000),종료시간(152000);
input : Period15(160),Period16(300),Period17(600),Period18(10),익절틱수(20),손절틱수(10);
Input : Period(12),sigPeriod(9);
input : Period33(15),sigPeriod34(9);
input : Period43(20),sigPeriod44(15);
var : mav15(0),mav16(0),mav17(0),mav18(0),Bxcond(false),Sxcond(false);
var : Tcond(false);
mav15 = ma(c, Period15);
mav16 = ma(c, Period16);
mav17 = ma(c, Period17);
mav18 = ma(c, Period18);
value1 = TRIX(Period);
value2 = ema(value1, sigPeriod);
value3 = TRIX(Period33);
value4 = ema(value3, sigPeriod34);
value5 = TRIX(Period43);
value6 = ema(value5, sigPeriod44);
if Bdate != Bdate[1] then
{
Tcond = True;
BXcond = false;
SXcond = false;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
if TotalTrades > TotalTrades[1] then{
BXcond = false;
SXcond = false;
if (IsExitName("bl",1) == true or IsExitName("bp",1) == true or IsExitName("bx1",1) == true) Then
BXcond = true;
if (IsExitName("sl",1) == true or IsExitName("sp",1) == true or IsExitName("sx1",1) == true) Then
SXcond = true;
}
if Tcond == true then{
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 > value4 and
mav15[3] < mav15[2] and mav15[2] < mav15[1] and mav15[1] < mav15 and
mav16[1] < mav16 and mav17[1] < mav17 and mav18[1] < mav18) Then
buy("b1",OnClose,def,1);
if MarketPosition <= 0 and Bxcond == false and
(value1 > value2 and value3 < value4 and value5 > value6 and mav18[1] < mav18) Then
buy("b2",OnClose,def,1);
if MarketPosition == 1 Then{
if (mav17[1] < mav17 and mav18[1] < mav18 and CurrentContracts < 3) Then
buy("bb1",OnClose,def,1);
if (mav17[1] < mav17 and mav18[3] >= mav18[2] and mav18[2] <= mav18[1] and mav18[1] < mav18 and CurrentContracts < 5) Then
buy("bb2",OnClose,def,1);
if IsEntryName("b1") == true and (
(CrossDown(value1, value2)) or (CrossDown(value3, value4)) or
(mav17[3] > mav17[2] and mav17[2] > mav17[1] and mav17[1] > mav17 and
mav18[3] > mav18[2] and mav18[2] > mav18[1] and mav18[1] > mav18)) Then
ExitLong("bx1");
if IsEntryName("b2") == true and CrossDown(value5, value6) Then
ExitLong("bx2");
ExitLong("bp",atlimit,AvgEntryPrice+PriceScale*익절틱수);
ExitLong("bl",AtStop,AvgEntryPrice-PriceScale*손절틱수);
}
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 < value4 and
mav15[3] > mav15[2] and mav15[2] > mav15[1] and mav15[1] > mav15 and
mav16[1] > mav16 and mav17[1] > mav17 and mav18[1] > mav18) Then
sell("s1",OnClose,def,1);
if MarketPosition >= 0 and
Sxcond == false and
(value1 < value2 and value3 > value4 and value5 < value6 and mav18[1] > mav18) Then
sell("s2",OnClose,def,1);
if MarketPosition == -1 then{
if mav17[1] > mav17 and mav18[1] > mav18 and CurrentContracts < 3 Then
sell("ss1",OnClose,def,1);
if mav17[1] > mav17 and mav18[3] <= mav18[2] and mav18[2] >= mav18[1] and mav18[1] > mav18 and CurrentContracts < 5 Then
sell("ss2",OnClose,def,1);
if IsExitName("s1") == true and
((crossup(value1, value2)) or (crossup(value3, value4)) or
(mav17[3] < mav17[2] and mav17[2] < mav17[1] and mav17[1] < mav17 and
mav18[3] < mav18[2] and mav18[2] < mav18[1] and mav18[1] < mav18)) Then
ExitShort("sx1");
if IsExitName("s2") == true and
(crossup(value5, value6)) Then
ExitShort("sx2");
ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수);
ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수);
}
}