老师好,请教一下,如果想编写一个代码,要求:当天累计亏损金额或累计亏损点数(股指)一旦达到一定额度就将头寸全部平仓,此后都不开仓直至交易结束,应该怎么编写呢?谢谢
variable:nn=0;
variable:biaoji=0;//开仓语句中加上条件biaoji=0
if 平仓条件 and 持仓判断 and openprofit<0 then begin
平仓语句;
nn:=nn+openprofit;
end
if openprofit<=指定额度 then 平仓语句;//平仓函数中的手数写0
我写了这么多代码,就是为了统计一天总亏损
[此贴子已经被作者于2013-5-24 9:16:39编辑过]
variable:nn=0;
variable:biaoji=0;//开仓语句中加上条件biaoji=0
疑问:关于biaoji,是在所有开仓的代码中都加上“biaoji=0”的条件吗?
if 平仓条件 and 持仓判断 and openprofit<0 then begin
平仓语句;
nn:=nn+openprofit;
end
疑问:是指在平多和平空的代码中加上“ and 持仓判断 and openprofit<0”,以及nn:=nn+openprofit;对吗?
if openprofit<=指定额度 then 平仓语句;//平仓函数中的手数写0
疑问:如果要求当日亏损金额达到10000¥就退出交易不再开仓,要填写多少?是10000还是-10000?
老师好,还有个疑问:
如果是这样的代码,如何在开仓语句buy和平仓语句sellshort中添加上述的代码?
if longcond then begin
sellshort(holding < 0 , 0,limitr,close),ignorecheckprice,orderqueue;
buy(holding = 0, ss,limitr,close),ignorecheckprice,orderqueue;
end
这个不简单么,分开写,需要全局变量的就加进去,不要的就不加