Navigation´╝ÜHome > Content >

pfd_snake_trend.mq4

Time: 2013-04-15 | Download file:pfd_snake_trend.mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color5 Aqua

extern bool Crash = FALSE;
extern int TimeFrame = 60;
extern int Length = 7;
extern int Method = 3;
extern int Smoothing = 2;
extern int Filter = 2;
extern bool RealTime = TRUE;
extern bool Steady = FALSE;
extern bool Color = TRUE;
extern bool Alerts = TRUE;
extern bool EmailON = FALSE;
extern bool SignalPrice = TRUE;
extern color SignalPriceBUY = Yellow;
extern color SignalPriceSELL = Aqua;
extern int CountBars = 1485;
double g_ibuf_136[];
double g_ibuf_140[];
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
double g_ibuf_164[];
bool gi_168 = TRUE;
bool gi_172 = TRUE;
int g_datetime_176 = 0;
int g_datetime_180 = 0;
int gi_184 = 0;

int init() {
   string ls_0;
   IndicatorBuffers(8);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(0, g_ibuf_140);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(1, g_ibuf_152);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(2, g_ibuf_156);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 233);
   SetIndexBuffer(3, g_ibuf_160);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 234);
   SetIndexBuffer(4, g_ibuf_164);
   SetIndexBuffer(5, g_ibuf_136);
   SetIndexBuffer(6, g_ibuf_148);
   SetIndexBuffer(7, g_ibuf_144);
   if (Length < 2) Length = 2;
   if (Method < MODE_SMA) Method = 0;
   if (Method > MODE_LWMA) Method = 3;
   if (Smoothing < 0) Smoothing = 0;
   if (Filter < 0) Filter = 0;
   if (TimeFrame < Period() && TimeFrame != 0) TimeFrame = Period();
   switch (TimeFrame) {
   case 1:
      ls_0 = "M1";
      break;
   case 5:
      ls_0 = "M5";
      break;
   case 15:
      ls_0 = "M15";
      break;
   case 30:
      ls_0 = "M30";
      break;
   case 60:
      ls_0 = "H1";
      break;
   case 240:
      ls_0 = "H4";
      break;
   case 1440:
      ls_0 = "D1";
      break;
   case 10080:
      ls_0 = "W1";
      break;
   case 43200:
      ls_0 = "MN1";
      break;
   default:
      ls_0 = "";
   }
   string ls_12 = "pfd_snake_trend" + ls_0 + " |  " + Length + " , " + Method + " , " + Smoothing + " , " + Filter + "  | ";
   IndicatorShortName(ls_12);
   return (0);
}

