macd ema java源码_彭乙武:MT4指标源码 MACD版本

MT4盘 MACD清晰版!大家可以看看

a4c26d1e5885305701be709a3d33442f.png

//+------------------------------------------------------------------+

//|  www.forexstar.com.cn.mq4

|

//|  Copyright ?2006,

www.forexstar.com.cn |

//|  http://www.forexstar.com.cn |

//+------------------------------------------------------------------+

#property copyright "Copyright ?2006,

www.forexstar.com.cn"

#property link  "http://www.forexstar.com.cn"

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Black

#property indicator_color2 Lime

#property indicator_color3 Red

#property indicator_color4 Blue

//---- input parameters

extern int  FastEMA=12;

extern int  SlowEMA=26;

extern int  SignalSMA=9;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function

|

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_LINE);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(2,DRAW_HISTOGRAM);

SetIndexBuffer(2,ExtMapBuffer3);

SetIndexStyle(3,DRAW_HISTOGRAM);

SetIndexBuffer(3,ExtMapBuffer4);

//----

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");

SetIndexLabel(0,"DIFF");

SetIndexLabel(1,"DEA");

SetIndexLabel(2,"MACD");

//---- initialization done

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function

|

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function  |

//+------------------------------------------------------------------+

int start()

{

int  counted_bars=IndicatorCounted();

//----

int limit;

//---- check for possible errors

if(counted_bars<0)

return(-1);

//---- last counted bar will be recounted

if(counted_bars>0)

counted_bars--;

limit=Bars-counted_bars;

//---- DIF counted in the 1-st buffer

for(int i=0; i

ExtMapBuffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

//---- MACD line counted in the 2-nd buffer

for(i=0; i

ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer1,Bars,SignalSMA,0,MODE_EMA,i);

//---- BAR line counted in the 3,4 buffer

for(i=0; i

{

if(ExtMapBuffer1[i] > ExtMapBuffer2[i])

{

ExtMapBuffer3[i] =

2*(ExtMapBuffer1[i]-ExtMapBuffer2[i]);

ExtMapBuffer4[i] = 0;

}

else

{

ExtMapBuffer4[i] =

2*(ExtMapBuffer1[i]-ExtMapBuffer2[i]);

ExtMapBuffer3[i] = 0;

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值