예스스탁
예스스탁 답변
2023-01-11 14:09:25
안녕하세요
예스스탁입니다.
트레일링스탑 : 포지션 진입이후 수익이 10point 미만으로 수익 발생후
포지션 평가손실이 -30point 이상이면 중간청산
위 내용은 SetStopTrailing함수로는 가능하지 않습니다.
일반청산함수로 구현하셔야 합니다.
Inputs : Period(10);
Input : 당일손실(50);
input : StartTime(140000),EndTime(60000);
Var : cnt1(0),dayPl(0),Xcond(false);
Var : line10(0) ;
##### 변수셋팅 #####
line10 = avg(C,Period);
### 해외선물 새벽시간 당일청산 ###
var : Tcond(false);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
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
{
Tcond = true;
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
### 일매매손익에 따른 손절 ###
if Bdate != Bdate[1] Then
{
Xcond = false;
cnt1 = NetProfit;
}
daypl = NetProfit-cnt1;
if TotalTrades > TotalTrades[1] then
{
if daypl <= -당일손실 Then
Xcond = true;
if IsExitName("dbl",1) == true or
IsExitName("dsl",1) == true then
Xcond = true;
}
##### 매매로직 #####
if Tcond == true Then
{
#----------------------
# 매수
#----------------------
If marketposition <= 0 and crossup(C,line10) then begin
Buy("B");
End;
#----------------------
# 매도
#----------------------
If marketposition >= 0 and crossup(c,line10) then begin #
Sell("S");
End;
if MarketPosition == 1 Then
{
if highest(H,BarsSinceEntry) < EntryPrice+10 Then
ExitLong("bx",AtStop,highest(H,BarsSinceEntry)-30);
}
if MarketPosition == -1 Then
{
if lowest(L,BarsSinceEntry) > EntryPrice-10 Then
ExitShort("sx",AtStop,lowest(L,BarsSinceEntry)+30);
}
} //매매시간 종료
##### 스탑로스 #####
SetStopLoss(51,PointStop);
SetStopTrailing(10,51,PointStop);
즐거운 하루되세요
> 양치기 님이 쓴 글입니다.
> 제목 : 시스템식 부탁드립니다.
> 항상 도움 주셔서 감사합니다.
종목 : 마이크로 나스닥
차트 : 5분봉
매매시간 : 오후 2시[14시]부터 다음날 새벽 6시까지
손실제한 : 하루 매매결과 총 손실이 50point 이상이면 매매중지
트레일링스탑 : 포지션 진입이후 수익이 10point 미만으로 수익 발생후
포지션 평가손실이 -30point 이상이면 중간청산
아래와 같이 했는데 잘 안됩니다.
수식 점검 부탁드립니다.
Inputs : Period(10);
Input : 당일손실틱수(200); <- 틱이 아닌 50 포인트로 수정 요망
Var : cnt1(0),dayPl(0),당일손실(0),Xcond(false);
Var : line10(0) ;
##### 변수셋팅 #####
line10 = avg(C,Period);
### 해외선물 새벽시간 당일청산 ###
if sDate != sDate[1] Then
SetStopEndofday(060000);
if Bdate != Bdate[1] Then
SetStopEndofday(0);
### 일매매손익에 따른 손절 ###
당일손실 = PriceScale*당일손실틱수;
if Bdate != Bdate[1] Then
{
Xcond = false;
cnt1 = NetProfit;
}
daypl = NetProfit-cnt1;
if TotalTrades > TotalTrades[1] then
{
if daypl <= -당일손실 Then
Xcond = true;
if IsExitName("dbl",1) == true or
IsExitName("dsl",1) == true then
Xcond = true;
}
##### 매매로직 #####
if (sTime >= 140000 and sTime <=2400000 or stime >= 000000 and sTime <= 070000) Then {
#----------------------
# 매수
#----------------------
If marketposition <= 0 and or crossup(C,line10) then begin
Buy("B");
End;
#----------------------
# 매도
#----------------------
If marketposition >= 0 and crossup(c,line10) then begin #
Sell("S");
End;
} //매매시간 종료
##### 스탑로스 #####
SetStopLoss(51,PointStop);
SetStopTrailing(10,51,PointStop);
SetStopTrailing(30,1,PointStop); // 손익이 10 이하로 발생후 -30point 손실시 청산
시스템식 부탁드립니다.
감사합니다.