#property copyright "Copyright © 2008, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_maximum 3.0 #property indicator_buffers 3 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Yellow extern int period = 20; extern double level = 50.0; bool gi_unused_88 = FALSE; bool gi_unused_92 = FALSE; double g_ibuf_96[]; double g_ibuf_100[]; double g_ibuf_104[]; double g_ibuf_108[]; double g_ibuf_112[]; double g_ibuf_116[]; double g_ibuf_120[]; int init() { IndicatorBuffers(7); SetIndexBuffer(0, g_ibuf_96); SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1); SetIndexBuffer(1, g_ibuf_100); SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1); SetIndexDrawBegin(0, period); SetIndexDrawBegin(1, period); SetIndexBuffer(2, g_ibuf_104); SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 1); SetIndexDrawBegin(2, period); SetIndexBuffer(3, g_ibuf_108); SetIndexBuffer(4, g_ibuf_112); SetIndexBuffer(5, g_ibuf_116); SetIndexBuffer(6, g_ibuf_120); IndicatorShortName("CK Speed " + period); SetIndexLabel(0, "Trend"); SetIndexLabel(1, "Correction"); SetIndexLabel(2, "Sleep"); return (0); } int deinit() { return (0); } int start() { int li_28 = IndicatorCounted(); if (li_28 < 0) return (-1); if (li_28 > 0) li_28--; int li_24 = Bars - li_28; double ld_unused_32 = 60; double ld_unused_40 = 40; for (int li_48 = li_24 - 1; li_48 >= 0; li_48--) { g_ibuf_108[li_48] = iATR(Symbol(), 0, period, li_48); g_ibuf_112[li_48] = iStdDev(Symbol(), 0, period, 0, MODE_SMA, PRICE_MEDIAN, li_48); } for (int li_52 = li_24 - 1; li_52 >= 0; li_52--) { g_ibuf_116[li_52] = iRSIOnArray(g_ibuf_112, 0, period, li_52); g_ibuf_120[li_52] = iRSIOnArray(g_ibuf_108, 0, period, li_52); if (g_ibuf_116[li_52] >= level && g_ibuf_120[li_52] >= level) { g_ibuf_96[li_52] = 3; g_ibuf_100[li_52] = 0; g_ibuf_104[li_52] = 0; } else { if (g_ibuf_116[li_52] < level && g_ibuf_120[li_52] < level) { g_ibuf_96[li_52] = 0; g_ibuf_100[li_52] = 0; g_ibuf_104[li_52] = 1; } else { g_ibuf_96[li_52] = 0; g_ibuf_100[li_52] = 2; g_ibuf_104[li_52] = 0; } } } return (0); }