//*******************************************************************//
#property description "Платим за каждую сделку Forex из 30+ брокеров"
#property description "Перед Вами новый инструмент трейдера ,Сервис, осуществляющий мгновенный возврат до 95% от спреда (рибейт) более чем в 30 самых надежных и проверенных брокеров с мировыми именами."
#property description  "http://fxcash.ru/?id=X53657"
#property description  "http://fxcash.ru/?id=fxgeneral"
#property copyright "http://fxcash.ru/?id=_spred    "
#property link "http://www.roboforex.ru/?a=bywt "
//*******************************************************************//

#property indicator_separate_window
#property indicator_minimum -0.5
#property indicator_maximum 9.0
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Black
#property indicator_color4 Blue
#property indicator_color5 Red
#property indicator_color6 Black
#property indicator_color7 Blue
#property indicator_color8 Red

extern int HigherPeriod = 60;
extern int Higher2ndPeriod = 240;
extern int StochKPeriod = 8;
extern int StochDPeriod = 3;
extern int StochSlowing = 3;
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[];
double G_ibuf_124[];

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, G_ibuf_96);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, G_ibuf_100);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(2, G_ibuf_104);
   SetIndexStyle(3, DRAW_HISTOGRAM);
   SetIndexBuffer(3, G_ibuf_108);
   SetIndexStyle(4, DRAW_HISTOGRAM);
   SetIndexBuffer(4, G_ibuf_112);
   SetIndexStyle(5, DRAW_HISTOGRAM);
   SetIndexBuffer(5, G_ibuf_116);
   SetIndexStyle(6, DRAW_HISTOGRAM);
   SetIndexBuffer(6, G_ibuf_120);
   SetIndexStyle(7, DRAW_HISTOGRAM);
   SetIndexBuffer(7, G_ibuf_124);
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int shift_8;
   double istochastic_12;
   double istochastic_20;
   int Li_4 = IndicatorCounted();
   if (Li_4 < 0) return (-1);
   if (Li_4 > 0) Li_4--;
   int Li_0 = Bars - Li_4;
   if (Li_0 < 15) Li_0 = 15;
   for (int shift_28 = 0; shift_28 < Li_0; shift_28++) {
      istochastic_20 = iStochastic(Symbol(), Period(), StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_SIGNAL, shift_28);
      istochastic_12 = iStochastic(Symbol(), Period(), StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_MAIN, shift_28);
      if (istochastic_20 < istochastic_12) {
         G_ibuf_96[shift_28] = 8;
         G_ibuf_100[shift_28] = 0;
      } else {
         G_ibuf_96[shift_28] = 0;
         G_ibuf_100[shift_28] = 8;
      }
      G_ibuf_104[shift_28] = 6;
      shift_8 = iBarShift(Symbol(), HigherPeriod, Time[shift_28]);
      istochastic_20 = iStochastic(Symbol(), HigherPeriod, StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_SIGNAL, shift_8);
      istochastic_12 = iStochastic(Symbol(), HigherPeriod, StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_MAIN, shift_8);
      if (istochastic_20 < istochastic_12) {
         G_ibuf_108[shift_28] = 5;
         G_ibuf_112[shift_28] = 0;
      } else {
         G_ibuf_108[shift_28] = 0;
         G_ibuf_112[shift_28] = 5;
      }
      G_ibuf_116[shift_28] = 3;
      shift_8 = iBarShift(Symbol(), Higher2ndPeriod, Time[shift_28]);
      istochastic_20 = iStochastic(Symbol(), Higher2ndPeriod, StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_SIGNAL, shift_8);
      istochastic_12 = iStochastic(Symbol(), Higher2ndPeriod, StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, 0, MODE_MAIN, shift_8);
      if (istochastic_20 < istochastic_12) {
         G_ibuf_120[shift_28] = 2;
         G_ibuf_124[shift_28] = 0;
      } else {
         G_ibuf_120[shift_28] = 0;
         G_ibuf_124[shift_28] = 2;
      }
   }
   return (0);
}
