以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请问老师这个要怎么写  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=90798)

--  作者:qq代人发帖
--  发布时间:2016/1/28 16:38:23
--  请问老师这个要怎么写
 符合A条件时加仓2%,但总加仓量不超20%,同时如果亏损5%平仓最后二次加仓的仓位。这如何写,多谢。

--  作者:jinzhe
--  发布时间:2016/1/28 16:44:18
--  
处理中请稍等
--  作者:fxrock4
--  发布时间:2016/1/28 16:54:28
--  
好的。
--  作者:fly
--  发布时间:2016/1/28 17:08:35
--  

那只能计算,你要加仓的具体数量是多少了,计算方法跟手工计算是一样的。

 

用全部资金可开仓手数公式为:Intpart(Tasset/(Close*Multiplier*MarginRatio));//开仓手数---MarginRatio是保证金比率,请自行添加

 

并且用全局变量记录下加仓的数量,亏损5%的时候,平掉


--  作者:fxrock4
--  发布时间:2016/1/28 17:21:30
--  
当前资金200万。请帮写一个完整的加仓和平掉加仓的代码吧
--  作者:fxrock4
--  发布时间:2016/1/29 10:32:41
--  
靓妹帮写一个完整的嘛
--  作者:jinzhe
--  发布时间:2016/1/29 10:52:44
--  

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

 

能记录最后一次的开仓手数,最后两次的记录不了