老师好
在COND 条件下 统计下跌的次数,并且在第N次下跌的时候开仓10% 。N+1次的时候开仓20% 应该如何表述呢?
统计满足cond同时下跌的 次数?你这个下跌具体怎么定义的?此外就是统计是全部统计还是统计指定周期内的次数。
是 统计满足COND 条件下的下跌次数(收盘价低于 前K收盘价+3个最小波动价位 即可),直到COND 条件反向或者不满足COND条件了 截止。
VARIABLE:ct:=0;
N:=5;
cond:c>o;
cond2:c<ref(c,1)+3*MINDIFF;
if cond and cond2 then ct:=ct+1;//满足2个条件的时候 全局变量累加一次。
if not(cond and cond2) then ct:=0;//不满足时候重置为0
if ct=N then buy(holding=0,10%,market);
if ct=N+1 and holding>0 then buy(holding>0,20%,market);
参考上面例子。
[此贴子已经被作者于2020/3/26 14:28:58编辑过]