int start() {
   int lia_0[];
   int li_4;
   int l_index_8;
   string ls_12;
   if (Bars < 100) {
      IndicatorShortName("Bars less than 100");
      return (0);
   }
   if (g_datetime_176 < iTime(NULL, TimeFrame, 0)) {
      gi_172 = FALSE;
      gi_168 = FALSE;
      g_datetime_176 = iTime(NULL, TimeFrame, 0);
   }
   if (!RealTime) {
      if (g_datetime_180 == iTime(NULL, TimeFrame, 0)) return (0);
      g_datetime_180 = iTime(NULL, TimeFrame, 0);
      gi_184 = TimeFrame / Period() + 1;
      if (gi_184 == 0) gi_184 = 1;
   }
   double ld_unused_20 = 0;
   double l_ima_28 = 0;
   double l_ima_36 = 0;
   double l_ima_44 = 0;
   double l_ima_52 = 0;
   double l_ima_60 = 0;
   if (CountBars > iBars(NULL, TimeFrame) || CountBars > Bars - Length - 1) CountBars = MathMin(Bars - Length - 1, iBars(NULL, TimeFrame) - Length - 1);
   if (Crash && CountBars > 0) {
      CountBars -= 10;
      IndicatorShortName("Crash: " + CountBars + "     ");
   }
   if (Crash && CountBars < 0) IndicatorShortName("Crash");
   int li_68 = CountBars;
   g_ibuf_140[li_68 + 1] = Close[li_68 + 1];
   g_ibuf_144[li_68 + 1] = Close[li_68 + 1];
   while (li_68 >= 0) {
      l_ima_28 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_HIGH, li_68);
      l_ima_36 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_LOW, li_68);
      l_ima_44 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_OPEN, li_68);
      l_ima_52 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, li_68);
      l_ima_60 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, li_68 + Smoothing);
      if (Steady == TRUE) {
         l_ima_52 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, li_68);
         l_ima_60 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, li_68 + Smoothing);
      }
      g_ibuf_136[li_68] = MathAbs(((l_ima_52 - l_ima_60) / MathMax(l_ima_28 - l_ima_36, MathMax(l_ima_28 - l_ima_60, l_ima_60 - l_ima_36)) + (l_ima_52 - l_ima_44) / (l_ima_28 - l_ima_36)) / 2.0) * ((l_ima_52 - l_ima_60 +
         (l_ima_52 - l_ima_44)) / 2.0);
      g_ibuf_140[li_68] = g_ibuf_140[li_68 + 1] + g_ibuf_136[li_68];
      if (Filter > 0)
         if (MathAbs(g_ibuf_140[li_68] - (g_ibuf_140[li_68 + 1])) < Filter * Point) g_ibuf_140[li_68] = g_ibuf_140[li_68 + 1];
      if (TimeFrame > Period()) g_ibuf_144[li_68] = g_ibuf_140[li_68];
      li_68--;
   }
   if (TimeFrame > Period()) {
      ArrayCopySeries(lia_0, 5, Symbol(), TimeFrame);
      li_4 = CountBars + TimeFrame / Period();
      li_68 = 0;
      l_index_8 = 0;
      while (li_68 < li_4) {
         if (Time[li_68] < lia_0[l_index_8]) l_index_8++;
         g_ibuf_140[li_68] = g_ibuf_144[l_index_8];
         li_68++;
      }
   }
   for (li_68 = CountBars; li_68 >= 0; li_68--) {
      g_ibuf_148[li_68] = g_ibuf_148[li_68 + 1];
      if (g_ibuf_140[li_68] - (g_ibuf_140[li_68 + 1]) > 0.0) g_ibuf_148[li_68] = 1;
      if (g_ibuf_140[li_68 + 1] - g_ibuf_140[li_68] > 0.0) g_ibuf_148[li_68] = -1;
      if (Color == TRUE) {
         if (g_ibuf_148[li_68] > 0.0) {
            g_ibuf_152[li_68] = g_ibuf_140[li_68];
            if (g_ibuf_148[li_68 + 1] < 0.0) g_ibuf_152[li_68 + 1] = g_ibuf_140[li_68 + 1];
            g_ibuf_156[li_68] = EMPTY_VALUE;
         } else {
            if (g_ibuf_148[li_68] < 0.0) {
               g_ibuf_156[li_68] = g_ibuf_140[li_68];
               if (g_ibuf_148[li_68 + 1] > 0.0) g_ibuf_156[li_68 + 1] = g_ibuf_140[li_68 + 1];
               g_ibuf_152[li_68] = EMPTY_VALUE;
            }
         }
      }
      if (Alerts == TRUE) {
         g_ibuf_160[li_68] = EMPTY_VALUE;
         g_ibuf_164[li_68] = EMPTY_VALUE;
         if (g_ibuf_148[li_68] == 1.0 && g_ibuf_148[li_68 + 1] == -1.0) g_ibuf_160[li_68] = g_ibuf_140[li_68 + 1] - (Ask - Bid);
         if (g_ibuf_148[li_68] == -1.0 && g_ibuf_148[li_68 + 1] == 1.0) g_ibuf_164[li_68] = g_ibuf_140[li_68 + 1] + (Ask - Bid);
      }
   }
   if (Alerts == TRUE) {
      if (g_ibuf_160[gi_184 + 0] != EMPTY_VALUE && gi_168 == FALSE) {
         ls_12 = "pfd_BUY:  " + Symbol() + " - " + Period() + "  at  " + DoubleToStr(Close[0], Digits) + "  -  " + TimeToStr(TimeCurrent(), TIME_SECONDS);
         Alert(ls_12);
         if (EmailON) SendMail(ls_12, ls_12);
         if (SignalPrice == TRUE) {
            ObjectCreate("BUY SIGNAL: " + DoubleToStr(Time[0], 0), OBJ_ARROW, 0, Time[0], Close[0]);
            ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0], 0), OBJPROP_ARROWCODE, SYMBOL_LEFTPRICE);
            ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0], 0), OBJPROP_COLOR, SignalPriceBUY);
         }
         gi_172 = FALSE;
         gi_168 = TRUE;
      }
      if (g_ibuf_164[gi_184 + 0] != EMPTY_VALUE && gi_172 == FALSE) {
         ls_12 = "pfd_SELL:  " + Symbol() + " - " + Period() + "  at  " + DoubleToStr(Close[0], Digits) + "  -  " + TimeToStr(TimeCurrent(), TIME_SECONDS);
         Alert(ls_12);
         if (EmailON) SendMail(ls_12, ls_12);
         if (SignalPrice == TRUE) {
            ObjectCreate("SELL SIGNAL: " + DoubleToStr(Time[0], 0), OBJ_ARROW, 0, Time[0], Close[0]);
            ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0], 0), OBJPROP_ARROWCODE, SYMBOL_LEFTPRICE);
            ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0], 0), OBJPROP_COLOR, SignalPriceSELL);
         }
         gi_168 = FALSE;
         gi_172 = TRUE;
      }
   }
   return (0);
}

Recommend