-- 作者: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;
|