那只能计算,你要加仓的具体数量是多少了,计算方法跟手工计算是一样的。
用全部资金可开仓手数公式为:Intpart(Tasset/(Close*Multiplier*MarginRatio));//开仓手数---MarginRatio是保证金比率,请自行添加
并且用全局变量记录下加仓的数量,亏损5%的时候,平掉
if todaybar=1 then extgbdataset('zj',taccount(6));
if 条件a and taccount(3)>=0.8*taccount(6) and time<>extgbdata('tt') then begin
extgbdataset('ss',taccount(3)*0.02/close/multiplier/taccount(41));
tbuy(1,taccount(3)*0.02/close/multiplier/taccount(41),mkt);
extgbdataset('tt',time);
end
if taccount(6)<=extgbdata('zj')*0.95 and time<>extgbdata('tt1') then begin
tsell(1,extgbdata('ss'),mkt);
extgbdata('tt1',time);
end
能记录最后一次的开仓手数,最后两次的记录不了