/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: HtTP://w wW .mE T aq uOT ES. NeT
   E-mail :  SUPp o RT @ mE t A QuOt eS. nE T
*/
#property copyright "RenkoScalp_System"
#property link      "wrt0306@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 OrangeRed
#property indicator_color3 Lime
#property indicator_color4 White

extern int MA_Period = 3;
extern int MA_Method = 2;
extern int UseSignal = 1;
extern int AlertMode = 1;
extern int WarningMode = 1;
extern int UpArrowCode = 250;
extern int DownArrowCode = 250;
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[];
int Gi_132 = 0;
bool Gi_136 = FALSE;
bool Gi_140 = FALSE;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   string Ls_unused_0;
   IndicatorBuffers(7);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, UpArrowCode);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, DownArrowCode);
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
   if (MA_Period < 2) MA_Period = 10;
   int Li_8 = MA_Period - 1;
   IndicatorShortName("RenkoScalp_Signal (" + MA_Period + ")");
   SetIndexLabel(0, "UpTrendEnv");
   SetIndexLabel(1, "DnTrendEnv");
   SetIndexLabel(2, "UpSignal");
   SetIndexLabel(3, "DnSignal");
   SetIndexDrawBegin(0, Li_8);
   SetIndexDrawBegin(1, Li_8);
   SetIndexDrawBegin(2, Li_8);
   SetIndexDrawBegin(3, Li_8);
   SetIndexBuffer(0, G_ibuf_104);
   SetIndexBuffer(1, G_ibuf_108);
   SetIndexBuffer(2, G_ibuf_112);
   SetIndexBuffer(3, G_ibuf_116);
   SetIndexBuffer(4, G_ibuf_120);
   SetIndexBuffer(5, G_ibuf_124);
   SetIndexBuffer(6, G_ibuf_128);
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   string Ls_0;
   if (Bars <= MA_Period) return (0);
   Gi_132 = IndicatorCounted();
   if (Gi_132 < 0) return (-1);
   if (Gi_132 > 0) Gi_132--;
   int Li_8 = Bars - Gi_132;
   for (int Li_12 = Li_8; Li_12 >= 0; Li_12--) {
      G_ibuf_120[Li_12] = iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_HIGH, Li_12);
      G_ibuf_124[Li_12] = iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_LOW, Li_12);
      G_ibuf_128[Li_12] = G_ibuf_128[Li_12 + 1];
      if (Close[Li_12] > G_ibuf_120[Li_12 + 1]) G_ibuf_128[Li_12] = 1;
      if (Close[Li_12] < G_ibuf_124[Li_12 + 1]) G_ibuf_128[Li_12] = -1;
      if (G_ibuf_128[Li_12] > 0.0) {
         if (G_ibuf_124[Li_12] < G_ibuf_124[Li_12 + 1]) G_ibuf_124[Li_12] = G_ibuf_124[Li_12 + 1];
         G_ibuf_104[Li_12] = G_ibuf_124[Li_12];
         if (UseSignal > 0) {
            if (G_ibuf_128[Li_12 + 1] < 0.0) {
               G_ibuf_112[Li_12] = G_ibuf_124[Li_12];
               if (WarningMode > 0 && Li_12 == 0) PlaySound("alert2.wav");
            } else G_ibuf_112[Li_12] = EMPTY_VALUE;
         }
         G_ibuf_108[Li_12] = EMPTY_VALUE;
         G_ibuf_116[Li_12] = EMPTY_VALUE;
      } else {
         if (G_ibuf_120[Li_12] > G_ibuf_120[Li_12 + 1]) G_ibuf_120[Li_12] = G_ibuf_120[Li_12 + 1];
         G_ibuf_108[Li_12] = G_ibuf_120[Li_12];
         if (UseSignal > 0) {
            if (G_ibuf_128[Li_12 + 1] > 0.0) {
               G_ibuf_116[Li_12] = G_ibuf_120[Li_12];
               if (WarningMode > 0 && Li_12 == 0) PlaySound("alert2.wav");
            } else G_ibuf_116[Li_12] = EMPTY_VALUE;
         }
         G_ibuf_104[Li_12] = EMPTY_VALUE;
         G_ibuf_112[Li_12] = EMPTY_VALUE;
      }
   }
   if (G_ibuf_128[2] < 0.0 && G_ibuf_128[1] > 0.0 && Volume[0] > 1.0 && (!Gi_136)) {
      Ls_0 = " " + Symbol() + " M" + Period() + ":  -  Signal  CONFIRMED!!    -  BUY  - ";
      if (AlertMode > 0) Alert(Ls_0);
      Gi_136 = TRUE;
      Gi_140 = FALSE;
   }
   if (G_ibuf_128[2] > 0.0 && G_ibuf_128[1] < 0.0 && Volume[0] > 1.0 && (!Gi_140)) {
      Ls_0 = " " + Symbol() + " M" + Period() + ":  -  Signal  CONFIRMED!!    -  SELL  - ";
      if (AlertMode > 0) Alert(Ls_0);
      Gi_140 = TRUE;
      Gi_136 = FALSE;
   }
   return (0);
}
