Navigation´╝ÜHome > Content >

Snake~.mq4

Time: 2016-05-07 | Download file:Snake~.mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.445.5 [-]
   Website: https://purebeam.biz
   E-mail : [email protected]
*/

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow

extern int Snake_HalfCycle = 5;
double g_ibuf_80[];
double gd_84;
double gd_92;
double gd_100;
double gd_108;
int gi_116;

int init() {
   gi_116 = 2 * Snake_HalfCycle + 1;
   int li_0 = gi_116 + 1;
   SetIndexDrawBegin(0, li_0);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexStyle(0, DRAW_LINE);
   return (0);
}

int start() {
   int li_4 = 0;
   if (Bars <= 150) return (0);
   if (Snake_HalfCycle < 3) Snake_HalfCycle = 3;
   li_4 = IndicatorCounted();
   if (li_4 < 0) return (-1);
   if (li_4 > 0) li_4--;
   int li_0 = Bars - li_4 - 1;
   if (li_0 > Bars - Snake_HalfCycle - 1) li_0 = Bars - Snake_HalfCycle - 1;
   f0_2(li_0);
   return (0);
}

void f0_2(int ai_0) {
   if (ai_0 <= Snake_HalfCycle + 1) ai_0 = Snake_HalfCycle + 2;
   g_ibuf_80[ai_0] = f0_1(ai_0);
   for (ai_0--; ai_0 >= Snake_HalfCycle; ai_0--) g_ibuf_80[ai_0] = f0_3(ai_0);
   while (ai_0 > 0) {
      g_ibuf_80[ai_0] = f0_1(ai_0);
      ai_0--;
   }
   if (ai_0 == 0) g_ibuf_80[0] = iMA(NULL, 0, Snake_HalfCycle, 0, MODE_LWMA, PRICE_TYPICAL, 0);
}

double f0_0(int ai_0) {
   return ((2.0 * Close[ai_0] + High[ai_0] + Low[ai_0]) / 4.0);
}

double f0_1(int ai_0) {
   int count_4;
   int li_8;
   gd_84 = 0.0;
   gd_92 = 0.0;
   if (ai_0 < Snake_HalfCycle) {
      count_4 = 0;
      for (int li_12 = ai_0 + Snake_HalfCycle; li_12 >= ai_0; li_12--) {
         count_4++;
         gd_84 += count_4 * f0_0(li_12);
         gd_92 += count_4;
      }
      while (li_12 >= 0) {
         count_4--;
         gd_84 += count_4 * f0_0(li_12);
         gd_92 += count_4;
         li_12--;
      }
   } else {
      gd_100 = 0.0;
      gd_108 = 0.0;
      li_8 = ai_0 - Snake_HalfCycle;
      count_4 = ai_0 + Snake_HalfCycle;
      for (li_12 = 1; li_12 <= Snake_HalfCycle; li_12++) {
         gd_84 += li_12 * (f0_0(count_4) + f0_0(li_8));
         gd_92 += li_12 * 2;
         gd_100 += f0_0(count_4);
         gd_108 += f0_0(li_8);
         li_8++;
         count_4--;
      }
      gd_84 += (Snake_HalfCycle + 1) * f0_0(ai_0);
      gd_92 = gd_92 + Snake_HalfCycle + 1.0;
      gd_100 += f0_0(ai_0);
   }
   return (gd_84 / gd_92);
}

double f0_3(int ai_0) {
   gd_108 += f0_0(ai_0 - Snake_HalfCycle);
   gd_84 = gd_84 - gd_100 + gd_108;
   gd_100 = gd_100 - f0_0(ai_0 + Snake_HalfCycle + 1) + f0_0(ai_0);
   gd_108 -= f0_0(ai_0);
   return (gd_84 / gd_92);
}

Recommend