Navigation´╝ÜHome > Content >

Trend_Bars.mq4

Time: 2017-05-15 | Download file:Trend_Bars.mq4

/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: ht tp : // Ww W . m E t a qUOt ES . nE t
   E-mail : S uppO r [email protected] M ETA q UO teS .nET
*/

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 LightSkyBlue
#property indicator_color3 Red

int Gi_unused_76 = 56;
int Gi_unused_80 = 56;
extern int RangePeriods = 120;
extern double PriceSmoothing = 0.67;
extern double IndexSmoothing = 0.9;
string Gs_104 = "Trend_Bars";
int Gi_112;
double G_ibuf_116[];
double G_ibuf_120[];
double G_ibuf_124[];
double G_ibuf_128[];
bool Gi_132 = FALSE;
bool Gi_136 = FALSE;
extern bool AlertON = TRUE;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   IndicatorBuffers(4);
   SetIndexLabel(0, "Star");
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, G_ibuf_116);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, G_ibuf_120);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(2, G_ibuf_124);
   SetIndexStyle(3, DRAW_NONE);
   SetIndexBuffer(3, G_ibuf_128);
   string Ls_0 = Gs_104;
   Ls_0 = Ls_0 + "  (rPeriods " + RangePeriods;
   Ls_0 = Ls_0 + ", pSmooth " + DoubleToStr(PriceSmoothing, 2);
   Ls_0 = Ls_0 + ", iSmooth " + DoubleToStr(IndexSmoothing, 2);
   Ls_0 = Ls_0 + ")  ";
   IndicatorShortName(Ls_0);
   SetIndexLabel(1, NULL);
   SetIndexLabel(2, NULL);
   Gi_112 = RangePeriods * 2 + 4;
   SetIndexDrawBegin(1, Gi_112);
   SetIndexDrawBegin(2, Gi_112);
   if (PriceSmoothing >= 1.0) {
      PriceSmoothing = 0.9999;
      Alert("PriceSmothing factor has to be smaller 1!");
   }
   if (PriceSmoothing < 0.0) {
      PriceSmoothing = 0;
      Alert("PriceSmothing factor mustn\'\'t be negative!");
   }
   if (IndexSmoothing >= 1.0) {
      IndexSmoothing = 0.9999;
      Alert("PriceSmothing factor has to be smaller 1!");
   }
   if (IndexSmoothing < 0.0) {
      IndexSmoothing = 0;
      Alert("PriceSmothing factor mustn\'\'t be negative!");
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   if (Bars < Gi_112) {
      Alert("Not enough Bars loaded to calculate with RangePeriods=", RangePeriods);
      return (-1);
   }
   int Li_0 = IndicatorCounted();
   if (Li_0 < 0) return (-1);
   if (Li_0 > 0) Li_0--;
   int Li_4 = Bars - Li_0;
   int Li_8 = Bars - Li_4;
   if (Li_8 < RangePeriods + 1) Li_4 = Bars - RangePeriods - 1;
   while (Li_4 >= 0) {
      f0_0(Li_4);
      Li_4--;
   }
   return (0);
}

// E52FDD187AC065FB13A2829F2B35155B
int f0_0(int Ai_0) {
   double Ld_36;
   double Ld_52;
   double low_4 = Low[iLowest(NULL, 0, MODE_LOW, RangePeriods, Ai_0)];
   double Ld_12 = High[iHighest(NULL, 0, MODE_HIGH, RangePeriods, Ai_0)];
   if (Ld_12 - low_4 < Point / 10.0) Ld_12 = low_4 + Point / 10.0;
   double Ld_20 = Ld_12 - low_4;
   double Ld_28 = (High[Ai_0] + Low[Ai_0]) / 2.0;
   if (Ld_20 != 0.0) {
      Ld_36 = (Ld_28 - low_4) / Ld_20;
      Ld_36 = 2.0 * Ld_36 - 1.0;
   }
   G_ibuf_128[Ai_0] = PriceSmoothing * (G_ibuf_128[Ai_0 + 1]) + (1.0 - PriceSmoothing) * Ld_36;
   double Ld_44 = G_ibuf_128[Ai_0];
   if (Ld_44 > 0.99) Ld_44 = 0.99;
   if (Ld_44 < -0.99) Ld_44 = -0.99;
   if (1 - Ld_44 != 0.0) Ld_52 = MathLog((Ld_44 + 1.0) / (1 - Ld_44));
   else Alert("Unauthorised state with bar number ", Bars - Ai_0);
   G_ibuf_116[Ai_0] = IndexSmoothing * (G_ibuf_116[Ai_0 + 1]) + (1.0 - IndexSmoothing) * Ld_52;
   if (Bars - Ai_0 < Gi_112) G_ibuf_116[Ai_0] = 0;
   double Ld_60 = G_ibuf_116[Ai_0];
   if (Ld_60 > 0.0) {
      G_ibuf_120[Ai_0] = Ld_60;
      G_ibuf_124[Ai_0] = 0;
   } else {
      G_ibuf_120[Ai_0] = 0;
      G_ibuf_124[Ai_0] = Ld_60;
   }
   if (G_ibuf_120[Ai_0] > 0.0 && G_ibuf_124[Ai_0 + 1] < 0.0) {
      if (Ai_0 == 1 && Gi_132 == FALSE) {
         Gi_132 = TRUE;
         Gi_136 = FALSE;
         if (AlertON) {
            Alert("Trend_Bars Crossing zero line up\n Time=", TimeToStr(TimeCurrent(), TIME_DATE), " ", TimeHour(TimeCurrent()), ":", TimeMinute(TimeCurrent()), 
            "\n Symbol=", Symbol(), " Period=", Period());
         }
      }
   } else {
      if (G_ibuf_120[Ai_0] < 0.0 && G_ibuf_124[Ai_0 + 1] > 0.0) {
         if (Ai_0 == 1 && Gi_136 == FALSE) {
            Gi_136 = TRUE;
            Gi_132 = FALSE;
            if (AlertON) {
               Alert("Trend_Bars Crossing zero line down\n Time=", TimeToStr(TimeCurrent(), TIME_DATE), " ", TimeHour(TimeCurrent()), ":", TimeMinute(TimeCurrent()), 
               "\n Symbol=", Symbol(), " Period=", Period());
            }
         }
      }
   }
   return (0);
}

Recommend