thirtycm 發表於 10-1-12 14:16

KD指標

本帖最後由 thirtycm 於 10-1-12 02:32 PM 編輯


_SECTION_BEGIN("Stochastic %KDJ");
SetChartOptions(0,0,chartGrid20|chartGrid80);
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
Plot( StochK( periods , Ksmooth),"%K", ParamColor( "Color_K", colorCycle ), ParamStyle("Style_K") );
Plot( StochD( periods , Ksmooth, DSmooth ),"%D", ParamColor( "Color_D", colorCycle ), ParamStyle("Style_D") );
K=StochK( periods , Ksmooth);
D=StochD( periods , Ksmooth, DSmooth );
j=3*K-2*D;
Plot( j, "%J", ParamColor( "Color_J", colorCycle ), ParamStyle("Style_J") );
Plot( 20, "", colorBlue, styleline);
Plot( 80, "", colorRed,styleline   );
Plot( 50, "", colorGreen,styleline   );
_SECTION_END();

綠茶妹 發表於 10-1-12 14:53

kd指標參數(15,3,3)?

我發現我越來越看的懂AFL的程式了。哈。
程式13~15行是畫三條線,分別為20,80,50。以標出超賣超買。

thirtycm 發表於 10-1-12 14:57

(15,3,3)是預設值,在parameters可以調整的!!!

綠茶妹 發表於 10-1-17 17:56



補上圖。

順請請問一下,怎麼樣把成交量拉到下面的單一區域?
每次都和k線圖混合一區,很不容易看。

thirtycm 發表於 10-1-17 18:04



   

thirtycm 發表於 10-1-17 18:07

本帖最後由 thirtycm 於 10-1-17 06:09 PM 編輯


_SECTION_BEGIN("Bull vs Bear Volume");
SetChartBkColor(16);

C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;

green = 1; blue = 2; yellow = 3; red = 4; white = 5;
VType = IIf(ud,         
         IIf(uc, green, yellow),
       IIf(dd,
         IIf(dc, red, blue), white));

gv = IIf(VType == green, V, 0);
yv = IIf(VType == yellow, V, 0);
rv = IIf(VType == red, V, 0);
bv = IIf(VType == blue, V, 0);
uv = gv + bv; uv1 = Ref(uv, -1);
dv = rv + yv; dv1 = Ref(dv, -1);
VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );
OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);
if(CompareBullvolume AND !OscillatorOnly){
Plot(SelectedValue(MAuv), "", colorRed, styleLine);
}

CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);
if(CompareBearVolume AND !OscillatorOnly){
Plot(SelectedValue(MAdv), "", colorGreen, styleLine);
}
bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
totalvolume = Param("Show Total Volume", 1, 0, 1, 1);
bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
if(bearToFront AND !OscillatorOnly){
Plot(MAdv, "", colorGreen, styleHistogram|styleNoLabel);
}
if(bullvolume AND !OscillatorOnly){
Plot(MAuv, "Average Bull Volume", colorRed, styleHistogram|styleNoLabel);
}
if(bearvolume AND !OscillatorOnly){
Plot(MAdv, "Average Bear Volume", colorGreen, styleHistogram|styleNoLabel);
}
if(totalVolume AND !OscillatorOnly){
Plot(MAtv, "Total Volume", colorWhite, styleHistogram|styleNoLabel);
Plot(MAtv, "", colorWhite, styleLine);
}
if(bullvolume AND !OscillatorOnly){
Plot(MAuv, "", colorGreen, styleLine);
}
if(bearvolume AND !OscillatorOnly){
Plot(MAdv, "", colorRed, styleLine);
}
Plot(0, "", colorBlue, 1);
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;
convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
if(convergenceOscillator OR OscillatorOnly){
Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,
1|styleLeftAxisScale|styleNoLabel|styleThick);
Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
}
riseFallColor = IIf(rising, 14,15);
riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
if(riseFallShadows){
Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,
styleHistogram|styleArea|styleOwnScale|styleNoLabel);
}
GraphXSpace = 0.5;
_SECTION_END();
另一種成交量!白色是總量,紅色的買進的量,綠色是賣出的量!

綠茶妹 發表於 10-1-17 22:10

回復 5# thirtycm


    謝謝。這樣子清楚多了。

egglee 發表於 10-4-28 15:38

請問一下,如果我要以KD指標來選股的話,應該怎麼寫呢??

譬如說,我要挑出所以K破50的股票

謝謝各位大大!

綠茶妹 發表於 10-4-28 20:19

回復 8# egglee


    http://www.coco-in.net/viewthread.php?tid=1753

這一篇為AmiBroker的選股功能,條件改成KD就能用了。

egglee 發表於 10-4-29 12:49

回復 9# 綠茶妹


    綠茶大,那篇我爬過了,但是我不知道KD值的K值要怎麼取出來耶{:4_186:}

egglee 發表於 10-5-3 10:58

呼~~好不容易寫出來了~~

但是跑出來的數值跟看盤軟體的不一樣說

除了參數,還有那裡需要注意呢

拜託好心人指點一下吧{:4_626:}

minc 發表於 10-5-3 13:29

本帖最後由 minc 於 10-5-3 01:31 PM 編輯

_SECTION_BEGIN("k over 50");
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
K=StochK( periods , Ksmooth);
Buy = K > 50 and Ref(K, -1) < 50;
Sell = K <50 and Ref(K, -1) >50;
_SECTION_END();

當k今天大於50時,出現Buy,跌破50時,為sell

minc 發表於 10-5-3 13:52

kd指標參數(15,3,3)?

我發現我越來越看的懂AFL的程式了。哈。
程式13~15行是畫三條線,分別為20,80,50。 ...
綠茶妹 發表於 10-1-12 02:53 PM http://www.coco-in.net/images/common/back.gif

其實不一定要劃這三條線


在kd圖中,按右鍵,選parameters -> Axes & Grids -> levels -> 在20/80,50 打勾就行了,另外,show middle line 改no

綠茶妹 發表於 10-5-3 13:57

回復 13# minc


    謝謝...原來可以這樣子用啊

{:4_209:}

Sirius 發表於 11-4-15 00:10

回復 13# minc


    之前竟然沒注意到原來也可以這樣用{:8_536:}
頁: [1] 2
查看完整版本: KD指標