Navigation:Home > Content >

SupportingADX.mq4

Time: 2010-11-12 | Download file:SupportingADX.mq4

#property indicator_separate_window
#property indicator_levelcolor DarkOrange
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 2
#property indicator_level1 35.0

extern double n = 14.0;
extern int NumberOfBarsToUse = 500;
double gd_88;
double gd_96;
double gda_104[];
double gda_108[];
double gda_112[];
double gda_116[];
double gda_120[];
double gda_124[];
double gda_128[];
double gda_132[];
double gda_136[];
double g_ibuf_140[];

int init() {
   SetIndexBuffer(0, g_ibuf_140);
   SetIndexLabel(0, "ADX");
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexDrawBegin(0, 0);
   ArrayResize(gda_104, Bars);
   ArrayResize(gda_108, Bars);
   ArrayResize(gda_112, Bars);
   ArrayResize(gda_116, Bars);
   ArrayResize(gda_120, Bars);
   ArrayResize(gda_124, Bars);
   ArrayResize(gda_128, Bars);
   ArrayResize(gda_132, Bars);
   ArrayResize(gda_136, Bars);
   return (0);
}

int start() {
   int li_0;
   int li_4 = IndicatorCounted();
   if (li_4 < 0) return (-1);
   if (li_4 > 0) li_4--;
   if (NumberOfBarsToUse == 0) li_0 = Bars;
   else li_0 = NumberOfBarsToUse;
   for (int li_8 = li_0 - 1; li_8 > 0; li_8--) {
      gd_88 = High[li_8] - (High[li_8 + 1]);
      gd_96 = Low[li_8 + 1] - Low[li_8];
      if ((gd_88 < 0.0 && gd_96 < 0.0) || gd_88 == gd_96) {
         gda_104[li_8] = 0;
         gda_108[li_8] = 0;
      } else {
         if (gd_88 > gd_96) {
            gda_104[li_8] = gd_88;
            gda_108[li_8] = 0;
         } else {
            if (gd_88 < gd_96) {
               gda_104[li_8] = 0;
               gda_108[li_8] = gd_96;
            }
         }
      }
      gda_112[li_8] = (gda_112[li_8 + 1]) * (n - 1.0) / n + gda_104[li_8] / n;
      gda_116[li_8] = (gda_116[li_8 + 1]) * (n - 1.0) / n + gda_108[li_8] / n;
      gda_120[li_8] = MathMax(MathAbs(High[li_8] - Low[li_8]), MathAbs(High[li_8] - (Close[li_8 + 1])));
      gda_120[li_8] = MathMax(gda_120[li_8], MathAbs(Close[li_8 + 1] - Low[li_8]));
      gda_124[li_8] = (gda_124[li_8 + 1]) * (n - 1.0) / n + gda_120[li_8] / n;
      if (gda_124[li_8] > 0.0) {
         gda_128[li_8] = 100.0 * (gda_112[li_8] / gda_124[li_8]);
         gda_132[li_8] = 100.0 * (gda_116[li_8] / gda_124[li_8]);
         if (gda_128[li_8] + gda_132[li_8] > 0.0) gda_136[li_8] = 100.0 * (MathAbs(gda_128[li_8] - gda_132[li_8]) / (gda_128[li_8] + gda_132[li_8]));
         else gda_136[li_8] = 0;
      } else gda_136[li_8] = 0;
      g_ibuf_140[li_8] = (g_ibuf_140[li_8 + 1]) * (n - 1.0) / n + gda_136[li_8] / n;
   }
   return (0);
}

Recommend