1.控制实际账号资金的留存的控制有且只能是通过后台程序化实现,图表模型所有的资金,费率,仓位都是理论持仓,和实际账户不是一回事。如果你对图表模型的情况不太了解可以参考下我们的文档:
https://www.weistock.com/docs/HE ... %E4%BA%A4%E6%98%93/
如果需要做一些实际账户的自己控制,大部分情况下我们是推荐使用后台的。
2.
参考下面的范例,开仓条件换成你自己的就行了。
[PEL] 复制代码
input:n(3,1,100,1);
input:m(15,1,100,1);
variable:lk:=0;//连亏次数
//若连续亏损了n笔,暂停下单m周期。
开多条件:cross(c,ma(c,5));
开空条件:cross(ma(c,4),c);
平多条件:h>ref(hhv(h,3),1);
平空条件:l<ref(llv(l,3),1);
if 平空条件 and holding<0 then
begin
sellshort(1,holding,market);
if numprofit(1)>0 then lk:=0;
if numprofit(1)<0 then lk:=lk+1;
end
开多:buy(开多条件 and lk<n and holding=0 ,1,market);
if 平多条件 and holding>0 then
begin
sell(1,holding,market);
if numprofit(1)>0 then lk:=0;
if numprofit(1)<0 then lk:=lk+1;
end
开空:buyshort(开空条件 and lk<n and holding=0 ,1,market);
//m周期后重置连亏标记
if all(lk=3,m) then lk:=0;
连亏次数:lk;
|