等级: 免费版
- 注册:
- 2022-9-28
- 曾用名:
|
发表于 2022-11-22 14:20
来自手机
|
显示全部楼层
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);//开仓手数; if BBI>REF(BBI,1) and C>BBI then begin; sellshort(1,holding,market); buy(holding=0,ss,market); END; if BBI<REF(BBI,1) and C<BBI then begin; sell(1,holding,market); buyshort(holding=0,ss,market); END; variable:maxprofit=0;//有仓位时最大获利幅度 //普通开仓; IF BBI>REF(BBI,1) and C>BBI then begin bUY(1,1,limit,c) maxprofit:=0 END IF BBI<REF(BBI,1) and C<BBI begin; THEN BEGIN BUYSHORT(1,1,limit,c); maxprofit:=0; END //普通平仓 SELL(sellshort(1,holding,market); buy(holding=0,ss,market);0,market); SELLSHORT(sell(1,holding,market); buyshort(holding=0,ss,market),0,market); //判断当前持仓状态下的最大盈利 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,limit,c); //出现最高盈利后,回落到盈利的60%平仓出场 止赢:SELL(win2 >= 60 and openprofit > 0, 0,limit,c); |
|