커뮤니티
생각하는데로 안되네요..ㅠㅠ
2018-11-15 18:35:48
181
글번호 123714
구현하려는 것
1.국내 ETF ( kodex200) 10분봉
2.당일매수후 익절/손절 또는 지정된시간(2시 50분)에 청산
3.매수방법: 연속 양봉시 매수진입
이것을 참조로 아래 식을 만들었는데.. 실제로는 당일 지정된 시간에 청산이 되지 않네요...
익절 또는 손절만 구현되네요..ㅠㅠ
알려주세요...
input : p1(5),p2(33),p3(75),X(5),Y(8),XX(6),YY(9),XXX(6),YYY(5);
input : 익절틱수(128),손절틱수(79),차이틱수(12);
input : P6(1),starttime(090000),endtime(143000);
var : Tcond(false);
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
Condition1 = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then
Condition1 = true;
if Condition1 == true and BarsSinceExit(1) >= P6 Then
Condition1 = false;
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
var1 = ma(c,P1);
var2 = ma(c,P2);
var3 = ma(c,P3);
if var1 > var2 and var2 > var3 then
{
if MarketPosition == 0 and CountIF(C>O,Y) == Y and C >= C[Y-1]+PriceScale*차이틱수 Then
buy("정배매수");
}
else if var1 < var2 and var2 < var3 then
{
if MarketPosition == 0 and CountIF(C>O,YY) == YY and C >= C[YY-1]+PriceScale*차이틱수 Then
buy("역배매수");
}
else
{
if MarketPosition == 0 and CountIF(C>O,YYY) == YYY and C >= C[YYY-1]+PriceScale*차이틱수 Then
buy("혼재매수");
}
SetStopProfittarget(PriceScale*익절틱수, PointStop);
SetStopLoss(PriceScale*손절틱수, PointStop);
답변 1
예스스탁 예스스탁 답변
2018-11-16 10:18:33
안녕하세요
예스스탁입니다.
1
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
Condition1 = false;
}
위와 같은 표현은 24시간 거래되는 해외선물이나
국내선물 주야간복합에서 새벽에 청산할때 사용됩니다.
국내주식은 해당설정이 필요없습니다.
2
수식에 시작시간부터 끝시간까지를 체크하는 Tcond라는 변수에 값을 할당이 되어 있지만
진입이나 청산에 해당 변수를 이용해 조건을 지정한 부분이 없습니다.
진입식에 조건을 지정해 추가하셔야 합니다.
3
수정한 식입니다.
input : p1(5),p2(33),p3(75),X(5),Y(8),XX(6),YY(9),XXX(6),YYY(5);
input : 익절틱수(128),손절틱수(79),차이틱수(12);
input : P6(1),starttime(090000),endtime(143000);
var : Tcond(false);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
Condition1 = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then
Condition1 = true;
if Condition1 == true and BarsSinceExit(1) >= P6 Then
Condition1 = false;
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
var1 = ma(c,P1);
var2 = ma(c,P2);
var3 = ma(c,P3);
if Tcond == true then
{
if var1 > var2 and var2 > var3 then
{
if MarketPosition == 0 and CountIF(C>O,Y) == Y and C >= C[Y-1]+PriceScale*차이틱수 Then
buy("정배매수");
}
else if var1 < var2 and var2 < var3 then
{
if MarketPosition == 0 and CountIF(C>O,YY) == YY and C >= C[YY-1]+PriceScale*차이틱수 Then
buy("역배매수");
}
else
{
if MarketPosition == 0 and CountIF(C>O,YYY) == YYY and C >= C[YYY-1]+PriceScale*차이틱수 Then
buy("혼재매수");
}
}
SetStopProfittarget(PriceScale*익절틱수, PointStop);
SetStopLoss(PriceScale*손절틱수, PointStop);
SetStopEndofday(endtime);
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 생각하는데로 안되네요..ㅠㅠ
> 구현하려는 것
1.국내 ETF ( kodex200) 10분봉
2.당일매수후 익절/손절 또는 지정된시간(2시 50분)에 청산
3.매수방법: 연속 양봉시 매수진입
이것을 참조로 아래 식을 만들었는데.. 실제로는 당일 지정된 시간에 청산이 되지 않네요...
익절 또는 손절만 구현되네요..ㅠㅠ
알려주세요...
input : p1(5),p2(33),p3(75),X(5),Y(8),XX(6),YY(9),XXX(6),YYY(5);
input : 익절틱수(128),손절틱수(79),차이틱수(12);
input : P6(1),starttime(090000),endtime(143000);
var : Tcond(false);
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
Condition1 = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then
Condition1 = true;
if Condition1 == true and BarsSinceExit(1) >= P6 Then
Condition1 = false;
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
var1 = ma(c,P1);
var2 = ma(c,P2);
var3 = ma(c,P3);
if var1 > var2 and var2 > var3 then
{
if MarketPosition == 0 and CountIF(C>O,Y) == Y and C >= C[Y-1]+PriceScale*차이틱수 Then
buy("정배매수");
}
else if var1 < var2 and var2 < var3 then
{
if MarketPosition == 0 and CountIF(C>O,YY) == YY and C >= C[YY-1]+PriceScale*차이틱수 Then
buy("역배매수");
}
else
{
if MarketPosition == 0 and CountIF(C>O,YYY) == YYY and C >= C[YYY-1]+PriceScale*차이틱수 Then
buy("혼재매수");
}
SetStopProfittarget(PriceScale*익절틱수, PointStop);
SetStopLoss(PriceScale*손절틱수, PointStop);
다음글
이전글