等级: 免费版
- 注册:
- 2022-4-2
- 曾用名:
|
请问老师这段止损代码有什么问题,加入之后成交次数反而少了很多
////交易系统
//***********************************************
variable:movestoploss=0; {移动止盈总开关,1为开,0为关}
//开平仓
if 开多条件 and movestoploss=0 then begin
sellshort(holding<0,holding,thisclose);
buy(holding=0,手数,thisclose);
movestoploss:=1;
end
if 开空条件 and movestoploss=0 then begin
sell(holding>0,holding,thisclose);
buyshort(holding=0,手数,thisclose);
movestoploss:=1;
end
//***********************************************
//二级移动止损策略
stopline:=c*vv3/300;//初始止损幅度
enterhighprice:=hhv(h,enterbars);
enterlowprice:=llv(l,enterbars);
if enterbars>0 then begin
longprofit:=enterhighprice-avgenterprice; //多单最高利润
shortprofit:=avgenterprice-enterlowprice;//空单最高利润
end;
////////////多单跟踪止盈
if movestoploss=1 and holding>0 then begin
if longprofit>=1.5*stopline and longprofit<3*stopline then begin
保本卖出止损:sell(close-avgenterprice<=0,0,thisclose);
end;
if longprofit>=3*stopline then begin
回落止盈卖出:sell(close-avgenterprice<=longprofit,0,thisclose);
end;
end;
/////////////空单跟踪止损
//
if movestoploss=1 and holding<0 then BEGIN
if shortprofit>=1.5*stopline and stopline<3*stopline then begin
保本买入止损:sellshort(avgenterprice-close<=0,0,thisclose);
end;
//
if movestoploss=1 and holding<0 and shortprofit>=3*stopline then begin
回落止盈买入:sellshort(avgenterprice-close<=longprofit,0,thisclose);
end;
////***********************************************
|
|