相關標簽:
{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;