以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 怎么编写5日下穿了30日后当周期的bar后面的4跟bar的收盘价都在ma30之下呢? (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=74627) |
-- 作者:pyd -- 发布时间:2015/1/19 10:46:10 -- 怎么编写5日下穿了30日后当周期的bar后面的4跟bar的收盘价都在ma30之下呢? 请教:若是corss(ma30,ma5);请问怎么编写5日下穿了30日后当周期的bar后面的4跟bar的收盘价都在ma30之下呢?
|
-- 作者:pyd -- 发布时间:2015/1/19 10:54:31 -- ma30:ma(c,30); aa=1时是满足条件 |
-- 作者:leysta -- 发布时间:2015/1/19 11:34:53 -- 您好! 请问ref不是向前引用吗? 举例来说:今天19号,cross(ma30,ma5); 今天的bar收盘时候已经满足了开空条件了,但是我不想在今年开仓,后续还想验证下,就加了个附加条件,也就是20,21,,22的bar的closs<ma30一直成立,在22号的time=145800的最近价格进行开空的动作。 |
-- 作者:jinzhe -- 发布时间:2015/1/19 13:29:21 -- ref就是起这个作用的,判断之前是否满足条件 |
-- 作者:leysta -- 发布时间:2015/1/19 13:35:06 -- 老是,那今天是19号,ref(c<ma30,3)这个语句不就是判断的是16 15 14这个三天的数据的吗? 而且会有一种情况就是cross(ma30,ma5)成立的时候,由于之前的行情急跌了,也会导致ref(c<ma30,3)成立的这样子不久变成在19开仓了吗? 有没有向后做条件判断的呢 |
-- 作者:jinzhe -- 发布时间:2015/1/19 13:46:04 -- 那通用的,如果是在22号,那么这个就是判断19号的情况 |
-- 作者:leysta -- 发布时间:2015/1/21 14:43:42 -- 回复:(jinzhe)那通用的,如果是在22号,那么这个就... RUNMODE:0; input: barcout1(1),barcout2(2),barcout3(3); input:SHORTPRIED(3,0,60,5); VARIABLE:myholding:=0,recentlyc:=0,i=0,times=0; 第一根bar:=BARSLAST(times) = barcout1,NOAXIS; 第二根bar:=BARSLAST(times) = barcout2,NOAXIS; 第三根bar:=BARSLAST(times) = barcout2,NOAXIS; 开多条件1:=cross(雷,资); 开多条件2:=cross(投,资); 开多条件2.1:=投>资 and 雷>投; 开多条件2.2:=雷>=REF(雷,SHORTPRIED); 开多条件3:=cross(雷,投); 平多条件:=雷<=REF(雷,SHORTPRIED); 开空条件1:=cross(资,雷); 开空条件2:=cross(资,投); 开空条件2.1:=投<资 and 雷<投; 开空条件2.2:=雷<=REF(雷,SHORTPRIED); 开空条件3:=cross(投,雷); 平空条件:=雷>=REF(雷,SHORTPRIED); if holding=0 then BEGIN if 投<资 and 开多条件1 THEN begin times=1; //过滤条件
if 第一根bar then recentlyc=close;
if recentlyc>资 then i=1;
if i=1 and 第二根bar then recentlyc=close;
if recentlyc>资 then i=2;
if i=2 and 第三根bar then recentlyc=close;
if recentlyc>资 then i=3; if i=3 then begin 开多:BUY(1,10%,limitr,CLOSE); end end if 开多条件2.1 and 开多条件2.2 then begin 开多3:buy(1,intpart(myholding/2),limitr,CLOSE); end end if holding>0 then begin myholding:=0; if 开多条件2 then begin 开多2:buy(1,10%,limitr,CLOSE); end myholding:=holding; end //多头平仓 if holding>0 then begin if 平多条件 then begin 平多:sell(1,holding,limitr,CLOSE); end end //建立空头模块 if holding=0 then BEGIN if 投>资 and 开空条件1 THEN begin times=1; //过滤条件
if 第一根bar then recentlyc=close;
if recentlyc<资 then i=1;
if i=1 and 第二根bar then recentlyc=close;
if recentlyc<资 then i=2;
if i=2 and 第三根bar then recentlyc=close;
if recentlyc<资 then i=3; if i=3 then begin 开空:BUYshort(1,10%,limitr,CLOSE); end end if 开空条件2.1 and 开空条件2.2 then begin 开空3:buyshort(1,intpart(myholding/2),limitr,CLOSE); end end if holding<0 then begin myholding:=0; if 开空条件2 then begin 开空2:buyshort(1,10%,limitr,CLOSE); end myholding:=holding; end //空头平仓 if holding<0 then begin if 平空条件 then begin 平空:sellshort(1,holding,limitr,CLOSE); end end 持仓:holding,noaxis,LINETHICK0; 资金:ASSET,noaxis,LINETHICK2,COLORCYAN; 收益:asset/1000000,NOAXIS,LINETHICK0; 老师您好,我中间添加了一段过滤条件的代码后发现坐标收到了影响,请教下需要在哪里添加noaxis。 老师中间那段代码哪里逻辑出错了吗?加载的时候没有显示应有的效果。麻烦老师了 |
-- 作者:jinzhe -- 发布时间:2015/1/21 14:50:29 -- Y轴右键勾选仅随k线变动 没效果是什么情况?在你认为应该起作用的地方没起作用?那么举例说明一下你认为应该起作用的地方 |
-- 作者:leysta -- 发布时间:2015/1/21 14:53:50 -- RUNMODE:0; input: barcout1(1),barcout2(2),barcout3(3); input:SHORTPRIED(3,0,60,5); VARIABLE:myholding:=0,recentlyc:=0,i=0,times=0; 第一根bar:=BARSLAST(times) = barcout1,NOAXIS; 第二根bar:=BARSLAST(times) = barcout2,NOAXIS; 第三根bar:=BARSLAST(times) = barcout2,NOAXIS; 开多条件1:=cross(雷,资); 开多条件2:=cross(投,资); 开多条件2.1:=投>资 and 雷>投; 开多条件2.2:=雷>=REF(雷,SHORTPRIED); 开多条件3:=cross(雷,投); 平多条件:=雷<=REF(雷,SHORTPRIED); 开空条件1:=cross(资,雷); 开空条件2:=cross(资,投); 开空条件2.1:=投<资 and 雷<投; 开空条件2.2:=雷<=REF(雷,SHORTPRIED); 开空条件3:=cross(投,雷); 平空条件:=雷>=REF(雷,SHORTPRIED); if holding=0 then BEGIN if 投<资 and 开多条件1 THEN begin times=1; //过滤条件
if 第一根bar then recentlyc=close;
if recentlyc>资 then i=1;
if i=1 and 第二根bar then recentlyc=close;
if recentlyc>资 then i=2;
if i=2 and 第三根bar then recentlyc=close;
if recentlyc>资 then i=3; if i=3 then begin 开多:BUY(1,10%,limitr,CLOSE); end end if 开多条件2.1 and 开多条件2.2 then begin 开多3:buy(1,intpart(myholding/2),limitr,CLOSE); end end if holding>0 then begin myholding:=0; if 开多条件2 then begin 开多2:buy(1,10%,limitr,CLOSE); end myholding:=holding; end //多头平仓 if holding>0 then begin if 平多条件 then begin 平多:sell(1,holding,limitr,CLOSE); end end //建立空头模块 if holding=0 then BEGIN if 投>资 and 开空条件1 THEN begin //当条件成立后记录times=1 times=1; //过滤条件
if 第一根bar then recentlyc=close; //上次条件成立后到现在的天数等于1,也就是昨天若是条件成立,对今天的bar进行条件判断 ,并今天收盘价赋值给recentlyc
if recentlyc<资 then i=1; //比较今天收盘价和参考线的大小,若是成立则标记i=1;
if i=1 and 第二根bar then recentlyc=close; //若是times=1条件成立后到现在的天数等于2,对今天的bar进行条件判断 ,并今天收盘价赋值给recentlyc
if recentlyc<资 then i=2;
if i=2 and 第三根bar then recentlyc=close;
if recentlyc<资 then i=3; //一次类推判断条件成立后三天的收盘的,只要是任意一天不成立则不进行开仓动作 if i=3 then begin 开空:BUYshort(1,10%,limitr,CLOSE); end end if 开空条件2.1 and 开空条件2.2 then begin 开空3:buyshort(1,intpart(myholding/2),limitr,CLOSE); end end if holding<0 then begin myholding:=0; if 开空条件2 then begin 开空2:buyshort(1,10%,limitr,CLOSE); end myholding:=holding; end //空头平仓 if holding<0 then begin if 平空条件 then begin 平空:sellshort(1,holding,limitr,CLOSE); end end 持仓:holding,noaxis,LINETHICK0; 资金:ASSET,noaxis,LINETHICK2,COLORCYAN; 收益:asset/1000000,NOAXIS,LINETHICK0; 老师您好,我中间添加了一段过滤条件的代码后发现坐标收到了影响,请教下需要在哪里添加noaxis。 老师中间那段代码哪里逻辑出错了吗?加载的时候没有显示应有的效果。麻烦老师了 老师我从新编辑下 |
-- 作者:pyd -- 发布时间:2015/1/21 15:01:01 -- 1,雷,投等未定义的变量,,贴全部代码,要编译能通过的。 2,什么没有效果?你要什么样的效果? 3,和一楼问题有关系吗? [此贴子已经被作者于2015/1/21 15:04:13编辑过]
|