커뮤니티
청산 스위침 로직
2019-09-16 09:18:14
225
글번호 131923
* 좋은 명절 되십시요.
* 많은 도움에 고맙 습니다.
<요청1> 매수가 대비 수익이면 빨강색(선두께3) 손해면 파랑색(선두께3) 보합이면 검은색 으로 수정 좀 부탁 드립니다.
var : TL(0);
if MarketPosition != 0 Then{if MarketPosition != MarketPosition[1] Then TL = TL_New(sdate[1],stime[1],EntryPrice,sdate,stime,EntryPrice); Else TL_SetEnd(TL,sdate,stime,EntryPrice); }
< 요청2 >
* 청산후 스위칭 로직이 "목표40만원달성1" 에 안걸리는데 로직 좀 수정 요청 드립니다.
<그림1> 첨부 파일(그림빨강색) 마지막 스위칭 매매는 안되야 하는데 매매가 됨니다.
스위칭 부분은 daypl >= PriceScale*40 이 부분이 적용 안 되는것 갔습니다.
즉 목표 달성 했는데 스위칭 로직은 매매가 됨니다.
목표 달성하면 매매가 안되야 하는데 스위칭은 매매가 됨니다.
아래 로직 좀 목표 달성 하면 스위칭도 매매 안 되게 수정 좀 부탁 드리겠습니다.
<그림2> 처럼 연속 손실 나는 경우도 있는데 연속손실 3회 이상이면 매매금지 부탁 드립니다.
## 아래 로직
Input : 당일수익틱수(50);
var : N1(0),dayPl(0),당일수익(0),Xcond(false);
당일수익 = PriceScale*당일수익틱수;
if Bdate != Bdate[1] Then{Xcond = false; N1 = NetProfit; }
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then{if daypl >= PriceScale*40 Then Xcond = true; if (IsExitName("목표40만원달성1",1) == true or IsExitName("목표40만원달성2",1) == true) then Xcond = true; }
if Xcond == false then
{
var1 = ma(c,5) ;
var2 = ma(c,20) ;
if crossup(var1,var2) Then buy("ss1") ;
if CrossDown(var1,var2) Then Sell("dd1") ;
}
## 가장 위
if MarketPosition == 1 and Value11<Value13 then{ ExitLong("목표40만원달성1",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts)); }
if MarketPosition == -1 then{ ExitShort("목표40만원달성2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); }
## 기타 청산
if MarketPosition==1 and IsEntryName("SS1") == true then{ SELL("SS1SWGOD1",AtLimit,EntryPrice+PriceScale*26); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWGOD2",AtLimit,EntryPrice-PriceScale*15); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWCUT2",Atstop ,EntryPrice+PriceScale*15); }
SetStopProfittarget(PriceScale*100,PointStop);
SetStopLoss(PriceScale*55,PointStop);
if sdate != sdate[1] Then SetStopEndofday(043000);
if bdate != bdate[1] Then SetStopEndofday(0);
* 항상 많은 도움에 고맙고 즐거운 추석 되십시요. 꾸벅~~~
답변 1
예스스탁 예스스탁 답변
2019-09-16 11:22:23
안녕하세요
예스스탁입니다.
1
var : TL(0);
if MarketPosition != 0 Then
{
if MarketPosition != MarketPosition[1] Then
TL = TL_New(sdate[1],stime[1],EntryPrice,sdate,stime,EntryPrice);
Else
TL_SetEnd(TL,sdate,stime,EntryPrice);
TL_SetSize(TL,3);
if PositionProfit(0) > 0 Then
{
TL_SetColor(TL,RED);
}
else if PositionProfit(0) > 0 Then
{
TL_SetColor(TL,BLUE);
}
Else
{
TL_SetColor(TL,BLACK);
}
}
2
if MarketPosition == 1 and Value11<Value13 then{ ExitLong("목표40만원달성1",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts)); }
조건에 value11 < value13이라는 조건이 있습니다.
불필요한 내용이면 지우셔야 합니다. 다른 내용에는 문제가 없습니다.
3연속 손실시 매매금지만 추가해 드립니다.
Input : 당일수익틱수(50);
var : N1(0),dayPl(0),당일수익(0),Xcond(false),loss(0);
var1 = ma(c,5) ;
var2 = ma(c,20) ;
당일수익 = PriceScale*당일수익틱수;
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
loss = 0;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if PositionProfit(1) < 0 Then
loss = loss+1;
Else
loss = 0;
if loss == 3 Then
Xcond = true;
if daypl >= PriceScale*40 Then
Xcond = true;
if (IsExitName("목표40만원달성1",1) == true or IsExitName("목표40만원달성2",1) == true) then
Xcond = true;
}
if Xcond == false then
{
if crossup(var1,var2) Then buy("ss1") ;
if CrossDown(var1,var2) Then Sell("dd1") ;
}
## 가장 위
if MarketPosition == 1 then{ ExitLong("목표40만원달성1",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts)); }
if MarketPosition == -1 then{ ExitShort("목표40만원달성2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); }
## 기타 청산
if MarketPosition==1 and IsEntryName("SS1") == true then{ SELL("SS1SWGOD1",AtLimit,EntryPrice+PriceScale*26); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWGOD2",AtLimit,EntryPrice-PriceScale*15); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWCUT2",Atstop ,EntryPrice+PriceScale*15); }
SetStopProfittarget(PriceScale*100,PointStop);
SetStopLoss(PriceScale*55,PointStop);
if sdate != sdate[1] Then SetStopEndofday(043000);
if bdate != bdate[1] Then SetStopEndofday(0);
즐거운 하루되세요
> 요타 님이 쓴 글입니다.
> 제목 : 청산 스위침 로직
> * 좋은 명절 되십시요.
* 많은 도움에 고맙 습니다.
<요청1> 매수가 대비 수익이면 빨강색(선두께3) 손해면 파랑색(선두께3) 보합이면 검은색 으로 수정 좀 부탁 드립니다.
var : TL(0);
if MarketPosition != 0 Then{if MarketPosition != MarketPosition[1] Then TL = TL_New(sdate[1],stime[1],EntryPrice,sdate,stime,EntryPrice); Else TL_SetEnd(TL,sdate,stime,EntryPrice); }
< 요청2 >
* 청산후 스위칭 로직이 "목표40만원달성1" 에 안걸리는데 로직 좀 수정 요청 드립니다.
<그림1> 첨부 파일(그림빨강색) 마지막 스위칭 매매는 안되야 하는데 매매가 됨니다.
스위칭 부분은 daypl >= PriceScale*40 이 부분이 적용 안 되는것 갔습니다.
즉 목표 달성 했는데 스위칭 로직은 매매가 됨니다.
목표 달성하면 매매가 안되야 하는데 스위칭은 매매가 됨니다.
아래 로직 좀 목표 달성 하면 스위칭도 매매 안 되게 수정 좀 부탁 드리겠습니다.
<그림2> 처럼 연속 손실 나는 경우도 있는데 연속손실 3회 이상이면 매매금지 부탁 드립니다.
## 아래 로직
Input : 당일수익틱수(50);
var : N1(0),dayPl(0),당일수익(0),Xcond(false);
당일수익 = PriceScale*당일수익틱수;
if Bdate != Bdate[1] Then{Xcond = false; N1 = NetProfit; }
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then{if daypl >= PriceScale*40 Then Xcond = true; if (IsExitName("목표40만원달성1",1) == true or IsExitName("목표40만원달성2",1) == true) then Xcond = true; }
if Xcond == false then
{
var1 = ma(c,5) ;
var2 = ma(c,20) ;
if crossup(var1,var2) Then buy("ss1") ;
if CrossDown(var1,var2) Then Sell("dd1") ;
}
## 가장 위
if MarketPosition == 1 and Value11<Value13 then{ ExitLong("목표40만원달성1",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts)); }
if MarketPosition == -1 then{ ExitShort("목표40만원달성2",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts)); }
## 기타 청산
if MarketPosition==1 and IsEntryName("SS1") == true then{ SELL("SS1SWGOD1",AtLimit,EntryPrice+PriceScale*26); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWGOD2",AtLimit,EntryPrice-PriceScale*15); }
if MarketPosition==-1 and IsEntryName("SS1SWGOD1") == true then{ ExitShort("SS1SWCUT2",Atstop ,EntryPrice+PriceScale*15); }
SetStopProfittarget(PriceScale*100,PointStop);
SetStopLoss(PriceScale*55,PointStop);
if sdate != sdate[1] Then SetStopEndofday(043000);
if bdate != bdate[1] Then SetStopEndofday(0);
* 항상 많은 도움에 고맙고 즐거운 추석 되십시요. 꾸벅~~~
다음글
이전글