以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (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=160215) |
-- 作者:zengxing -- 发布时间:2017/12/7 9:52:22 -- 编写问题,求教 我想编写 一个完整交易日内(包括夜盘),多头止损后价格再次突破30周期高点继续买开,如再次止损后 当天不再交易。 一个完整交易日内(包括夜盘),空头止损后价格再次跌破20周期低点继续卖开,如再次止损后 当天不再交易。 但编写如下,为什么不能过滤呢?每天还开2次以上。 VARIABLE:mark=0; VARIABLE:mark2=0; atrx:=2; 手数:=1; hh:hhv(ref(h,1),30); ll:llv(ref(l,1),20); aa:BARSLAST(c>hh and holding=0)+1; bb:BARSLAST(c<ll and holding=0)+1; TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,14); zhis1:=ref(low,aa)>low and holding>0; zhis2:=ref(h,aa)<h and holding<0; if ref(low,aa)>low and holding>0 then sell(1,holding,LIMIT,c); if ref(h,aa)<h and holding<0 then SELLSHORT(1,holding,LIMIT,c); tq:=3; abb:=(time0-TIMETOT0(DYNAINFO(207))<=tq) or not(ISLASTBAR); zhiy1:(AVGENTERPRICE-c)>ATR*atrx and HOLDING<0; zhiy2:(C-AVGENTERPRICE)>ATR*atrx and HOLDING>0; 平空:SELLSHORT((AVGENTERPRICE-c)>ATR*atrx and HOLDING<0,手数,MARKET); 平多:SELL((C-AVGENTERPRICE)>ATR*atrx and HOLDING>0,手数,MARKET); //主要看这里一下部分 if ref(low,aa)>low and holding>0 then begin mark:=mark+1; end if c>=hh and holding=0 and mark<=2 then begin 开多:BUY(c>=hh and holding=0,手数,MARKET); end if time>=closetime(0) then mark:=0; if ref(h,aa)<h and holding<0 then begin mark2:=mark2+1; end if c<=ll and holding=0 and mark<=2 then begin 开空:BUYSHORT(c<=ll and holding=0,手数,MARKET); end if time>=closetime(0) then mark2:=0;
|
-- 作者:FireScript -- 发布时间:2017/12/7 10:16:55 -- 有个地方好像出错了,是mark<2不是mark<=2,mark2也同样改下 还有“if c<=ll and holding=0 and mark<=2 then ” 这一句应该是mark2而不是mark吧。 |
-- 作者:zengxing -- 发布时间:2017/12/7 16:55:07 -- VARIABLE:mark=0; VARIABLE:mark2=0; atrx:=2; 手数:=1; hh:hhv(ref(h,1),30); ll:llv(ref(l,1),20); aa:BARSLAST(c>hh and holding=0)+1; bb:BARSLAST(c<ll and holding=0)+1; TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,14); zhis1:=ref(low,aa)>low and holding>0; zhis2:=ref(h,aa)<h and holding<0; if ref(low,aa)>low and holding>0 then sell(1,holding,LIMIT,c); if ref(h,aa)<h and holding<0 then SELLSHORT(1,holding,LIMIT,c); tq:=3; abb:=(time0-TIMETOT0(DYNAINFO(207))<=tq) or not(ISLASTBAR); zhiy1:(AVGENTERPRICE-c)>ATR*atrx and HOLDING<0; zhiy2:(C-AVGENTERPRICE)>ATR*atrx and HOLDING>0; 平空:SELLSHORT((AVGENTERPRICE-c)>ATR*atrx and HOLDING<0,手数,MARKET); 平多:SELL((C-AVGENTERPRICE)>ATR*atrx and HOLDING>0,手数,MARKET); if ref(low,aa)>low and holding>0 then begin mark:=mark+1; end if c>=hh and holding=0 and mark<2 then begin 开多:BUY(c>=hh and holding=0,手数,MARKET); end if time>=closetime(0) then mark:=0; if ref(h,aa)<h and holding<0 then begin mark2:=mark2+1; end if c<=ll and holding=0 and mark2<2 then begin 开空:BUYSHORT(c<=ll and holding=0,手数,MARKET); end if time>=closetime(0) then mark2:=0; 改完了还是不对呀,一天之中,如果止损两次了,还是会开仓呀?求教,可以加载帮我看看嘛?谢谢老师
|