以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 老师 帮我写个模型 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=65549) |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:09:37 -- 老师 帮我写个模型 dd:=if(date>1130301,1,1); trr:=max(max((high-low),abs((ref(close,1)-high))),abs((ref(close,1)-low)))*dd; hh:=c+trr*dd*倍数/10,colorgray; ll:=c-trr*dd*倍数/10,colorgray; llxx:=ref(hhv(ll,5),1)*dd; hlxx:=ref(llv(hh,5),1)*dd; chxx:=cross(c,hlxx*1.000001); clxx:=(0-cross(llxx*0.999999,c)); tfxx:=if(chxx,chxx,if(cross(llxx*0.999999,c),clxx,0)); udxx:=ref(tfxx,barslast(tfxx)); llxxx:=hhv(ll,barslast(udxx<0)); hlxxx:=llv(hh,barslast(udxx>0)); chxxx:=cross(c,hlxxx*1.000001); clxxx:=(0-cross(llxxx*0.999999,c)); tfxxx:=if(chxxx,chxxx,if(cross(llxxx*0.999999,c),clxxx,0)); udxxx:=ref(tfxxx,barslast(tfxxx)); llxxxx:=min(hhv(ll,barslast(udxxx<0)),llxxx); hlxxxx:=max(llv(hh,barslast(udxxx>0)),hlxxx); chxxxx:=cross(c,hlxxxx*1.000001); clxxxx:=(0-cross(llxxxx*0.999999,c)); tfxxxx:=if(chxxxx,chxxxx,if(cross(llxxxx*0.999999,c),clxxxx,0)); udxxxx:=ref(tfxxxx,barslast(tfxxxx)); llxxxxx:=min(hhv(ll,barslast(udxxxx<0)),llxxxx); hlxxxxx:=max(llv(hh,barslast(udxxxx>0)),hlxxxx); chxxxxx:=cross(c,hlxxxxx*1.000001); clxxxxx:=(0-cross(llxxxxx*0.999999,c)); tfxxxxx:=if(chxxxxx,chxxxxx,if(cross(llxxxxx*0.999999,c),clxxxxx,0)); udxxxxx:=ref(tfxxxxx,barslast(tfxxxxx)); llxxxxxx:=min(hhv(ll,barslast(udxxxxx<0)),llxxxxx); hlxxxxxx:=max(llv(hh,barslast(udxxxxx>0)),hlxxxxx); bbx:=llxxxxxx*0.999999; ssx:=hlxxxxxx*1.000001; b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0))*dd; b2x:=ref(b1x,barslast(b1x))*dd; w:=if(b2x=1,bbx,if(b2x=-1,ssx,c))*dd,coloryellow; bbx:=ema(llv(l,3),5)*0.999999*dd; ssx:=ema(hhv(h,3),5)*1.000001*dd; b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0)); b2x:=ref(b1x,barslast(b1x)); 多空转折线:=if(b2x=1,bbx,if(b2x=-1,ssx,0))*dd; w,coloryellow,linethick2; ll:=bbx; hl:=ssx; ch:=cross(c,hl); cl:=(0-cross(ll,c)); tf:=if(ch,ch,if(cross(ll,c),cl,0)); ud:=ref(tf,barslast(tf)); lll:=ema(llv(l,3),5)*dd; hhh:=ema(hhv(h,3),5)*dd; kkk:=(barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25)))-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)))*dd,nodraw; stickline(kkk>0,o,c,6,0),colorred; stickline(kkk>0,h,l,0,0),colorred; stickline(kkk>0 and c>o,o,c,6,1),colorred; stickline(kkk<0,o,c,6,0),color00aa00; stickline(kkk<0,h,l,0,0),color00aa00; stickline(kkk<0 and c>o,o,c,6,1),color00aa00; partline(c>w and not(cross(c,w)),w),colormagenta,linethick2; partline(c<w and not(cross(w,c)),w),colorcyan,linethick2; drawicon(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001),bbx,4); drawicon(cross(ref(llv(l,25),1)*0.99999,llv(c,25)),ssx,5); drawtext(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001),bbx*0.9995,\'开多\'),colorred; drawtext(cross(ref(llv(l,25),1)*0.99999,llv(c,25)),ssx*1.0005,\'开空\'),colorgreen; kd:barslast(((cross(w,c) and c>多空转折线) or (cross(多空转折线,c) and c>w) or (cross(多空转折线,c) and cross(w,c))) and kkk>0)-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)),nodraw; kk:barslast(((cross(c,w) and c<多空转折线) or (cross(c,多空转折线) and c<w) or (cross(c,多空转折线) and cross(c,w))) and kkk<0)-barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25))),nodraw; drawtext(cross(0,kd) and kkk>0,w,\'平多\'),coloryellow; drawtext(cross(0,kk) and kkk<0,w,\'平空\'),coloryellow; 上面是公式: 模型要求按照公式开多,开空,平多,平空。 1.第一次开多后,如果连续出现开多,那么就是加仓。 然后如果出现平多,就把2次开仓的全部平仓。 2.开空也是如此。 3.开仓 加仓手数可以设置就行
|
-- 作者:jinzhe -- 发布时间:2014/5/28 10:16:47 -- kdss:=某个数值;//开多手数 jdss:=某个数值;//加多手数 kkss:=某个数值;//开空手数 jkss:=某个数值;//加空手数
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001 and holding=0 then begin buy(holding=0,kdss,market); end
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001 and holding>0 then begin buy(holding>0,jdss,market); end
if cross(ref(llv(l,25),1)*0.99999 and holding=0 then begin buyshort(holding=0,kkss,market); end
if cross(ref(llv(l,25),1)*0.99999 and holding<0 then begin buyshort(holding<0,jkss,market); end
if cross(0,kd) and kkk>0 then sell(1,0,market); if cross(0,kk) and kkk<0 then sellshort(1,0,market); |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:26:32 -- 金哲老师 显示引用的括号不完整。您的这些编码括号有问题? |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:30:48 -- if cross(ref(llv(l,25),1))*0.99999 and holding=0 then begin buyshort(holding=0,kkss,market); end; 这一行显示 CROSS 调用参数与预定参数不符
|
-- 作者:jinzhe -- 发布时间:2014/5/28 10:34:48 -- 这个条件是照着你原来代码里面抄的,有问题就是你原来的代码有问题 |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:35:33 -- 但是 金哲老师 我原来代码测评没问题啊,加上您这些 就测评不通过了 |
-- 作者:jinzhe -- 发布时间:2014/5/28 10:38:10 -- cross(ref(llv(l,25),1))*0.99999 改成cross(ref(llv(l,25),1)*0.99999,llv(c,25)) |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:46:23 -- 指标开空一次。怎么模型开空2次? |
-- 作者:qichao371 -- 发布时间:2014/5/28 10:48:34 -- 我长传不了图片,就是指标显示“开空” 模型却开空两次 |
-- 作者:jinzhe -- 发布时间:2014/5/28 10:53:26 -- cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding=0 then begin buy(holding=0,kdss,market); end
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding>0 then begin buy(holding>0,jdss,market); end
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding=0 then begin buyshort(holding=0,kkss,market); end
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding<0 then begin buyshort(holding<0,jkss,market); end
if cross(0,kd) and kkk>0 then sell(1,0,market); if cross(0,kk) and kkk<0 then sellshort(1,0,market); |