예스스탁
예스스탁 답변
2020-09-09 13:47:51
안녕하세요
예스스탁입니다.
현재 수식이 동일 방향진입으로 추가진입되는 것을 제어하는 것으로 작성이 되어 있습니다.
동일포지션 거래가 3회이상 반복되지 않게 수정해 드립니다.
Input : 당일수익(3),당일손실(3);
Var : N1(0),dayPl(0),Xcond(false);
Vars : ma5(0), ma20(0);
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
}
ma5 = ma(C, 5);
ma20 = ma(C, 20);
Condition1 = MarketPosition == 0 and MarketPosition(1) == 1 and MarketPosition(2) == 1 and MarketPosition(3) == 1;
Condition2 = MarketPosition == 0 and MarketPosition(1) == -1 and MarketPosition(2) == -1 and MarketPosition(3) == -1;
If (stime >= 090000 && stime <= 110000) and Xcond == False then
{
IF MarketPosition() <= 0 and Condition1 == False Then
{
IF ma20 > ma20[1] && C < ma5 then
Buy("매수", AtLimit, O+PriceScale*1);
}
IF MarketPosition() >= 0 and Condition2 == False Then
{
IF ma20 < ma20[1] && C > ma5 then
Sell("매도", AtLimit, O-PriceScale*1);
}
}
if MarketPosition == 1 then{
ExitLong("dbp",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("dsp",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts));
}
SetStopLoss(PriceScale*10, PointStop);
SetStopProfittarget(PriceScale*10, PointStop);
즐거운 하루되세요
> 즐거운기다림 님이 쓴 글입니다.
> 제목 : 진입횟수 제한에 관하여
> 안녕하세요 ^^
아래 69102 게시물을 참조하여 진입조건을 만족할때 같은 방향으로 3회까지만 허용하는
수식을 적용해 봤습니다.
그런데 그림과 같이 계속 진입이 되는데 어디가 잘못된 것인지요.
수식은 다음과 같습니다.
Vars : ma5(0), ma20(0);
ma5 = ma(C, 5);
ma20 = ma(C, 20);
If (stime >= 090000 && stime <= 110000) then
{
# 매수 진입/청산 조건
IF MarketPosition() <= 0 or (MarketPosition() == 1 && MaxEntries < 3) Then
{
IF ma20 > ma20[1] && C < ma5 then
Buy("매수", AtLimit, O+PriceScale*1);
}
# 매도 진입/청산 조건
IF MarketPosition() >= 0 or (MarketPosition() == -1 && MaxEntries < 3) Then
{
IF ma20 < ma20[1] && C > ma5 then
Sell("매도", AtLimit, O-PriceScale*1);
}
}
SetStopLoss(PriceScale*10, PointStop);
SetStopProfittarget(PriceScale*10, PointStop);
도움 부탁드립니다.
여기에 더하여 하루 수익이나 손실이 3Pt 이면 더이상 매매하지 않도록 하는 수식도
부탁드립니다.
감사합니다.