以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4) ---- 检测新加条件 后台程序 (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=167102) |
-- 作者:f三年 -- 发布时间:2018/12/14 16:12:03 -- 检测新加条件 后台程序 在下面程序中新加了一个条件: 开新仓时,RSV值在10%~90%。无论买多,买空,开仓手数都加倍 。请教老师帮忙看下编程的是否正确。后台程序的。 TR=Max(H-L,H-PDC,PDC-L) 其中: TR=真实波幅 H=当日最高价 L=当日最低价 PDC=前一日收盘价 N(即ATR)的计算公式如下(其实就): 前面20天的TR值平均 绝对波动幅度=N*合约每一点所代表的价值 头寸规模单位n=账户的1%/绝对波动幅度 开仓时机:当价格突破20天新高的时候开n手做多,当价格回调3ATR平仓。 当价格突破20日新低的时候做空,当价格回调3ATR平仓 止损为1N PDC:=REF(C,1); TR1:=MAX(H-L,MAX(H-PDC,PDC-L)); ATR:=MA(TR1,20); 绝对波幅:=ATR*DYNAINFO(209); rdp:=ln(c/ref(c,1)); vr:=std(rdp,60)*100; vrma:=ma(vr,120); N:=tASSET*0.01/绝对波幅; h20:=ref(hhv(h,20),1); l20:=ref(llv(l,20),1); t1:=c>h20; t2:=c<l20; n1:=ref(ATR,BARSLAST(t1 and ref(t1,1)=0)); n2:=ref(ATR,BARSLAST(t2 and ref(t2,1)=0)); c1:=ref(c,BARSLAST(t1 and ref(t1,1)=0)); c2:=ref(c,BARSLAST(t2 and ref(t2,1)=0)); kd:cross(c,h20); pd:c<(c1-3*n1); kk:=cross(l20,c); pk:=c>(c2+3*n2); if TBUYHOLDING(1)>0 and pd then tsell(pd,if(range(vrma,0.1,0.9),n*2,n),mkt); if tsellholding(1)>0 and pk then tsellshort(pk,if(range(vrma,0.1,0.9),n*2,n),mkt); if tbuyholding(1)=0 and kd then tbuy(kd,if(range(vrma,0.1,0.9),n*2,n),mkt); if tsellholding(1)=0 and kk then tbuyshort(kk,if(range(vrma,0.1,0.9),n*2,n),mkt); if tholding>0 and c<DYNAINFO(211)-n1 then tsell(pd,if(range(vrma,0.1,0.9),n*2,n),mkt); if tholding<0 and c>DYNAINFO(211)+n2 then tsellshort(pk,if(range(vrma,0.1,0.9),n*2,n),mkt);{止损块在有持仓时运行} |
-- 作者:FireScript -- 发布时间:2018/12/14 16:19:04 -- 可以 不过 你平仓如果是全平 没必要这样写吧。直接把持仓函数写上去也就行了。 if TBUYHOLDING(1)>0 and pd then tsell(pd,if(range(vrma,0.1,0.9),n*2,n),mkt); if tsellholding(1)>0 and pk then tsellshort(pk,if(range(vrma,0.1,0.9),n*2,n),mkt); |