//+------------------------------------------------------------------+ //| Custom MACD.mq4 | //| Copyright ? 2004, MetaQuotes Software Corp. | //| | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Silver #property indicator_width1 1 //---- indicator parameters extern double FastEMA=12; extern double SlowEMA=26; extern double SignalEMA=9; //---- indicator buffers double Price[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_LINE,STYLE_DOT); SetIndexDrawBegin(0,FastEMA); //---- indicator buffers mapping SetIndexBuffer(0,Price); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalEMA+")"); SetIndexLabel(0,"MACD Predictor"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer for(int i=0; ipredict) {ObjectDelete("signal1"); ObjectCreate("signal1",OBJ_TREND,0,Time[0],Price[0],futureBarTime,predict); ObjectSet("signal1",OBJPROP_COLOR,Gold); ObjectSet("signal1",OBJPROP_RAY,false); ObjectSet("signal1",OBJPROP_STYLE,STYLE_DASH); predict1=ObjectGet("signal1",OBJPROP_PRICE1);} } return(0); } //+------------------------------------------------------------------+