等级: 免费版
- 注册:
- 2022-9-28
- 曾用名:
|
发表于 2022-11-25 09:27
来自手机
|
显示全部楼层
input:m1(4,1,100,10),m2(8,1,100,10),m3(16,1,100,10),m4(32,1,100,10); bbi:(ma(close,m1)+ma(close,m2)+ma(close,m3)+ma(close,m4))/4; input:ss(5,1,100,1);//开仓手数;input:m1(4,1,100,10),m2(8,1,100,10),m3(16,1,100,10),m4(32,1,100,10); bbi:(ma(close,m1)+ma(close,m2)+ma(close,m3)+ma(close,m4))/4; input:ss(5,1,100,1);//开仓手数; cz:abs(bbi-ref(bbi,1)); 平空开多:bbi>ref(bbi,1) and c>bbi andcz>ref(cz,1); 平多开空:bbi<ref(bbi,1) and c<bbi andcz>ref(cz,1); variable:maxprofit=0;//有仓位时最大获利幅度 //普通开仓 if 平空开多 then begin sellshort(holding<0,0,marketr); buy(holding=0,1,marketr); maxprofit:=0; end if 平多开空 then begin sell(holding>0,0,marketr); buyshort(holding=0,1,marketr); 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 if holding < 0 and enterbars > 0 then begin win:=(enterprice-c)/enterprice*100; //记录最大盈利 if win > maxprofit then maxprofit:=win; win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度 end //出现浮动亏损比如2%平仓 止损:sell(win < -2,0,marketr); //出现最高盈利后,回落到盈利的60%平仓出场 止赢:sell(win2 >= 60 and openprofit > 0, 0,marketr); |
|