예스스탁
예스스탁 답변
2021-09-24 14:57:15
안녕하세요
예스스탁입니다.
강제청산함수인 SetStopEndofday로 동작되게 작성해 드립니다.
설정창의 강제청산탭에서 청산시점이 조건만족즉시이면 해당시간 이후의 첫틱에 즉시 청산되고
봉완성시로 설정하면 해당시간이후 첫봉완성시 청산됩니다.
input : 범위봉수(400);
input : 매수진입이격(1.000);
input : 추가진입하락폭(0.985);
Input : 수익청산틱수(225);
Input : 손실청산틱수(150);
input : 일봉우상향일수(1);
var : Bcnt(0),Scnt(0),ST(0);
var : mav(0,Data2);
mav = Data2(ma(C,일봉우상향일수));
if bdate != Bdate[1] Then
{
Bcnt = 0;
Scnt = 0;
ST = sTime;
IF sdate == 20211215 Then
SetStopEndofday(233030);
Else
SetStopEndofday(0);
}
if MarketPosition == 1 and MarketPosition != MarketPosition[1] Then
Bcnt = Bcnt+1;
if MarketPosition == -1 and MarketPosition != MarketPosition[1] Then
Scnt = Scnt+1;
if MarketPosition <= 0 and Bcnt < 1 and mav > mav[1] Then
Buy("b",AtLimit,Lowest(L,범위봉수)*매수진입이격);
if MarketPosition == 1 then
{
if MaxEntries == 1 then # 85
buy("b2",AtLimit,LatestEntryPrice(0)*추가진입하락폭,1);
if MaxEntries == 2 then # 80
buy("b3",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.015),1);
if MaxEntries == 3 then # 75
buy("b4",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.03),1);
if MaxEntries == 4 then # 70
buy("b5",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.045),1);
if MaxEntries == 5 then # 65
buy("b6",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.06),1);
if MaxEntries == 6 then # 85
buy("b7",AtLimit,LatestEntryPrice(0)*추가진입하락폭-0.075,1);
if MaxEntries == 7 then # 80
buy("b8",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.09),1);
if MaxEntries == 8 then # 75
buy("b9",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.1),1);
if MaxEntries == 9 then # 70
buy("b10",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.11),1);
if MaxEntries == 10 then # 65
buy("b11",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.12),1);
if MaxEntries == 11 then # 80
buy("b12",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.13),1);
if MaxEntries == 12 then # 75
buy("b13",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.14),1);
if MaxEntries == 13 then # 70
buy("b14",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.15),1);
if MaxEntries == 14 then # 65
buy("b15",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.16),1);
}
SetStopProfitTarget(PriceScale*수익청산틱수,PointStop);
SetStopLoss(PriceScale*손실청산틱수,PointStop);
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 기존 수식에서 특정일에 전량 보유 수량 청산하는 수식을 추가하는 방법 알려주세요
> 만기일 몇시간전에 보유 수량 전량 청산하는 수식을 추가하고 싶어요~~
2021년 12월 15일 오후 11시 30분 30초에 보유 수량 전량 청산 하는 수식입니다.
궁금한점 : 만약 알려주신 수식으로 할경우 봉완성시 청산인가요? 아니면 해당 시간에 맞추어 청산인가요?
기존 수식 해외선물 나스닥 60분봉
input : 범위봉수(400);
input : 매수진입이격(1.000);
input : 추가진입하락폭(0.985);
Input : 수익청산틱수(225);
Input : 손실청산틱수(150);
input : 일봉우상향일수(1);
var : Bcnt(0),Scnt(0);
var : mav(0,Data2);
mav = Data2(ma(C,일봉우상향일수));
if bdate != Bdate[1] Then
{
Bcnt = 0;
Scnt = 0;
}
if MarketPosition == 1 and MarketPosition != MarketPosition[1] Then
Bcnt = Bcnt+1;
if MarketPosition == -1 and MarketPosition != MarketPosition[1] Then
Scnt = Scnt+1;
if MarketPosition <= 0 and Bcnt < 1 and mav > mav[1] Then
Buy("b",AtLimit,Lowest(L,범위봉수)*매수진입이격);
if MarketPosition == 1 then
{
if MaxEntries == 1 then # 85
buy("b2",AtLimit,LatestEntryPrice(0)*추가진입하락폭,1);
if MaxEntries == 2 then # 80
buy("b3",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.015),1);
if MaxEntries == 3 then # 75
buy("b4",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.03),1);
if MaxEntries == 4 then # 70
buy("b5",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.045),1);
if MaxEntries == 5 then # 65
buy("b6",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.06),1);
if MaxEntries == 6 then # 85
buy("b7",AtLimit,LatestEntryPrice(0)*추가진입하락폭-0.075,1);
if MaxEntries == 7 then # 80
buy("b8",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.09),1);
if MaxEntries == 8 then # 75
buy("b9",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.1),1);
if MaxEntries == 9 then # 70
buy("b10",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.11),1);
if MaxEntries == 10 then # 65
buy("b11",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.12),1);
if MaxEntries == 11 then # 80
buy("b12",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.13),1);
if MaxEntries == 12 then # 75
buy("b13",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.14),1);
if MaxEntries == 13 then # 70
buy("b14",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.15),1);
if MaxEntries == 14 then # 65
buy("b15",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.16),1);
}
SetStopProfitTarget(PriceScale*수익청산틱수,PointStop);
SetStopLoss(PriceScale*손실청산틱수,PointStop);