Navigation:Home > Content >

PrevDayAndFloatingPivot_O_(2).mq4

Time: 2018-04-08 | Download file:PrevDayAndFloatingPivot_O_(2).mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2006, mbkennel@gmail.com"
#property link      "http://www.metatrader.org"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Fuchsia

double g_ibuf_76[];
double g_ibuf_80[];

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, g_ibuf_80);
   SetIndexLabel(0, "Previous Day Pivot");
   SetIndexLabel(1, "Floating current pivot");
   return (0);
}

int deinit() {
   return (0);
}

int TodaysBarShift(int ai_0) {
   int l_datetime_4 = iTime(NULL, Period(), ai_0);
   int l_shift_8 = iBarShift(NULL, PERIOD_D1, l_datetime_4, FALSE);
   int l_datetime_12 = iTime(NULL, PERIOD_D1, l_shift_8);
   if (l_datetime_12 > l_datetime_4) l_shift_8++;
   return (l_shift_8);
}

int PreviousNonSundayBarShift(int ai_0) {
   int li_4 = TodaysBarShift(ai_0);
   int li_ret_8 = li_4 + 1;
   int l_datetime_12 = iTime(NULL, PERIOD_D1, li_ret_8);
   if (TimeDayOfWeek(l_datetime_12) == 0) li_ret_8++;
   return (li_ret_8);
}

void TodaysHighestLowest(double &ad_0, double &ad_8, int ai_16) {
   double ld_36;
   double ld_44;
   int l_datetime_20 = iTime(NULL, Period(), ai_16);
   int li_24 = TodaysBarShift(ai_16);
   int l_datetime_28 = iTime(NULL, PERIOD_D1, li_24);
   ad_0 = High[ai_16];
   ad_8 = Low[ai_16];
   int li_32 = ai_16 + 1;
   while (iTime(NULL, Period(), li_32) >= l_datetime_28) {
      ld_36 = High[li_32];
      ld_44 = Low[li_32];
      ad_0 = MathMax(ad_0, ld_36);
      ad_8 = MathMin(ad_8, ld_44);
      li_32++;
      if (li_32 - ai_16 > 24) {
         Print("Shit!");
         return;
      }
   }
}

int start() {
   int li_12;
   int li_16;
   double l_iopen_20;
   double ld_28;
   double ld_36;
   double ld_44;
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0;
   for (int li_8 = li_4; li_8 >= 0; li_8--) {
      li_12 = PreviousNonSundayBarShift(li_8);
      li_16 = TodaysBarShift(li_8);
      l_iopen_20 = iOpen(NULL, PERIOD_D1, li_16);
      TodaysHighestLowest(ld_28, ld_36, li_8);
      ld_44 = 0.33333 * (ld_28 + ld_36 + Close[li_8]);
      g_ibuf_76[li_8] = l_iopen_20;
      g_ibuf_80[li_8] = ld_44;
   }
   return (0);
}

Recommend