#property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 White #property indicator_color2 White #property indicator_color3 White #property indicator_color4 Red #property indicator_color5 Yellow double g_ibuf_76[]; double g_ibuf_80[]; double g_ibuf_84[]; double g_ibuf_88[]; double g_ibuf_92[]; extern int period = 10; extern double fib = 2.61; int init() { SetIndexStyle(0, DRAW_LINE); SetIndexShift(0, 0); SetIndexDrawBegin(0, 0); SetIndexBuffer(0, g_ibuf_76); SetIndexStyle(1, DRAW_LINE); SetIndexShift(1, 0); SetIndexDrawBegin(1, 0); SetIndexBuffer(1, g_ibuf_80); SetIndexStyle(2, DRAW_LINE); SetIndexShift(2, 0); SetIndexDrawBegin(2, 0); SetIndexBuffer(2, g_ibuf_84); SetIndexStyle(3, DRAW_LINE); SetIndexShift(3, 0); SetIndexDrawBegin(3, 0); SetIndexBuffer(3, g_ibuf_88); SetIndexStyle(4, DRAW_LINE); SetIndexShift(4, 0); SetIndexDrawBegin(4, 0); SetIndexBuffer(4, g_ibuf_92); return (0); } int deinit() { return (0); } int start() { double ld_8; int li_4 = IndicatorCounted(); if (li_4 < 0) return (-1); if (li_4 > 0) li_4--; int li_0 = Bars - li_4; for (int li_16 = 0; li_16 < li_0; li_16++) { g_ibuf_80[li_16] = iMA(NULL, 0, period, 0, MODE_SMA, PRICE_MEDIAN, li_16); ld_8 = findAvg(period, li_16); g_ibuf_76[li_16] = g_ibuf_80[li_16] + ld_8; g_ibuf_84[li_16] = g_ibuf_80[li_16] - ld_8; g_ibuf_88[li_16] = g_ibuf_80[li_16] + ld_8 * fib; g_ibuf_92[li_16] = g_ibuf_80[li_16] - ld_8 * fib; } return (0); } double findAvg(int ai_0, int ai_4) { double ld_ret_8 = 0; for (int li_16 = ai_4; li_16 < ai_4 + ai_0; li_16++) ld_ret_8 += MathMax(High[li_16], Close[li_16 + 1]) - MathMin(Low[li_16], Close[li_16 + 1]); ld_ret_8 /= ai_0; return (ld_ret_8); }