以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请教一下这种情况如何实现 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=51592) |
-- 作者:blackcn -- 发布时间:2013/5/2 23:09:44 -- 请教一下这种情况如何实现 请教各位老师 d 和k 是kdj中的 ENTERLONG:CROSS(C,ma(c,5)); EXITLONG:CROSS(d,k); 比如这个简单的模型,执行时,会先出现多次买入,再出现多次卖出 而我想要买入一次后再卖出一次作为一个循环完成。如何实现呀 |
-- 作者:jinzhe -- 发布时间:2013/5/3 9:04:00 -- ENTERLONG:CROSS(C,ma(c,5)),tfilter;
EXITLONG:CROSS(d,k),tfilter;
现在这种交易函数不推荐和提倡使用
|
-- 作者:blackcn -- 发布时间:2013/5/3 11:52:34 -- 再次请教下, 我自己的公式在最下边 我引用了PB指标里的HH线 如果价格突破FB买入 如果价格线跌破FB就选择FB作为触发条件卖出,如果先跌破HH就选择HH作为触发卖出条件 可是我写了最下边的公式,不能按照我的意思进行卖出交易,卖出的指示很混乱 能帮我写下这个吗,谢谢了 PB的公式如下 { runmode:0; input:V1(1,1,100,1); input:f1(0.4); input:f2(0.07); input:f3(0.18); input:m(0.9); input:x(3,1,10,1); variable:up=0; variable:bsetup=0; variable:senter=0; variable:benter=0; variable:bbreak=0; variable:sbreak=0; variable:ltoday=0; variable:h0=999999; variable:sn=0; variable:div=0; variable:rf=false; i:=m*(callstock(stklabel,vtopen,6,0)/100); if barpos=1 then begin sn:=0; div:=max(x,1);//xdiv end hh:ref(h0,1),noaxis; cc:=ref(close,1); ll:=ref(ltoday,1); if date>ref(date,1) then begin sn:=sn+1; up:=hh+f1*(cc-ll); senter:=((1+f2)/2)*(hh+cc)-f2*ll; benter:=((1+f2)/2)*(ll+cc)-f2*hh; bsetup:=ll-f1*(hh-cc); bbreak:=up+f3*(up-bsetup); sbreak:=bsetup-f3*(up-bsetup); h0:=high; ltoday:=low; rf:=hh-cc>=0.2{rangemin}; end if high>h0 then h0:=high; if low<ltoday then ltoday:=low; if time>=opentime(1) and time<closetime(0)-500 and sn>=2 and rf then begin if h0>=up and holding>=0 then begin if low<=senter+(h0-up)/div then begin sell(1,v1,thisclose); buyshort(1,v1,thisclose); end end if ltoday<=bsetup and holding<=0 then begin if high>=benter-(bsetup-ltoday)/div then begin if high>=benter-(bsetup-ltoday)/div then begin sellshort(1,v1,thisclose); buy(1,v1,thisclose); end end end if holding<0 then begin if high-enterprice>=i then sellshort(1,v1,thisclose); end if holding>0 then begin if enterprice-low>=i then sell(1,v1,thisclose); end if holding=0 then begin if high>=bbreak then buy(1,v1); end if holding=0 then begin if low<=sbreak then buyshort(1,v1); end end if time>=closetime(0)-500 then begin if holding<0 then sellshort(1,v1); if holding>0 then sell(1,v1); end 资产:asset,noaxis,coloryellow,linethick2; } 自己的公式如下 ZH:=callstock(stklabel,vthigh,6,-1); ZL:=callstock(stklabel,vtlow,6,-1); FS:=(1.07/2)*(ZH+ZL)-0.07*ZL; FB:(1.07/2)*(ZH+ZL)-0.07*ZH; HH:"pb.hh"; sellc:=if(FB>HH,FB,HH); ENTERLONG:CROSS(C,FB),tfilter; EXITLONG:CROSS(sellc,C),tfilter;
|
-- 作者:jinzhe -- 发布时间:2013/5/3 13:15:28 -- 这是要写两个公式的 |
-- 作者:blackcn -- 发布时间:2013/5/3 13:22:16 -- 麻烦给优化出来吧,谢谢了,自己刚开始看了一部分金字塔编程,可惜基础太差,自己编不出复杂的东西,只能东拼西凑想检测一下自己的理解 |
-- 作者:blackcn -- 发布时间:2013/5/3 15:13:23 -- 小妹急切等待版主和数据专家以及各位高人帮助 |