以文本方式查看主题

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

--  作者:image
--  发布时间:2014/12/11 17:08:49
--  连亏次数计算
我想通过计算连续亏损次数进行加减仓:

问题1、其中连续亏损3次不知如何编写?(连续亏损3次,接下来有一次盈利后,后面的连续亏损次数重新计算)

问题2、连续亏损3次后,我想把仓位砍掉一半(时间上持续X条K线),另外一半继续根据之前的判断进行操作。

[此贴子已经被作者于2014/12/11 17:09:01编辑过]

--  作者:jinzhe
--  发布时间:2014/12/11 17:15:32
--  

variable:n=0;

if holding>0 and 平多条件 then begin

    sell.......;

    if numprofit(1)>0 then n:=0;

    if numprofit(1)<0 then n:=n+1;

end

 

if holding<0 and 平空条件 then begin

    sellshort.......;

    if numprofit(1)>0 then n:=0;

    if numprofit(1)<0 then n:=n+1;

end

 

if n=3 and holding>0 then sell(1,holding/2,market);

 

if n=3 and holding<0 then sellshort(1,holding/2,market);