/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/

#property indicator_separate_window
#property indicator_minimum -1.0
#property indicator_maximum 1.0
#property indicator_levelcolor DarkSlateGray
#property indicator_buffers 8
#property indicator_color1 LimeGreen
#property indicator_color2 OrangeRed
#property indicator_color3 Black
#property indicator_color4 Yellow
#property indicator_color5 LimeGreen
#property indicator_color6 OrangeRed
#property indicator_color7 Black
#property indicator_color8 Yellow

extern int TimeFrame1 = 0;
extern int TimeFrame2 = 0;
extern int RSI1Period = 10;
extern int RSI2Period = 60;
extern int RSIPrice = 0;
extern int MA1Signal = 50;
extern int MA2Signal = 300;
extern int MA1Mode = 2;
extern int MA2Mode = 3;
extern bool ZeroLineFilter = TRUE;
extern double RSIHistoModify = 1.5;
double g_ibuf_124[];
double g_ibuf_128[];
double g_ibuf_132[];
double g_ibuf_136[];
double g_ibuf_140[];
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];

int init() {
   if (TimeFrame2 == 0) TimeFrame2 = nextPeriod(TimeFrame1);
   IndicatorShortName("Rumi RSI Signal-mtf   T1=" + TimeFrame1 + ", T2=" + TimeFrame2);
   IndicatorBuffers(8);
   SetIndexStyle(0, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(0, 167);
   SetIndexBuffer(0, g_ibuf_124);
   SetIndexStyle(1, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(1, 167);
   SetIndexBuffer(1, g_ibuf_128);
   SetIndexStyle(2, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(2, 167);
   SetIndexBuffer(2, g_ibuf_132);
   SetIndexStyle(3, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(3, 167);
   SetIndexBuffer(3, g_ibuf_136);
   SetIndexStyle(4, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(4, 167);
   SetIndexBuffer(4, g_ibuf_140);
   SetIndexStyle(5, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(5, 167);
   SetIndexBuffer(5, g_ibuf_144);
   SetIndexStyle(6, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(6, 167);
   SetIndexBuffer(6, g_ibuf_148);
   SetIndexStyle(7, DRAW_ARROW, STYLE_DASHDOT, 3);
   SetIndexArrow(7, 167);
   SetIndexBuffer(7, g_ibuf_152);
   SetIndexEmptyValue(0, 0);
   SetIndexEmptyValue(1, 0);
   SetIndexEmptyValue(2, 0);
   SetIndexEmptyValue(3, 0);
   SetIndexEmptyValue(4, 0);
   SetIndexEmptyValue(5, 0);
   SetIndexEmptyValue(6, 0);
   SetIndexEmptyValue(7, 0);
   return (0);
}

int deinit() {
   return (0);
}

int nextPeriod(int ai_0) {
   if (ai_0 > 43200) return (0);
   if (ai_0 >= 10080) return (43200);
   if (ai_0 >= 1440) return (10080);
   if (ai_0 >= 240) return (1440);
   if (ai_0 >= 60) return (240);
   if (ai_0 >= 15) return (60);
   if (ai_0 >= 5) return (15);
   if (ai_0 >= 1) return (5);
   if (ai_0 == 1) return (1);
   if (ai_0 == 0) return (nextPeriod(Period()));
   return (0);
}

int start() {
   int l_icustom_12;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   int li_8 = Bars - 31;
   if (li_0 >= 31) li_8 = Bars - li_0 - 1;
   for (int li_4 = li_8; li_4 >= 0; li_4--) {
      l_icustom_12 = iCustom(NULL, TimeFrame1, "RumiRSISignal-MTF-Fnc", 0, RSI1Period, RSI2Period, RSIPrice, MA1Signal, MA2Signal, MA1Mode, MA2Mode, ZeroLineFilter, RSIHistoModify, 0, 1, iBarShift(NULL, TimeFrame1, Time[li_4], FALSE));
      if (l_icustom_12 == 1) {
         g_ibuf_124[li_4] = 0.2;
         g_ibuf_128[li_4] = 0;
         g_ibuf_132[li_4] = 0;
         g_ibuf_136[li_4] = 0;
      } else {
         if (l_icustom_12 == -1) {
            g_ibuf_128[li_4] = 0.2;
            g_ibuf_124[li_4] = 0;
            g_ibuf_132[li_4] = 0;
            g_ibuf_136[li_4] = 0;
         } else {
            if (l_icustom_12 == 0) {
               g_ibuf_132[li_4] = 0.2;
               g_ibuf_124[li_4] = 0;
               g_ibuf_128[li_4] = 0;
               g_ibuf_136[li_4] = 0;
            } else {
               g_ibuf_136[li_4] = 0.2;
               g_ibuf_124[li_4] = 0;
               g_ibuf_128[li_4] = 0;
               g_ibuf_132[li_4] = 0;
            }
         }
      }
      if (TimeFrame2 >= 0) {
         l_icustom_12 = iCustom(NULL, TimeFrame2, "RumiRSISignal-MTF-Fnc", 0, RSI1Period, RSI2Period, RSIPrice, MA1Signal, MA2Signal, MA1Mode, MA2Mode, ZeroLineFilter, RSIHistoModify, 0, 1, iBarShift(NULL, TimeFrame2, Time[li_4], FALSE));
         if (l_icustom_12 == 1) {
            g_ibuf_140[li_4] = -0.5;
            g_ibuf_144[li_4] = 0;
            g_ibuf_148[li_4] = 0;
            g_ibuf_152[li_4] = 0;
         } else {
            if (l_icustom_12 == -1) {
               g_ibuf_144[li_4] = -0.5;
               g_ibuf_140[li_4] = 0;
               g_ibuf_148[li_4] = 0;
               g_ibuf_152[li_4] = 0;
            } else {
               if (l_icustom_12 == 0) {
                  g_ibuf_148[li_4] = -0.5;
                  g_ibuf_140[li_4] = 0;
                  g_ibuf_144[li_4] = 0;
                  g_ibuf_152[li_4] = 0;
               } else {
                  g_ibuf_152[li_4] = -0.5;
                  g_ibuf_140[li_4] = 0;
                  g_ibuf_144[li_4] = 0;
                  g_ibuf_148[li_4] = 0;
               }
            }
         }
      }
   }
   return (0);
}
