MACD(夹心型)指标(附送源码)
-
相关简介:我叫:MACD 指数平滑异同平均线(夹心型)指标 你叫:MACD 指数平滑异同平均线(顶底型)指标 他叫:MACD 指数平滑异同平均线(超买超卖型)指标 . 感谢悄悄冰虾提供的源码!同时也感谢下面这位人仕提供的完整源码(见附件1)!这指标是根据两位提供的源码的意思仿写的,请懂该指标的人仕看看是否正确?多谢先! C/C++ Code 复制内容到剪贴板 {参数自行设置:(12,26,9)} DIFF:EMA(CLOSE, SHORT )-EMA(CLOSE, LONG ); DEA:E
-
文章来源:择股网作者:股海网发布时间:2009-10-14浏览次数:
我叫:MACD 指数平滑异同平均线(夹心型)指标
你叫:MACD 指数平滑异同平均线(顶底型)指标
他叫:MACD 指数平滑异同平均线(超买超卖型)指标
. 感谢悄悄冰虾提供的源码!同时也感谢下面这位人仕提供的完整源码(见附件1)!这指标是根据两位提供的源码的意思仿写的,请懂该指标的人仕看看是否正确?多谢先!
C/C++ Code复制内容到剪贴板
- {参数自行设置:(12,26,9)}
- DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
- DEA : EMA(DIFF,M);
- MACD : 2*(DIFF-DEA), COLORSTICK;
- VAR1:=HHV(DEA,53);
- VAR2:=LLV(DEA,55);
- VAR3:=DEA-(DIFF-DEA);
- UP:IF(DIFF>VAR1 AND DEA=VAR1,MAX(LLV(VAR1,10),VAR3),VAR1),COLORbb0000,LINETHICK2;
- DN:IF(DIFF<VAR2 AND DEA=VAR2,MIN(HHV(VAR2,10),VAR3),VAR2),COLORaa00aa,LINETHICK2;
- 【附件1】:MACD(**型)源码
- //MACD
- r1 = Param( "Fast avg", 12, 2, 200, 1 );
- r2 = Param( "Slow avg", 26, 2, 200, 1 );
- r3 = Param( "Signal avg", 9, 2, 200, 1 );
- ml = MACD(r1, r2);
- Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorBlack ), ParamStyle("MACD style") );
- Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
- Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorRed ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
- //DZBUY
- Left=-10000; Right=10000;count=0;j=0;j1=0;Prob=0;eps=0.001;yval=0;k=0;delt=0;
- BNumb=35775;BNumb1=30208;InitVal=0.12;N=70;value1=0;
- for (bar=1; bar< BarCount;bar++)
- {value5=ml[bar];
- BarNumber=bar;
- if (BarNumber>N)
- {
- for (k=0;k<N-1;k++)
- {
- return1[k]=return1[k+1];
- }
- return1[N-1]=value5;
- }
- else
- {
- j=BarNumber-1;
- return1[j]=value5;
- }
- if (BarNumber>=N)
- {
- yval=(left+right)/2;
- delt=yval-left;
- while((delt>0.005) AND (value1<50))
- {
- value1=value1+1;
- for (j1=0; j1<N;j1++)
- {
- if (return1[j1]<yval)
- {
- count=count+1;
- }
- }
- Prob=count/N;
- if (Prob>InitVal+eps)
- {
- right=yval;
- yval=(yval+left)/2;
- }
- if (Prob<InitVal-eps)
- {
- left=yval;
- yval=(yval+right)/2;
- }
- if ((Prob<InitVal+eps) AND (Prob>InitVal-eps))
- {
- right=yval;
- yval=(yval+left)/2;
- }
- delt=yval-left;
- count=0;
- }
- if (value1!=500 )
- {
- value1=0;
- }
- DZBuy[bar]=yval;
- Right=10000;
- Left=-10000;
- Prob=0;
- }
- }
- Plot(DZBUY,"DZBUY",colorGreen, styleLine | styleThick);
- //DZSELL
- Left=-10000; Right=10000;count=0;j=0;j1=0;Prob=0;eps=0.001;yval=0;k=0;delt=0;
- BNumb=35775;BNumb1=30208;InitVal=0.12;N=70;value1=0;
- for (bar=1; bar< BarCount;bar++)
- {value5=ml[bar];
- BarNumber=bar;
- if (BarNumber>N)
- {
- for (k=0;k<N-1;k++)
- {
- return1[k]=return1[k+1];
- }
- return1[N-1]=value5;
- }
- else
- {
- j=BarNumber-1;
- return1[j]=value5;
- }
- if (BarNumber>=N)
- {
- yval=(left+right)/2;
- delt=right-yval;
- while((delt>0.005) AND (value1<50))
- {
- value1=value1+1;
- for (j1=0; j1<N;j1++)
- {
- if (return1[j1]>yval)
- {
- count=count+1;
- }
- }
- Prob=count/N;
- if (Prob>InitVal+eps)
- {
- left=yval;
- yval=(yval+right)/2;
- }
- if (Prob<InitVal-eps)
- {
- right=yval;
- yval=(yval+left)/2;
- }
- if ((Prob<InitVal+eps) AND (Prob>InitVal-eps))
- {
- left=yval;
- yval=(yval+right)/2;
- }
- delt=right-yval;
- count=0;
- }
- if (value1!=500 )
- {
- value1=0;
- }
- DZSELL[bar]=yval;
- Right=10000;
- Left=-10000;
- Prob=0;
- }
- }
- Plot(DZSELL,"DZSELL",colorRed, styleLine | styleThick);
上一篇:筹码攻击
下一篇:条件选股公式;成功率非常高