以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (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=171266)

--  作者:OscarDeng
--  发布时间:2019/7/24 21:38:52
--  在调用跨周期的时候,近期或者近两三天的信号就不会出现的?
在调用跨周期的时候, 做检测我经常发现在信号从很久以前历史数据到几天前的历史数据都能够有效显示, 但是近期或者近两三天的信号就不会出现的? 我也专门下载了近三天的历史数据, 发现问题还是一直出现, 是什么原因造成的?
--  作者:FireScript
--  发布时间:2019/7/25 9:02:44
--  
 你跨周期调用的时候是不是做了偏移量的设置?你描述的情况最好配合代码一起说明下比较好。
--  作者:OscarDeng
--  发布时间:2019/7/25 9:54:27
--  我只是偏离了-1 , 但是不明白为什么为什么DIFF最后变成了直线,没有显示出来。

我只是偏离了-1 , 但是不明白为什么为什么DIFF最后变成了直线,没有显示出来。 看附件, 附图有个MACD背离指标能显示两个底背离, 但是在图表程序化显示不出来。

 

//上证指数
SHDIFFDAY:STKINDI(\'SH000001\',\'MACDViolate.DIFF(12,26,9)\',0,6,-1),noaxis;
SHDIFF60MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,5,-1),noaxis;
SHDIFF15MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,3,-1),noaxis;
SHDIFF5MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,2,-1),noaxis;
SHDIFF1MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,1,-1),noaxis;
SHDEA1MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DEA(12,26,9)\',0,1,-1),noaxis;
//POSITIVEV, PV 代表底背离POSITIVE VIOLATION, 底背离
//PV 是调用底背离第几次,SHPOSITIVEVDAY是代表底背离的程度
SHPV5MIN1:STKINDI(\'SH000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN2:STKINDI(\'SH000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN3:STKINDI(\'SH000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN4:STKINDI(\'SH000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN5:STKINDI(\'SH000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,2,-1),noaxis;


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20190725095207.png
图片点击可在新窗口打开查看

--  作者:FireScript
--  发布时间:2019/7/25 10:24:48
--  
 可以把MACDViolate的代码提供下。我本地直接调试下吧。
--  作者:OscarDeng
--  发布时间:2019/7/25 11:25:12
--  我在2018年已经下载了该有的历史数据, 但是分钟级别在2018年根本就显示不出来, 只能显示日线的的信号。 这是为什么?

这个是MACDVIOLATE 的公式,参数你自己设置

 

DIFF :EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA  :EMA(DIFF,M);
MACD:2*(DIFF-DEA),COLORSTICK;
MACDMAX:=MAX(C,O);
MACDMIN:=MIN(C,O);
MACDL:=LLV(MACDMIN,7);//8周期内最低收盘价

{Variable:I=0;
Variable:DIFFLLV2=DIFF;
For I=0 to 7 do BEGIN
    iF i<>LLVBARS(DIFF,7) and DIFFLLV2>=REF(DIFF,I) THEN DIFFLLV2=REF(DIFF,I);
    I=I+1;
END}
DIFFL:=(LLV(DIFF,7)+REF(DIFF,LLVBARS(DIFF,7)-1)+REF(DIFF,LLVBARS(DIFF,7)+1))/3;//4天到8周期的最低DIFF
GTMIN:=DEA>REF(DEA,1) AND REF(DEA,1)<REF(DEA,2) && DEA<0;//找DEA是最低的
A1:=BARSLAST(REF(GTMIN,1));//A1底背离,最低转折点到今天的周期数, 转折点单根K线为0
A2:=A1+REF(A1,A1+1);
A3:=A2+REF(A1,A2+2);
A4:=A3+REF(A1,A3+3);
A5:=A4+REF(A1,A4+4);
IGNOREMIN1:=ABS( REF(DIFFL,A1+1)/DIFFL/( MACDL/REF(MACDL,A1+1)) )>1.06;
IGNOREMIN2:=ABS( REF(DIFFL,A2+1)/DIFFL/( MACDL/REF(MACDL,A2+1)) )>1.06;
IGNOREMIN3:=ABS( REF(DIFFL,A3+1)/DIFFL/( MACDL/REF(MACDL,A4+1)) )>1.06;
IGNOREMIN4:=ABS( REF(DIFFL,A4+1)/DIFFL/( MACDL/REF(MACDL,A4+1)) )>1.06;
IGNOREMIN5:=ABS( REF(DIFFL,A5+1)/DIFFL/( MACDL/REF(MACDL,A5+1)) )>1.06;

底背离1:=(REF(MACDL,A1+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A1+1))>=0 AND GTMIN AND IGNOREMIN1;
底背离2:=(REF(MACDL,A2+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A2+1))>=0 AND GTMIN AND IGNOREMIN2 AND (底背离1<>1) AND COUNT(CROSS(DEA,DIFF) && DEA>0,A2)<2;
底背离3:=(REF(MACDL,A3+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A3+1))>=0 AND GTMIN AND IGNOREMIN3 AND ((底背离1||底背离2)<>1) AND COUNT(CROSS(DEA,DIFF) && DEA>0,A3)<2;
底背离4:=(REF(MACDL,A4+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A4+1))>=0 AND GTMIN AND IGNOREMIN4 AND ((底背离1||底背离2||底背离3)<>1) AND COUNT(CROSS(DEA,DIFF) && DEA>0,A4)<2;
底背离5:=(REF(MACDL,A5+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A5+1))>=0 AND GTMIN AND IGNOREMIN5 AND ((底背离1||底背离2||底背离3||底背离4)<>1) AND COUNT(CROSS(DEA,DIFF) && DEA>0,A5)<2;
底背离:底背离1||底背离2||底背离3||底背离4||底背离5;

//PV POSITIVE VIOLATION 底背离的简称。 底背离和PV的区别是如果有底背离1, 那就没有底背离2. PV就是既可以有底背离1, 也可以有底背离2
PV1:=(REF(MACDL,A1+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A1+1))>=0 AND GTMIN AND IGNOREMIN1;
PV2:=(REF(MACDL,A2+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A2+1))>=0 AND GTMIN AND IGNOREMIN2 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A2)<2;
PV3:=(REF(MACDL,A3+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A3+1))>=0 AND GTMIN AND IGNOREMIN3 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A3)<2;
PV4:=(REF(MACDL,A4+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A4+1))>=0 AND GTMIN AND IGNOREMIN4 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A4)<2;
PV5:=(REF(MACDL,A5+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A5+1))>=0 AND GTMIN AND IGNOREMIN5 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A5)<2;

