以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://www.weistock.com/bbs/list.asp?boardid=4)
----  修改模型  (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=163316)

--  作者:GUAN666
--  发布时间:2018/5/9 7:29:48
--  修改模型
老师,请问一下,模型设置下单默认1手,模型有时候会重复出现下单信号,软件并执行了下单,持仓单就变成2手了,到了出现平仓信号,只平仓一手,如何能做到出现平仓后全部平仓,麻烦帮我修改一下。

pkkd:ref(CROSS(ZIG(3,10),REF(ZIG(3,10),1)),1);   //平空开多条件
pdkk:ref(CROSS(REF(ZIG(3,10),1),ZIG(3,10)),1);  //平多开空条件


if pkkd then
  begin 
  sellshort(holding<0,holding,market);
  buy(holding=0,1,market);
  end
  
if pdkk then
  begin 
  sell(holding>0,holding,market);
  buyshort(holding=0,1,market);
  end
  
if holding>0 and c<ref(low,enterbars+1) then      //多头止损
  sell(1,holding,market);
  
if holding<0 and c>ref(high,enterbars+1) then     //空头止损
  sellshort(1,holding,market);



--  作者:FireScript
--  发布时间:2018/5/9 8:45:33
--  
 sell(holding>0,0,market);
第二个参数改成0,为0表示全部(实盘交易时为全部实际持仓)

--  作者:GUAN666
--  发布时间:2018/5/9 10:10:57
--  
修改后变成信号出现满仓下单了,是否可以下单还是一手,平仓就全部平仓
--  作者:FireScript
--  发布时间:2018/5/9 10:15:13
--  
 不是 你就只要改平仓语句里面的参数啊。开仓的保持原样即可。

--  作者:GUAN666
--  发布时间:2018/5/9 12:03:25
--  
可以了,谢谢老师