/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2009 David J. Lin"
#property link      "www.formula4xm.com"

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 2.0
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

string gs_unused_76 = "For Timeframe enter values 1(M1)";
string gs_unused_84 = "5(M5),15(M15),30(M30),60(H1),";
string gs_unused_92 = "240(H4),1440(D1),10080(W1)";
string gs_unused_100 = " or 43200(MN1)";
string gs_unused_108 = "Enter value for Moving Average";
string gs_unused_116 = "method 1(EMA) or 0(SMA)";
int g_timeframe_124 = PERIOD_H1;
int g_period_128 = 50;
int g_ma_method_132 = MODE_SMA;
extern int Thickness = 1;
double g_ibuf_140[];
double g_ibuf_144[];
int gi_148;

int init() {
   SetIndexBuffer(0, g_ibuf_140);
   SetIndexStyle(0, DRAW_ARROW, EMPTY, Thickness);
   SetIndexArrow(0, 117);
   SetIndexEmptyValue(0, 0.0);
   SetIndexBuffer(1, g_ibuf_144);
   SetIndexStyle(1, DRAW_ARROW, EMPTY, Thickness);
   SetIndexArrow(1, 117);
   SetIndexEmptyValue(1, 0.0);
   IndicatorShortName("4X Pip Snager Filter ");
   gi_148 = g_timeframe_124 / Period();
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int l_shift_0;
   double ld_12;
   double ld_20;
   double ld_28;
   double ld_36;
   if (TimeLocal() >= 1587945600) return (0);
   int li_4 = IndicatorCounted();
   if (li_4 > 0) li_4 -= gi_148;
   int li_8 = Bars - li_4;
   for (int li_44 = li_8; li_44 >= 0; li_44--) {
      l_shift_0 = iBarShift(NULL, g_timeframe_124, iTime(NULL, 0, li_44), FALSE);
      ld_12 = NormalizeDouble(iMA(Symbol(), g_timeframe_124, g_period_128, 0, g_ma_method_132, PRICE_CLOSE, l_shift_0), Digits);
      ld_20 = NormalizeDouble(iHigh(NULL, g_timeframe_124, l_shift_0), Digits);
      ld_28 = NormalizeDouble(iLow(NULL, g_timeframe_124, l_shift_0), Digits);
      g_ibuf_140[li_44] = EMPTY_VALUE;
      g_ibuf_144[li_44] = EMPTY_VALUE;
      if (ld_20 > ld_12 && ld_28 < ld_12) continue;
      ld_36 = NormalizeDouble(iClose(NULL, g_timeframe_124, l_shift_0), Digits);
      if (ld_36 > ld_12) g_ibuf_140[li_44] = 1;
      else g_ibuf_144[li_44] = 1;
   }
   return (0);
}
