|
- {K线微积分律与MACD;MACD_DCIC_K ;原创及版权属于JIPGEMLING.见凌见;}
- {关键词:K线微积分律,MACD指标}
- {仅允许个人自用、互联网传播并带上作者笔名及版权声明}
- {本文实际证明了等式:
- DIF=(LONG-SHORT)/2*EMA(EMA((C-REF(C,1)),SHORT),LONG)
- =((LONG-SHORT)/2)*EMA(EMA(C,SHORT)-REF(EMA(C,SHORT),1),LONG)
- =EMA(C,SHORT)-EMA(C,LONG) }
- {即,对于SHORT>=1和LONG>=1 的所有正整数,上述等式成立。}
- {证明:用数学归纳法。由于我们不知道股软函数EMA()、REF()的具体形式,所以计算过程要结合股软(TDX)辅证。
- 1、首先当SHORT=1、LONG=1时,公式两边0=0,等式显然成立;
- 2、当SHORT=1、LONG=>2时并在股软上任意调节对比,等式两边数值非恒量但均相等,故等式成立;
- 3、当LONG=1时,SHORT=>2并在股软上任意调节对比,等式两边数值非恒量但均相等,故等式成立;
- 4、其余任意正整数,在股软上任意调节对比,等式两边数值非恒量但均相等,故等式成立;
- 5、根据上述结论和数学归纳法原理,对于SHORT>=1和LONG>=1 的所有正整数,等式成立。证毕。}
- {同理可证1:DIF_H =(LONG-SHORT)/2*EMA(EMA((H-REF(H,1)),SHORT),LONG)= }
- {=((LONG-SHORT)/2)*EMA(EMA(H,SHORT)-REF(EMA(H,SHORT),1),LONG)=EMA(H,SHORT)-EMA(H,LONG);}
- {同理可证2:DIF_L =(LONG-SHORT)/2*EMA(EMA((L-REF(L,1)),SHORT),LONG)= }
- {=((LONG-SHORT)/2)*EMA(EMA(L,SHORT)-REF(EMA(L,SHORT),1),LONG)=EMA(L,SHORT)-EMA(L,LONG);}
- {同理可证3:DIF_O =(LONG-SHORT)/2*EMA(EMA((O-REF(O,1)),SHORT),LONG)= }
- {=((LONG-SHORT)/2)*EMA(EMA(O,SHORT)-REF(EMA(O,SHORT),1),LONG)=EMA(O,SHORT)-EMA(O,LONG);}
- {同理可证4:DIF_CC =(LONG-SHORT)/2*EMA(EMA((CC-REF(CC,1)),SHORT),LONG)= }
- {=((LONG-SHORT)/2)*EMA(EMA(CC,SHORT)-REF(EMA(CC,SHORT),1),LONG)=EMA(CC,SHORT)-EMA(CC,LONG);}
- {其中CC=(C+H+L)/3;只要C、H、L、O 属于相同时序的常系数线性组合(可否为有理式组合?)}
- {可否考虑将上述事实作为一个【K线定理、定律】来看待?}
- {MACD功效、一般应用、典型应用条件}
- {一般应用条件:LONG>SHORT;典型应用:LONG=2*(SHORT+1),}
- {即LONG是SHORT的2个倍频程+2个K线单位时程(看待为积分一个完整的脉冲周期而又不致于丢失信息和混入杂波)}
- {微分具有剔除低频(长线资金)的作用,积分是微分的反运算,并有压制高频杂波(投机资金)的作用。}
- {MACD式子是个“有源平直中频带通滤波器”,做法是差值滤波并作2倍放大,取得中线资金激励信息。}
- {MACD指标突出中线资金的买卖趋势。0轴为多空平衡位。参数设置应考虑是否符合指标本身固有功能}
- {受中波广播频段(535kHz--1605kHz)设置的启发,现提出 LONG<=3*SHORT 这样的条件是否合理?}
- {语句注释}
- DFC:=C-REF(C,1);{收盘价前差值,K线微分}
- WJXS:=(LONG-SHORT)/2;{微积分系数,可由中值定理导出,为兼顾后面引用及统一标尺,前移至此}
- JGL_JF:=WJXS*EMA(DFC,SHORT);{内层积分,隐含积分限[1--SHORT],结果:WJXS*EMA(EMA(CC,SHORT)-REF(EMA(CC,SHORT),1),LONG)}
- DIF_JIP:EMA(JGL_JF,LONG);{外层积分,重积分,隐含积分限[1--LONG],结果:EMA(CC,SHORT)-EMA(CC,LONG)}
- DEA_GEM:EMA(DIF_JIP,MID);{平滑,压制高频}
- MACD_LING:2*(DIF_JIP-DEA_GEM),COLOR1133FF,COLORSTICK;{差值滤波然后作2倍放大,显示红、青色针状线柱}
- {“类KDJ”}
- {以下为“类KDJ”及显示“J值前差值柱”,后者可提高对涨跌的肉眼分辨率,提高对短线波动的感知度}
- {J值式子具有“有源高频滤波器”性质,经典KDJ的J是对高频信号作3倍放大,D是对中高频作2倍放大,}
- {然后差值滤波,滤掉中低频和杂波信号,所以在选择系数时应考虑使激励与阻尼达平衡,避免过激励和欠激励}
- {J_DF系数,设A=2.00~3.00,B=1.00~2.00,弱必要条件是 A-B=1,使差值信号仍有1倍放大,3条线间隔大致等距}
- K_DF_J:SMA(JGL_JF,M1,1),COLORFEDCBA;{平滑,压制超短线杂波}
- D_DF_G:SMA(K_DF_J,M2,1),COLOR13F8F9;{再平滑,圆滑超短线造成的扰动}
- J_DF_L:2.5*K_DF_J-1.5*D_DF_G,COLORF813F9;{有源差值滤波,取得中高频短线信号}
- RF:=REF(J_DF_L,1);
- DJ:=ABS(J_DF_L-RF);
- MM:=(HHV(DJ,120)+LLV(DJ,120))/2;
- STICKLINE(J_DF_L>RF,J_DF_L,RF,2.3,0),COLOR1388D3;
- STICKLINE(J_DF_L>RF,J_DF_L,RF,1.0,0),COLOR13AAD3;
- STICKLINE(J_DF_L<RF,J_DF_L,RF,2.3,0),COLOR338833;
- STICKLINE(J_DF_L<RF,J_DF_L,RF,1.0,0),COLOR33AA33;
- STICKLINE(J_DF_L<RF AND DJ<0.2*MM,J_DF_L+0.15*MM,RF-0.15*MM,0.1,0),COLOR33AA33;
- STICKLINE(J_DF_L>=RF AND DJ<0.2*MM,RF-0.1*MM,J_DF_L+0.1*MM,0.1,0),COLOR13AADD;
- {轨道设置,仅作试用;KG(开关,默认 开);{飞狐等版本可考虑用虚线}}
- N:=SQRT(SHORT*LONG);
- NN:=IF(N<9,9,N);
- BZC:=STD(DFC,NN);
- U:IF(KG=1,K_DF_J+2*BZC,MA(C,25600)),COLORFE9813,CROSSDOT,LINETHICK2;
- D:IF(KG=1,K_DF_J-2*BZC,MA(C,25600)),COLOR33EAEA,CROSSDOT,LINETHICK2;
- {实际加入编译的语句及“说明头”如下}
- {副图:MACD_DCIC ;K线微积分律与MACD;}
- {原创及版权属于JIPGEMLING.见凌见;JIPGEMLING.签名版}
- {参数设置: SHORT(1,300,12);LONG(2,300,26);MID(2,200,9);}
- {参数设置: M1(2,300,3);M2(2,300,3);KG(1,2,1);}
- {坐标线位置:自动;额外Y轴分界 值1=0;}
- {TDX版(基本通用版)中高分辨率屏幕;如嫁接其他版本,可调整“J值前差值柱”的宽度}
- DFC:=C-REF(C,1);
- WJXS:=(LONG-SHORT)/2;
- JGL_JF:=WJXS*EMA(DFC,SHORT);
- DIF_JIP:EMA(JGL_JF,LONG),COLOR1188FF,LINETHICK2;
- DEA_GEM:EMA(DIF_JIP,MID),COLORGREEN,LINETHICK2;
- MACD_LING:2*(DIF_JIP-DEA_GEM),COLOR1133FF,COLORSTICK;
- K_DF_J:SMA(JGL_JF,M1,1),COLORFEDCBA;
- D_DF_G:SMA(K_DF_J,M2,1),COLOR13F8F9;
- J_DF_L:2.5*K_DF_J-1.5*D_DF_G,COLORF813F9;
- RF:=REF(J_DF_L,1);
- DJ:=ABS(J_DF_L-RF);
- MM:=(HHV(DJ,120)+LLV(DJ,120))/2;
- STICKLINE(J_DF_L>RF,J_DF_L,RF,2.3,0),COLOR1388D3;
- STICKLINE(J_DF_L>RF,J_DF_L,RF,1.0,0),COLOR13AAD3;
- STICKLINE(J_DF_L<RF,J_DF_L,RF,2.3,0),COLOR338833;
- STICKLINE(J_DF_L<RF,J_DF_L,RF,1.0,0),COLOR33AA33;
- STICKLINE(J_DF_L<RF AND DJ<0.2*MM,J_DF_L+0.15*MM,RF-0.15*MM,0.1,0),COLOR33AA33;
- STICKLINE(J_DF_L>=RF AND DJ<0.2*MM,RF-0.1*MM,J_DF_L+0.1*MM,0.1,0),COLOR13AADD;
- N:=SQRT(SHORT*LONG);
- NN:=IF(N<9,9,N);
- BZC:=STD(DFC,NN);
- U:IF(KG=1,K_DF_J+2*BZC,MA(C,25600)),COLORFE9813,CROSSDOT,LINETHICK2;
- D:IF(KG=1,K_DF_J-2*BZC,MA(C,25600)),COLOR33EAEA,CROSSDOT,LINETHICK2;
- *************************************************************************************************
- MACD的微积分解析与再造
- {副图名:DF_MACD ;中文名:微分MACD;发明人及版权属于JIPGEMLING.见凌见};
- {参数:SHORT(2,200,12);LONG(2,200,26);MID(2,200,9);M(2,100,3)};
- {额外Y轴分界,值1:0.00 ;坐标线位置:自动 };
- {环球通用版};
- WXS:=(LONG-SHORT)/2;{系数};
- JGL_DF:=WXS*(EMA(CLOSE,SHORT)-REF(EMA(CLOSE,SHORT),1));{微分};
- DIF_J:EMA(JGL_DF,LONG),COLORFEDCBA,LINETHICK2;{积分};
- DEA_G:EMA(DIF_J,MID),LINETHICK2;{平滑};
- MACD_L:(DIF_J-DEA_G)*2,COLOR1133FE,COLORSTICK;
- K_DF:SMA(JGL_DF,M,1),COLOR1188FF;{以下为“类KDJ”};
- D_DF:SMA(K_DF,3,1),COLOR13FF99;
- J_DF:2.6*K_DF-1.6*D_DF,COLORAF13FA;
- RF:=REF(J_DF,1);
- STICKLINE(J_DF>=RF,J_DF,RF,2.3,0),COLOR1399FE;
- STICKLINE(J_DF>=RF,J_DF,RF,1.0,0),COLOR13DDFE;
- STICKLINE(J_DF<RF,J_DF,RF,2.3,0),COLORFF9913;
- STICKLINE(J_DF<RF,J_DF,RF,1.0,0),COLORFFDD13;
- **************************************************************************
- 修改版,提高了显示效果。
- {副图名:DF_MACD ;中文名:微分MACD;发明人及版权属于JIPGEMLING.见凌见}
- {参数:SHORT(2,200,12);LONG(2,200,26);MID(2,200,9);M(2,100,3)}
- {额外Y轴分界,值1:0.00 ;坐标线位置:自动 }
- WXS:=(LONG-SHORT)/2;{系数}
- JGL_DF:=WXS*(EMA(CLOSE,SHORT)-REF(EMA(CLOSE,SHORT),1));{微分}
- DIF_J:EMA(JGL_DF,LONG),COLOR1234AA,LINETHICK2;{积分}
- DEA_G:EMA(DIF_J,MID),COLOR338833,LINETHICK2;{平滑}
- MACD_L:(DIF_J-DEA_G)*2,COLORA9A813,COLORSTICK;
- K_DF:SMA(JGL_DF,M,1)*1,COLORFEDCBA;{以下为“类KDJ”}
- D_DF:SMA(K_DF,M,1),COLOR13F8F9;
- J_DF:3*K_DF-2*D_DF,COLORF813F9;
- {以下显示“J_DF前差值柱”,柱子太薄时显示“十”字星}
- RF:=REF(J_DF,1);
- DJ:=ABS(J_DF-RF);
- MM:=(HHV(DJ,240)+LLV(DJ,240))/2;
- STICKLINE(J_DF>RF,J_DF,RF,2.3,0),COLOR1388D3;
- STICKLINE(J_DF>RF,J_DF,RF,1.0,0),COLOR13AAD3;
- STICKLINE(J_DF<RF,J_DF,RF,2.3,0),COLOR338833;
- STICKLINE(J_DF<RF,J_DF,RF,1.0,0),COLOR33AA33;
- STICKLINE(J_DF<RF AND DJ<0.2*MM,J_DF-0.1*MM,RF+0.1*MM,0.1,0),COLOR33AA33;
- STICKLINE(J_DF>=RF AND DJ<0.2*MM,J_DF+0.1*MM,RF-0.1*MM,0.1,0),COLOR13AADD;
- 以上是位高手发现之旅
复制代码 |
|