예스스탁
예스스탁 답변
2021-07-20 09:11:49
안녕하세요
예스스탁입니다.
input : position1(1),ntime1(100000),vol1(1);
input : position2(1),ntime2(110000),vol2(1);
input : xtime(55800);
input : 최소수익틱수(50),수익감소틱수(20);
var : ST(0);
if Bdate != Bdate[1] Then
{
ST = sTime;
}
if ST > 0 then
{
if (sdate != sdate[1] and stime >= ntime1) or
(sdate == sdate[1] and stime >= ntime1 and stime[1] < ntime1) Then
{
if position1 == 1 Then
Buy("매수-1",OnClose,DEf,vol1);
if position1 == -1 Then
Sell("매도-1",OnClose,DEf,vol1);
}
if (sdate != sdate[1] and stime >= ntime2) or
(sdate == sdate[1] and stime >= ntime2 and stime[1] < ntime2) Then
{
if position2 == 1 Then
Buy("매수-2",OnClose,DEf,vol2);
if position2 == -1 Then
Sell("매도-2",OnClose,DEf,vol2);
}
if MarketPosition == 1 and Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소수익틱수 Then
ExitLong("bx",AtStop,Highest(H,BarsSinceEntry)-PriceScale*수익감소틱수);
if MarketPosition == -1 and lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소수익틱수 Then
ExitShort("sx",AtStop,lowest(L,BarsSinceEntry)+PriceScale*수익감소틱수);
}
IF Xtime > ST Then
SetStopEndofday(Xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Xtime);
}
if (sdate != sdate[1] and stime >= ST) or
(sdate == sdate[1] and stime >= ST and stime[1] < ST) Then
{
IF Xtime <= ST Then
{
SetStopEndofday(0);
}
}
즐거운 하루되세요
> 스카스카 님이 쓴 글입니다.
> 제목 : 트레일링스탑 추가요청...
> input : position1(1),ntime1(100000),vol1(1);
input : position2(1),ntime2(110000),vol2(1);
input : xtime(55800);
var : ST(0);
if Bdate != Bdate[1] Then
{
ST = sTime;
}
if ST > 0 then
{
if (sdate != sdate[1] and stime >= ntime1) or
(sdate == sdate[1] and stime >= ntime1 and stime[1] < ntime1) Then
{
if position1 == 1 Then
Buy("매수-1",OnClose,DEf,vol1);
if position1 == -1 Then
Sell("매도-1",OnClose,DEf,vol1);
}
if (sdate != sdate[1] and stime >= ntime2) or
(sdate == sdate[1] and stime >= ntime2 and stime[1] < ntime2) Then
{
if position2 == 1 Then
Buy("매수-2",OnClose,DEf,vol2);
if position2 == -1 Then
Sell("매도-2",OnClose,DEf,vol2);
}
}
IF Xtime > ST Then
SetStopEndofday(Xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Xtime);
}
if (sdate != sdate[1] and stime >= ST) or
(sdate == sdate[1] and stime >= ST and stime[1] < ST) Then
{
IF Xtime <= ST Then
{
SetStopEndofday(0);
}
}
위 식에서 트레일링 스탑을 추가하고 싶습니다.
변수로 지정 가능하게 해주세요~ ^^
만약 안된다면 목표가 도달시 -20틱 으로 부탁드립니다.~~
매번 감사하드립니다.
감사합니다. ^^ (__)
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 트레일링스탑 추가요청...
> 안녕하세요
예스스탁입니다.
input : position1(1),ntime1(100000),vol1(1);
input : position2(1),ntime2(110000),vol2(1);
input : xtime(55800);
input : 최소수익틱수(50),수익감소틱수(20);
var : ST(0);
if Bdate != Bdate[1] Then
{
ST = sTime;
}
if ST > 0 then
{
if (sdate != sdate[1] and stime >= ntime1) or
(sdate == sdate[1] and stime >= ntime1 and stime[1] < ntime1) Then
{
if position1 == 1 Then
Buy("매수-1",OnClose,DEf,vol1);
if position1 == -1 Then
Sell("매도-1",OnClose,DEf,vol1);
}
if (sdate != sdate[1] and stime >= ntime2) or
(sdate == sdate[1] and stime >= ntime2 and stime[1] < ntime2) Then
{
if position2 == 1 Then
Buy("매수-2",OnClose,DEf,vol2);
if position2 == -1 Then
Sell("매도-2",OnClose,DEf,vol2);
}
if MarketPosition == 1 and Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소수익틱수 Then
ExitLong("bx",AtStop,Highest(H,BarsSinceEntry)-PriceScale*수익감소틱수);
if MarketPosition == -1 and lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소수익틱수 Then
ExitShort("sx",AtStop,lowest(L,BarsSinceEntry)+PriceScale*수익감소틱수);
}
IF Xtime > ST Then
SetStopEndofday(Xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Xtime);
}
if (sdate != sdate[1] and stime >= ST) or
(sdate == sdate[1] and stime >= ST and stime[1] < ST) Then
{
IF Xtime <= ST Then
{
SetStopEndofday(0);
}
}
즐거운 하루되세요
> 스카스카 님이 쓴 글입니다.
> 제목 : 트레일링스탑 추가요청...
> input : position1(1),ntime1(100000),vol1(1);
input : position2(1),ntime2(110000),vol2(1);
input : xtime(55800);
var : ST(0);
if Bdate != Bdate[1] Then
{
ST = sTime;
}
if ST > 0 then
{
if (sdate != sdate[1] and stime >= ntime1) or
(sdate == sdate[1] and stime >= ntime1 and stime[1] < ntime1) Then
{
if position1 == 1 Then
Buy("매수-1",OnClose,DEf,vol1);
if position1 == -1 Then
Sell("매도-1",OnClose,DEf,vol1);
}
if (sdate != sdate[1] and stime >= ntime2) or
(sdate == sdate[1] and stime >= ntime2 and stime[1] < ntime2) Then
{
if position2 == 1 Then
Buy("매수-2",OnClose,DEf,vol2);
if position2 == -1 Then
Sell("매도-2",OnClose,DEf,vol2);
}
}
IF Xtime > ST Then
SetStopEndofday(Xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Xtime);
}
if (sdate != sdate[1] and stime >= ST) or
(sdate == sdate[1] and stime >= ST and stime[1] < ST) Then
{
IF Xtime <= ST Then
{
SetStopEndofday(0);
}
}
위 식에서 트레일링 스탑을 추가하고 싶습니다.
변수로 지정 가능하게 해주세요~ ^^
만약 안된다면 목표가 도달시 -20틱 으로 부탁드립니다.~~
매번 감사하드립니다.