{文华8
DRAWLINE(底背离1,DEA,底背离1,REF(DEA,A1),0),COLORRED,LINETHICK2;
DRAWLINE(底背离2,DEA,底背离2,REF(DEA,A2),0),COLORRED,LINETHICK2;
DRAWLINE(底背离3,DEA,底背离3,REF(DEA,A3),0),COLORRED,LINETHICK2;
DRAWLINE(底背离4,DEA,底背离4,REF(DEA,A4),0),COLORRED,LINETHICK2;
DRAWLINE(底背离5,DEA,底背离5,REF(DEA,A5),0),COLORRED,LINETHICK2;}
VERTLINE(底背离1,DEA,REF(DEA,A1),COLORRED,LINETHICK2);
VERTLINE(底背离2,DEA,REF(DEA,A2),COLORRED,LINETHICK2);
VERTLINE(底背离3,DEA,REF(DEA,A3),COLORRED,LINETHICK2);
VERTLINE(底背离4,DEA,REF(DEA,A4),COLORRED,LINETHICK2);
VERTLINE(底背离5,DEA,REF(DEA,A5),COLORRED,LINETHICK2);
DRAWTEXT(底背离1,DEA,\'底背离1\'),COLORFF00FF;
DRAWTEXT(底背离2,DEA,\'底背离2\'),COLORFF00FF;
DRAWTEXT(底背离3,DEA,\'底背离3\'),COLORFF00FF;
DRAWTEXT(底背离4,DEA,\'底背离4\'),COLORFF00FF;
DRAWTEXT(底背离5,DEA,\'底背离5\'),COLORFF00FF;

 

 

这个是主函数, 分别60分钟, 5分钟, 15分钟, 天数调用, 还有一个问题, 我在2018年已经下载了该有的历史数据, 但是分钟级别在2018年根本就显示不出来, 只能显示日线的的信号。 这是为什么?

SHDIFFDAY:STKINDI(\'SH000001\',\'MACDViolate.DIFF(12,26,9)\',0,6,-1),noaxis;
SHDIFF60MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,5,-1),noaxis;
SHDIFF15MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,3,-1),noaxis;
SHDIFF5MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,2,-1),noaxis;
SHDIFF1MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,1,-1),noaxis;
SHDEA1MIN:STKINDI(\'SH000001\',\'MACDVIOLATE.DEA(12,26,9)\',0,1,-1),noaxis;
//POSITIVEV, PV 代表底背离POSITIVE VIOLATION, 底背离
//PV 是调用底背离第几次,SHPOSITIVEVDAY是代表底背离的程度
SHPV5MIN1:STKINDI(\'SH000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN2:STKINDI(\'SH000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN3:STKINDI(\'SH000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN4:STKINDI(\'SH000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,2,-1),noaxis;
SHPV5MIN5:STKINDI(\'SH000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,2,-1),noaxis;

SHPV15MIN1:STKINDI(\'SH000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,3,-1),noaxis;
SHPV15MIN2:STKINDI(\'SH000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,3,-1),noaxis;
SHPV15MIN3:STKINDI(\'SH000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,3,-1),noaxis;
SHPV15MIN4:STKINDI(\'SH000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,3,-1),noaxis;
SHPV15MIN5:STKINDI(\'SH000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,3,-1),noaxis;

SHPV60MIN1:STKINDI(\'SH000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,5,-1),noaxis;
SHPV60MIN2:STKINDI(\'SH000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,5,-1),noaxis;
SHPV60MIN3:STKINDI(\'SH000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,5,-1),noaxis;
SHPV60MIN4:STKINDI(\'SH000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,5,-1),noaxis;
SHPV60MIN5:STKINDI(\'SH000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,5,-1),noaxis;

SHPVDAY1:STKINDI(\'SH000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,6,-1),noaxis;
SHPVDAY2:STKINDI(\'SH000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,6,-1),noaxis;
SHPVDAY3:STKINDI(\'SH000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,6,-1),noaxis;
SHPVDAY4:STKINDI(\'SH000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,6,-1),noaxis;
SHPVDAY5:STKINDI(\'SH000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,6,-1),noaxis;

SHPV5MIN:=STKINDI(\'SH000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,2,-1),noaxis;
SHPV15MIN:=STKINDI(\'SH000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,3,-1),noaxis;
SHPV60MIN:=STKINDI(\'SH000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,5,-1),noaxis;
SHPVDAY6:=STKINDI(\'SH000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,6,-1),noaxis;

 

//深圳指数
SZDIFFDAY:STKINDI(\'SZ000001\',\'MACDViolate.DIFF(12,26,9)\',0,6,-1),noaxis;
SZDIFF60MIN:STKINDI(\'SZ000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,5,-1),noaxis;
SZDIFF15MIN:STKINDI(\'SZ000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,3,-1),noaxis;
SZDIFF5MIN:STKINDI(\'SZ000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,2,-1),noaxis;
SZDIFF1MIN:STKINDI(\'SZ000001\',\'MACDVIOLATE.DIFF(12,26,9)\',0,1,-1),noaxis;
SZDEA1MIN:STKINDI(\'SZ000001\',\'MACDVIOLATE.DEA(12,26,9)\',0,1,-1),noaxis;
//POSITIVEV, PV 代表底背离POSITIVE VIOLATION, 底背离
//PV 是调用底背离第几次,POSITIVEVDAY是代表底背离的程度
SZPV5MIN1:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,2,-1),noaxis;
SZPV5MIN2:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,2,-1),noaxis;
SZPV5MIN3:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,2,-1),noaxis;
SZPV5MIN4:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,2,-1),noaxis;
SZPV5MIN5:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,2,-1),noaxis;

SZPV15MIN1:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,3,-1),noaxis;
SZPV15MIN2:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,3,-1),noaxis;
SZPV15MIN3:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,3,-1),noaxis;
SZPV15MIN4:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,3,-1),noaxis;
SZPV15MIN5:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,3,-1),noaxis;

SZPV60MIN1:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,5,-1),noaxis;
SZPV60MIN2:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,5,-1),noaxis;
SZPV60MIN3:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,5,-1),noaxis;
SZPV60MIN4:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,5,-1),noaxis;
SZPV60MIN5:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,5,-1),noaxis;

SZPVDAY1:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV1(12,26,9)\',0,6,-1),noaxis;
SZPVDAY2:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV2(12,26,9)\',0,6,-1),noaxis;
SZPVDAY3:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV3(12,26,9)\',0,6,-1),noaxis;
SZPVDAY4:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV4(12,26,9)\',0,6,-1),noaxis;
SZPVDAY5:=STKINDI(\'SZ000001\',\'MACDVIOLATE.PV5(12,26,9)\',0,6,-1),noaxis;

SZPV5MIN:=STKINDI(\'SZ000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,2,-1),noaxis;
SZPV15MIN:=STKINDI(\'SZ000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,3,-1),noaxis;
SZPV60MIN:=STKINDI(\'SZ000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,5,-1),noaxis;
SZPVDAY6:=STKINDI(\'SZ000001\',\'MACDVIOLATE.底背离(12,26,9)\',0,6,-1),noaxis;


--  作者:FireScript
--  发布时间:2019/7/25 14:31:05
--  
 好像是这样的。

SH001和SH000001 数据其实是一样的。但是分别属于期货和股票行情。数据虽然一样,但是分别存储的。你图上和代码里指定的不是一致的。
你上图上 图上用的好像是期货的SH001,但是你跨周期调用的000001是属于股票行情里的。
你调整下试下。

我调整后是这样的,18年的也有数据的。

图片点击可在新窗口打开查看此主题相关图片如下:temp.png
图片点击可在新窗口打开查看

--  作者:OscarDeng
--  发布时间:2019/8/3 13:00:32
--  为什么我要用: , 不能用:=。 如果我用:= , 使用 STKINDI 调用这个值就不能被输出。

我想问一下, 为什么我要用: , 不能用:=。  如果我用:= , 使用  STKINDI 调用这个值就不能被输出。  

 

必须是这样,不能使用:=。 这些值才能被调用输出

底背离:底背离1||底背离2||底背离3||底背离4||底背离5;

PV1:(REF(MACDL,A1+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A1+1))>=0 AND GTMIN AND IGNOREMIN1;
PV2:(REF(MACDL,A2+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A2+1))>=0 AND GTMIN AND IGNOREMIN2 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A2)<2;
PV3:(REF(MACDL,A3+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A3+1))>=0 AND GTMIN AND IGNOREMIN3 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A3)<2;
PV4:(REF(MACDL,A4+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A4+1))>=0 AND GTMIN AND IGNOREMIN4 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A4)<2;
PV5:(REF(MACDL,A5+1)-MACDL)/MACDL>=-0.01 AND (DIFFL-REF(DIFFL,A5+1))>=0 AND GTMIN AND IGNOREMIN5 AND COUNT(CROSS(DEA,DIFF) && DEA>0,A5)<2;


--  作者:FireScript
--  发布时间:2019/8/5 8:49:01
--  
 是这样的。跨周期调用的变量需要采用 “:”的方式去定义。