예스스탁
예스스탁 답변
2021-06-07 10:28:36
안녕하세요
예스스탁입니다.
1
설정창 강제청산탭에 신호발생시점은 해당화면 상단의 강제청산에 해당 되는 설정입니다.
exitlong,exitshort은 일반청산함수로 해당 설정과 관계가 없고
수식안에서 atstop이나 atlimit으로 봉미완성시에 신호가 발생하게 작성합니다.
해당 수식은 당일누적손익에 따라 청산하는 내용으로
일반 강제청산함수로는 구현이 되지 않아 일반청산함수로 구현되어야 합니다.
2
해당 신호가 진입봉에서 발생하지 않고
그 다음봉에서 봉미완성시에 발생한 이유는 if문은 봉완성 기준이기 때문입니다.
매도진입이 발생하고 진입봉 하나가 완성되어야 MarketPosition 상태가 -1로 인지가 되고
entryprice또한 한개봉이 완성되어야 그 진입가가 변경이 됩니다
3
진입봉에서 동시에 발생하게 하기 위해서는 수식 코딩상 별도의 처리를 해주셔야 합니다.
진입에서 사용한 신호타입에 따라 값을 달리 지정해서 진입봉에서도 신호가 발생하게 해주셔야 합니다.
아래 내용 참고하시기 바랍니다.
각 진입의 신호타입에 따라 아직 entryprice가 인식되기 전에는 지정한 값을 사용하고
포지션인식후에는 진입가를 이용해서 당일수익/당일손실이 진입봉에서도
동작하게 하는 내용입니다.
var : BuyPrice(0),SellPrice(0);
if Xcond == false and Tcond == true then
{
#매수진입이 OnClose타입일때
if MarketPosition <= 0 and 매수진입조건 Then
{
Buy("b",OnClose);
BuyPrice = C;
}
#매수진입이 atmarket타입일때
if MarketPosition <= 0 and 매수진입조건 Then
{
Buy("b",AtMarket);
BuyPrice = NextBarOpen;
}
#매수진입이 atstop타입일때
if MarketPosition <= 0 and 매수진입조건 Then
{
Buy("b",AtStop,가격조건);
BuyPrice = max(NextBarOpen,가격조건);
}
#매수진입이 atlimit타입일때
if MarketPosition <= 0 and 매수진입조건 Then
{
Buy("b",AtLimit,가격조건);
BuyPrice = min(NextBarOpen,가격조건);
}
#매도진입이 OnClose타입일때
if MarketPosition >= 0 and 매도진입조건 Then
{
Sell("s",OnClose);
SellPrice = C;
}
#매도진입이 atmarket타입일때
if MarketPosition >= 0 and 매도진입조건 Then
{
Sell("s",AtMarket);
SellPrice = NextBarOpen;
}
#매도진입이 atstop타입일때
if MarketPosition >= 0 and 매도진입조건 Then
{
Sell("s",AtStop,가격조건);
SellPrice = min(NextBarOpen,가격조건);
}
#매도진입이 atlimit타입일때
if MarketPosition >= 0 and 매도진입조건 Then
{
Sell("s",AtLimit,가격조건);
SellPrice = max(NextBarOpen,가격조건);
}
}
if MarketPosition == 1 then
BuyPrice = EntryPrice;
Else
BuyPrice = C;
if MarketPosition == -1 then
SellPrice = EntryPrice;
Else
SellPrice = C;
if BuyPrice > 0 Then
{
ExitLong("dbp",atlimit,BuyPrice+((당일수익-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일손실+daypl)/CurrentContracts));
}
if SellPrice > 0 Then
{
ExitShort("dsp",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts));
}
즐거운 하루되세요
> 오케마컴 님이 쓴 글입니다.
> 제목 : 같은봉에서 청산이 안됩니다
> if sdate != sDate[1] Then
SetStopEndofday(Endtime);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
SetStopEndofday(0);
Tcond = true;
}
당일수익 = PriceScale*당일수익틱수;
당일손실 = PriceScale*당일손실틱수;
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;
}
if Xcond == false and Tcond == true then
{
진입식
}
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));
}
이와같이 수식을 했는데 당일 수익청산시점인 dsp 신호가 다음봉에서 나오네요
분명 진입봉에서도 가격은 만족했거든요
진입봉이라도 가격이 만족하면 즉시 신호가 나오게 하고싶습니다
시스템매매설정에서 강제청산에서 조건만족즉시는 체크 했지만 위 그림과 같은 경우는 강제청산 조건에는 부합하지 안지만 위 수식의 당일 수익에는 만족하는 가격입니다