Navigation:Home > Content >

Bands_(2).mq4

Time: 2014-09-26 | Download file:Bands_(2).mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen

extern int BandsPeriod = 20;
extern int BandsShift = 0;
extern double BandsDeviations = 2.0;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, g_ibuf_96);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, g_ibuf_100);
   SetIndexDrawBegin(0, BandsPeriod + BandsShift);
   SetIndexDrawBegin(1, BandsPeriod + BandsShift);
   SetIndexDrawBegin(2, BandsPeriod + BandsShift);
   return (0);
}

int start() {
   int li_4;
   double ld_12;
   double ld_20;
   double ld_28;
   double ld_36;
   int l_ind_counted_8 = IndicatorCounted();
   if (Bars <= BandsPeriod) return (0);
   if (l_ind_counted_8 < 1) {
      for (int li_0 = 1; li_0 <= BandsPeriod; li_0++) {
         g_ibuf_92[Bars - li_0] = EMPTY_VALUE;
         g_ibuf_96[Bars - li_0] = EMPTY_VALUE;
         g_ibuf_100[Bars - li_0] = EMPTY_VALUE;
      }
   }
   int li_44 = Bars - l_ind_counted_8;
   if (l_ind_counted_8 > 0) li_44++;
   for (li_0 = 0; li_0 < li_44; li_0++) g_ibuf_92[li_0] = iMA(NULL, 0, BandsPeriod, BandsShift, MODE_SMA, PRICE_CLOSE, li_0);
   li_0 = Bars - BandsPeriod + 1;
   if (l_ind_counted_8 > BandsPeriod - 1) li_0 = Bars - l_ind_counted_8 - 1;
   while (li_0 >= 0) {
      ld_20 = 0.0;
      li_4 = li_0 + BandsPeriod - 1;
      ld_28 = g_ibuf_92[li_0];
      while (li_4 >= li_0) {
         ld_36 = Close[li_4] - ld_28;
         ld_20 += ld_36 * ld_36;
         li_4--;
      }
      ld_12 = BandsDeviations * MathSqrt(ld_20 / BandsPeriod);
      g_ibuf_96[li_0] = ld_28 + ld_12;
      g_ibuf_100[li_0] = ld_28 - ld_12;
      li_0--;
   }
   return (0);
}

Recommend