Navigation:Home > Content >

WildersDMI_v3.mq4

Time: 2015-10-07 | Download file:WildersDMI_v3.mq4

#property copyright "Copyright © 2007-09, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 LightBlue
#property indicator_color2 Lime
#property indicator_color3 Tomato
#property indicator_color4 Orange
#property indicator_width1 2
#property indicator_level1 20.0

extern int MA_Length = 1;
extern int DMI_Length = 14;
extern int ADX_Length = 14;
extern int ADXR_Length = 14;
extern int ADXMode = 1;
extern int ADXRMode = 1;
extern int VisualMode = 1;
double G_ibuf_104[];
double G_ibuf_108[];
double G_ibuf_112[];
double G_ibuf_116[];
double G_ibuf_120[];
double G_ibuf_124[];
double G_ibuf_128[];
double G_ibuf_132[];
int Gi_136;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   IndicatorBuffers(8);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, G_ibuf_104);
   SetIndexBuffer(1, G_ibuf_108);
   SetIndexBuffer(2, G_ibuf_112);
   if (VisualMode == 0) {
      SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
      SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
   } else {
      SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
      SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   }
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, G_ibuf_116);
   SetIndexBuffer(4, G_ibuf_120);
   SetIndexBuffer(5, G_ibuf_124);
   SetIndexBuffer(6, G_ibuf_128);
   SetIndexBuffer(7, G_ibuf_132);
   string Ls_0 = "WildersDMI_v3(" + MA_Length + "," + DMI_Length + "," + ADX_Length + "," + ADXR_Length + ")";
   IndicatorShortName(Ls_0);
   SetIndexLabel(0, "ADX");
   if (VisualMode == 0) {
      SetIndexLabel(1, "+DI");
      SetIndexLabel(2, "-DI");
   } else {
      SetIndexLabel(1, "(+DI)-(-DI)");
      SetIndexLabel(2, "(-DI)-(+DI)");
   }
   SetIndexLabel(3, "ADXR");
   Gi_136 = DMI_Length + MA_Length + ADX_Length + ADXR_Length + 1;
   SetIndexDrawBegin(0, Gi_136);
   SetIndexDrawBegin(1, Gi_136);
   SetIndexDrawBegin(2, Gi_136);
   SetIndexDrawBegin(3, Gi_136);
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   double Ld_32;
   double Ld_40;
   double ima_56;
   double ima_64;
   double ima_72;
   double ima_80;
   double ima_88;
   double Ld_96;
   double Ld_104;
   int Li_12 = IndicatorCounted();
   double Ld_16 = 1.0 / DMI_Length;
   double Ld_24 = 1.0 / ADX_Length;
   double Ld_48 = 0;
   if (Li_12 < 0) return (-1);
   if (Li_12 < 1) {
      for (int Li_0 = 1; Li_0 <= Gi_136; Li_0++) {
         G_ibuf_108[Bars - Li_0] = 0.0;
         G_ibuf_112[Bars - Li_0] = 0.0;
         G_ibuf_104[Bars - Li_0] = 0.0;
         G_ibuf_120[Bars - Li_0] = 0.0;
         G_ibuf_124[Bars - Li_0] = 0.0;
         G_ibuf_132[Bars - Li_0] = 0.0;
         G_ibuf_128[Bars - Li_0] = 0.0;
         G_ibuf_116[Bars - Li_0] = 0.0;
      }
   }
   if (Li_12 > 0) Li_12--;
   int Li_8 = Bars - Li_12;
   for (int Li_4 = Li_8; Li_4 >= 0; Li_4--) {
      ima_56 = iMA(NULL, 0, MA_Length, 0, MODE_EMA, PRICE_HIGH, Li_4);
      ima_64 = iMA(NULL, 0, MA_Length, 0, MODE_EMA, PRICE_HIGH, Li_4 + 1);
      ima_72 = iMA(NULL, 0, MA_Length, 0, MODE_EMA, PRICE_LOW, Li_4);
      ima_80 = iMA(NULL, 0, MA_Length, 0, MODE_EMA, PRICE_LOW, Li_4 + 1);
      ima_88 = iMA(NULL, 0, MA_Length, 0, MODE_EMA, PRICE_CLOSE, Li_4 + 1);
      if (ima_56 >= ima_64) Ld_32 = (MathAbs(ima_56 - ima_64) + (ima_56 - ima_64)) / 2.0;
      else Ld_32 = 0;
      if (ima_72 <= ima_80) Ld_40 = (MathAbs(ima_80 - ima_72) + (ima_80 - ima_72)) / 2.0;
      else Ld_40 = 0;
      if (Ld_32 > Ld_40) Ld_40 = 0;
      else {
         if (Ld_32 < Ld_40) Ld_32 = 0;
         else {
            if (Ld_32 == Ld_40) {
               Ld_32 = 0;
               Ld_40 = 0;
            }
         }
      }
      Ld_48 = MathMax(ima_56 - ima_72, ima_56 - ima_88);
      Ld_48 = MathMax(Ld_48, ima_88 - ima_72);
      if (Li_4 <= Bars - MA_Length - 1 && Li_4 >= Bars - DMI_Length - MA_Length) {
         G_ibuf_120[Li_4] += Ld_32;
         G_ibuf_124[Li_4] += Ld_40;
         G_ibuf_128[Li_4] += Ld_48;
         if (Li_4 == Bars - DMI_Length - MA_Length) {
            G_ibuf_120[Li_4] = Ld_32 / DMI_Length;
            G_ibuf_124[Li_4] = Ld_40 / DMI_Length;
            G_ibuf_128[Li_4] = Ld_48 / DMI_Length;
         }
      } else {
         if (Li_4 < Bars - DMI_Length - MA_Length) {
            G_ibuf_120[Li_4] = G_ibuf_120[Li_4 + 1] + Ld_16 * (Ld_32 - (G_ibuf_120[Li_4 + 1]));
            G_ibuf_124[Li_4] = G_ibuf_124[Li_4 + 1] + Ld_16 * (Ld_40 - (G_ibuf_124[Li_4 + 1]));
            G_ibuf_128[Li_4] = G_ibuf_128[Li_4 + 1] + Ld_16 * (Ld_48 - (G_ibuf_128[Li_4 + 1]));
            if (G_ibuf_128[Li_4] != 0.0) {
               Ld_96 = 100.0 * G_ibuf_120[Li_4] / G_ibuf_128[Li_4];
               Ld_104 = 100.0 * G_ibuf_124[Li_4] / G_ibuf_128[Li_4];
            } else {
               Ld_96 = 0;
               Ld_104 = 0;
            }
            if (ADXMode > 0) {
               if (Ld_96 + Ld_104 != 0.0) G_ibuf_132[Li_4] = 100.0 * MathAbs(Ld_96 - Ld_104) / (Ld_96 + Ld_104);
               else G_ibuf_132[Li_4] = 0;
               if (ADXMode == 1 && Li_4 < Bars - DMI_Length - MA_Length - ADX_Length) G_ibuf_104[Li_4] = G_ibuf_104[Li_4 + 1] + Ld_24 * (G_ibuf_132[Li_4] - (G_ibuf_104[Li_4 + 1]));
               else
                  if (ADXMode == 2) G_ibuf_104[Li_4] = G_ibuf_132[Li_4];
               if (ADXRMode > 0 && Li_4 < Bars - Gi_136) G_ibuf_116[Li_4] = (G_ibuf_104[Li_4] + (G_ibuf_104[Li_4 + ADXR_Length])) / 2.0;
            }
            if (VisualMode == 1) {
               if (Ld_96 > Ld_104) {
                  G_ibuf_108[Li_4] = Ld_96 - Ld_104;
                  G_ibuf_112[Li_4] = 0;
                  continue;
               }
               G_ibuf_112[Li_4] = Ld_104 - Ld_96;
               G_ibuf_108[Li_4] = 0;
               continue;
            }
            G_ibuf_108[Li_4] = Ld_96;
            G_ibuf_112[Li_4] = Ld_104;
         }
      }
   }
   return (0);
}

Recommend