/*
   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_buffers 1
#property indicator_color1 Lime

#include <SSA.mqh>

extern int Lag = 20;
extern int NumComps = 2;
extern int PeriodNorm = 20;
extern int ModeMA = 0;
extern int Price = 1;
extern int N = 300;
double gda_100[];
double g_ibuf_104[];

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_104);
   ArrayResize(gda_100, N);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double ld_4;
   double l_ima_12;
   int l_ind_counted_0 = IndicatorCounted();
   SetIndexDrawBegin(0, Bars - N);
   for (int li_20 = N - 1; li_20 >= 0; li_20--) {
      l_ima_12 = iMA(NULL, 0, PeriodNorm, 0, ModeMA, Price, li_20);
      ld_4 = 3.0 * iStdDev(NULL, 0, PeriodNorm, 0, ModeMA, Price, li_20);
      if (ld_4 == 0.0) ld_4 = 0.1;
      gda_100[li_20] = (Close[li_20] - l_ima_12) / ld_4;
   }
   fastsingular(gda_100, N, Lag, NumComps, g_ibuf_104);
   int li_24 = ArrayMaximum(g_ibuf_104, 3, 1);
   int li_28 = ArrayMinimum(g_ibuf_104, 3, 1);
   if (li_24 == 2) {
      ObjectCreate("Sell" + Time[0], OBJ_ARROW, 0, Time[0], Open[0]);
      ObjectSet("Sell" + Time[0], OBJPROP_ARROWCODE, 226);
   }
   if (li_28 == 2) {
      ObjectCreate("Buy" + Time[0], OBJ_ARROW, 0, Time[0], Open[0]);
      ObjectSet("Buy" + Time[0], OBJPROP_ARROWCODE, 0);
   }
   return (0);
}