#property copyright "Aleksandr Pak,Almaty, 2006" #property link "ekr-ap@mail.ru" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Silver extern int FastEMA = 12; extern int SlowEMA = 26; extern int SignalSMA = 9; double g_ibuf_88[]; double g_ibuf_92[]; double g_ibuf_96[]; double g_ibuf_100[]; int init() { IndicatorBuffers(4); SetIndexBuffer(0, g_ibuf_92); SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexBuffer(1, g_ibuf_96); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexBuffer(2, g_ibuf_100); SetIndexStyle(2, DRAW_LINE); SetIndexDrawBegin(2, SignalSMA); SetIndexBuffer(3, g_ibuf_88); SetIndexStyle(3, DRAW_NONE); SetIndexLabel(0, "Buffer 0"); SetIndexLabel(1, "Buffer 1"); SetIndexLabel(2, "Signal"); IndicatorDigits(Digits + 3); IndicatorShortName("GreatTrader MACD_color(" + FastEMA + "," + SlowEMA + "," + SignalSMA + ")"); return (0); } int start() { int li_8 = IndicatorCounted(); if (li_8 > 0) li_8--; int li_0 = Bars - li_8; for (int li_4 = 0; li_4 < li_0; li_4++) g_ibuf_88[li_4] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, li_4) - iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, li_4); for (li_4 = 0; li_4 < li_0; li_4++) { g_ibuf_96[li_4] = 0.0; g_ibuf_92[li_4] = 0.0; if (li_4 >= 1) { if (g_ibuf_88[li_4 + 1] - g_ibuf_88[li_4] >= 0.0) g_ibuf_96[li_4] = g_ibuf_88[li_4]; else g_ibuf_92[li_4] = g_ibuf_88[li_4]; } } for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_100[li_4] = iMAOnArray(g_ibuf_88, Bars, SignalSMA, 0, MODE_SMA, li_4); return (0); }