
等级: 标准版
- 注册:
- 2022-11-14
- 曾用名:
|
标红的地方是一样的,是不是错了
INPUT:SS(1,1,100,1);
手数:=SS;
{交易条件}
开多条件:=A; //开多条件
平多条件:=B ; //平多条件
开空条件:=C; //开空条件
平空条件:=D; //平空条件
variable:maxprofit=0;//有仓位时最大获利幅度
平空:SELLSHORT(平空条件 ,手数,THISCLOSE); //平空信号
if 开多条件 and holding=0 then
begin
开多:BUY(开多条件 AND HOLDING=0,手数,THISCLOSE); //开多信号
maxprofit:=0;
end
平多:SELL(平多条件 ,手数,THISCLOSE); //平多信号
if 开空条件 and holding=0 then
begin
开空:BUYSHORT(开空条件 AND HOLDING=0,手数,THISCLOSE); //开空信号
maxprofit:=0;
end
//判断当前持仓状态下的多头最大盈利
win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win>maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//出现浮动亏损比如2%平仓
止损:SELL(win < -2,0,limit,c);
//出现最高盈利后,回落到盈利的60%平仓出场
多止赢:SELL(win2 >= 60 and openprofit > 0, 0,limit,c);
//判断当前持仓状态下的空头最大盈利
win1:=0;
win3:=0;
if holding < 0 and enterbars > 0 then
begin
win1:=(C-enterprice)/enterprice*100; //记录最大盈利
if win1 > maxprofit then
maxprofit:=win1;
win3:=(maxprofit-win1)/maxprofit*100; //最大盈利后的回调幅度
end
//出现浮动亏损比如2%平仓
空止损:SELLSHORT(win1 < -2,0,limit,c);
//出现最高盈利后,回落到盈利的60%平仓出场
空止赢:SELLSHORT(win3 >= 60 and openprofit > 0, 0,limit,c);
持仓:holding,COLORRED,linethick0;
资产:asset,noaxis,linethick0;
可用现金:cash(0),linethick0; |
|