커뮤니티
문의
2014-10-30 13:44:04
125
글번호 79915
답변해 주신 내용입니다.
가상손익계산쪽에 주석 부탁드리겠습니다.
감사합니다.
=====================================================================================
아래내용 참고하시기 바랍니다.
문의하신 내용은 가상으로 전략의 수익을 계산해서 사용하셔야 합니다.
실제 신호상 손실에 3번연속 발생하면 다음 가상의 거래중 2번연속 수익이 발생하면
진입합니다. 진입된 신호가 다시 손실이면 다시 가상으로 2번의 연속거래가 수익이어야 다시 진입합니다.
var : T(0),EP(0),PL(0),PL1(0),Xcond(false);
var1=ema(C,5);
var2=ema(C,15);
if MarketPosition == 0 and PositionProfit(1) < 0 and PositionProfit(2) < 0 and PositionProfit(3) < 0 Then
Xcond = true;
else if MarketPosition == 1 and C < EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
else if MarketPosition == -1 and C > EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
Else
Xcond = false;
if crossup(var1,var2) then{
#가상손익 계산
if T == -1 Then{
PL = EP-C;
PL1 = PL[1];
}
EP = C;
T = 1;
if Xcond == false Then
buy("b1");
if Xcond == true and countif(crossup(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
buy("b2");
if MarketPosition == -1 and Xcond == true Then
ExitShort("sx");
}
if crossdown(var1,var2) then{
#가상손익 계산
if T == 1 Then{
PL = C-EP;
PL1 = PL[1];
}
EP = C;
T = -1;
if Xcond == false Then
sell("s1");
if Xcond == true and countif(CrossDown(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
sell("s2");
if MarketPosition == 1 and Xcond == true Then
ExitLong("bx");
}
답변 1
예스스탁 예스스탁 답변
2014-10-30 15:17:28
안녕하세요
예스스탁입니다.
var : T(0),EP(0),PL(0),PL1(0),Xcond(false);
var1=ema(C,5);
var2=ema(C,15);
#현재 무포지션이고 이전 3개의 청산완료된 거래의 손익이 모두 0이하이면 true
if MarketPosition == 0 and PositionProfit(1) < 0 and PositionProfit(2) < 0 and PositionProfit(3) < 0 Then
Xcond = true;
#현재 매수포지션이고 현재 매수진입의 손실이고 0이하 이전 2개의 청산완료 된 거래도 0이하이면 true
else if MarketPosition == 1 and C < EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
#현재 매도포지션이고 현재 매도진입도 손실이고 0이하 이전 2개의 청산완료 된 거래도 0이하이면 true
else if MarketPosition == -1 and C > EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
Else #위 조건들이 아니면 false
Xcond = false;
#이평 골드
if crossup(var1,var2) then{
#가상손익 계산
// T가 -1이면(가상으로 매도진입중)
if T == -1 Then{
PL = EP-C; #PL에 손익저장
PL1 = PL[1]; //PL1에 직전 가상거래의 손익저장
}
EP = C; //EP에 종가저장(가상진입의 진입가)
T = 1; //T에 1저장 (가상진입의 포지션상태)
#Xcond가 false이면 진입
if Xcond == false Then
buy("b1");
#Xcond가 True이면 직전 청산이후에 골드가 2회이상(현재골드포함)이고 모두 가상손익이 모두 수익일때 진입
#골드가 2회이면 중간에 데드가 한번 있으므로 직전 청산신호이후에 가상거래가 2회이상(골드-데드-골드) 발생한것을 의미합니다.
if Xcond == true and countif(crossup(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
buy("b2");
#Xcond가 true이면 청산만
if MarketPosition == -1 and Xcond == true Then
ExitShort("sx");
}
#이평 데드
if crossdown(var1,var2) then{
#가상손익 계산
// T가 1이면(가상으로 매수진입중)
if T == 1 Then{
PL = C-EP; #PL에 손익저장
PL1 = PL[1]; //PL1에 직전 가상거래의 손익저장
}
EP = C; //EP에 종가저장(가상진입의 진입가)
T = -1; //T에 1저장 (가상진입의 포지션상태)
#Xcond가 false이면 진입
if Xcond == false Then
sell("s1");
#Xcond가 True이면 직전 청산이후에 데드가 2회이상(현재데드포함)이고 모두 가상손익이 모두 수익일때 진입
#데드가 2회이면 중간에 골드가 한번 있으므로 직전 청산신호이후에 가상거래가 2회이상(데드-골드-데드) 발생한것을 의미합니다.
if Xcond == true and countif(CrossDown(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
sell("s2");
#Xcond가 true이면 청산만
if MarketPosition == 1 and Xcond == true Then
ExitLong("bx");
}
즐거운 하루되세요
> hjkang철인 님이 쓴 글입니다.
> 제목 : 문의
> 답변해 주신 내용입니다.
가상손익계산쪽에 주석 부탁드리겠습니다.
감사합니다.
=====================================================================================
아래내용 참고하시기 바랍니다.
문의하신 내용은 가상으로 전략의 수익을 계산해서 사용하셔야 합니다.
실제 신호상 손실에 3번연속 발생하면 다음 가상의 거래중 2번연속 수익이 발생하면
진입합니다. 진입된 신호가 다시 손실이면 다시 가상으로 2번의 연속거래가 수익이어야 다시 진입합니다.
var : T(0),EP(0),PL(0),PL1(0),Xcond(false);
var1=ema(C,5);
var2=ema(C,15);
if MarketPosition == 0 and PositionProfit(1) < 0 and PositionProfit(2) < 0 and PositionProfit(3) < 0 Then
Xcond = true;
else if MarketPosition == 1 and C < EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
else if MarketPosition == -1 and C > EntryPrice and PositionProfit(1) < 0 and PositionProfit(2) < 0 Then
Xcond = true;
Else
Xcond = false;
if crossup(var1,var2) then{
#가상손익 계산
if T == -1 Then{
PL = EP-C;
PL1 = PL[1];
}
EP = C;
T = 1;
if Xcond == false Then
buy("b1");
if Xcond == true and countif(crossup(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
buy("b2");
if MarketPosition == -1 and Xcond == true Then
ExitShort("sx");
}
if crossdown(var1,var2) then{
#가상손익 계산
if T == 1 Then{
PL = C-EP;
PL1 = PL[1];
}
EP = C;
T = -1;
if Xcond == false Then
sell("s1");
if Xcond == true and countif(CrossDown(var1,var2),BarsSinceExit(1)) >= 2 and PL > 0 and PL1 > 0 Then
sell("s2");
if MarketPosition == 1 and Xcond == true Then
ExitLong("bx");
}