gadi_obv_v2.2.mq4

gadi_obv_v2.2.mq4 download link will appear after 10 seconds.




gadi_obv_v2.2.mq4 Programming source code

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lavender
#property indicator_color2 DodgerBlue
#property indicator_color3 Red

extern int TF = 0;
extern bool DrawChannel = TRUE;
extern int StartHour = 0;
extern int StartMinute = 0;
extern int EndHour = 7;
extern int EndMinute = 0;
extern double PercentIncrease = 0.5;
int Gi_108 = 0;
double G_ibuf_112[];
double Gd_116;
double G_ibuf_124[];
double G_ibuf_128[];
double Gd_132;
double Gd_140;
int Gi_152;
int Gi_156 = 0;
int Gi_160 = 0;
string Gs_164;
string Gs_dummy_172;
string Gs_dummy_180;
string Gs_dummy_188;
string Gs_dummy_196;
string Gs_204;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexBuffer(0, G_ibuf_112);
   SetIndexBuffer(1, G_ibuf_124);
   SetIndexBuffer(2, G_ibuf_128);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   IndicatorDigits(0);
   if (TF == 0) TF = Period();
   Gs_164 = "Gadi_OBV_v2.2 (TF = " + TF + " Min.)  ";
   IndicatorShortName(Gs_164);
   SetIndexLabel(0, Gs_164);
   SetIndexLabel(1, "Channel High");
   SetIndexLabel(2, "Channel Low");
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   double Ld_12;
   double Ld_20;
   int Li_8 = IndicatorCounted();
   if (Li_8 > 0) Li_8--;
   int Li_4 = Bars - Li_8 - 1;
   for (int Li_0 = Li_4; Li_0 >= 0; Li_0--) {
      if (Li_0 == Bars - 1) G_ibuf_112[Li_0] = iVolume(NULL, TF, Li_0);
      else {
         Ld_12 = f0_0(Gi_108, Li_0);
         Ld_20 = f0_0(Gi_108, Li_0 + 1);
         if (Ld_12 == Ld_20) G_ibuf_112[Li_0] = G_ibuf_112[Li_0 + 1];
         else {
            if (Ld_12 < Ld_20) {
               if (iHigh(NULL, TF, Li_0) - iLow(NULL, TF, Li_0) > 0.0) {
                  Gd_116 = (iOpen(NULL, TF, Li_0) - iClose(NULL, TF, Li_0)) / (iHigh(NULL, TF, Li_0) - iLow(NULL, TF, Li_0));
                  G_ibuf_112[Li_0] = G_ibuf_112[Li_0 + 1] - iVolume(NULL, TF, Li_0) * Gd_116;
                  continue;
               }
               G_ibuf_112[Li_0] = G_ibuf_112[Li_0 + 1];
            } else {
               if (iHigh(NULL, TF, Li_0) - iLow(NULL, TF, Li_0) > 0.0) {
                  Gd_116 = (iClose(NULL, TF, Li_0) - iOpen(NULL, TF, Li_0)) / (iHigh(NULL, TF, Li_0) - iLow(NULL, TF, Li_0));
                  G_ibuf_112[Li_0] = G_ibuf_112[Li_0 + 1] + iVolume(NULL, TF, Li_0) * Gd_116;
               } else G_ibuf_112[Li_0] = G_ibuf_112[Li_0 + 1];
            }
         }
      }
   }
   Comment("");
   SetLevelValue(1, 0);
   SetLevelValue(2, 0);
   if (DrawChannel == TRUE) {
      Gi_156 = 0;
      Gi_160 = 0;
      Comment("\nChannel Start: ", f0_1(StartHour), ":", f0_1(StartMinute), 
      "\nChannel End: ", f0_1(EndHour), ":", f0_1(EndMinute));
      for (int index_28 = 0; index_28 <= 1440; index_28++) {
         if (TimeHour(Time[index_28]) == StartHour && TimeMinute(Time[index_28]) == StartMinute) Gi_156 = index_28;
         if (TimeHour(Time[index_28]) == EndHour && TimeMinute(Time[index_28]) == EndMinute) Gi_160 = index_28;
         if (Gi_156 > 0) break;
      }
      Gd_132 = G_ibuf_112[Gi_156];
      Gd_140 = G_ibuf_112[Gi_156];
      if (Gi_160 > 0) {
         for (Gi_152 = Gi_160 + 1; Gi_152 <= Gi_156; Gi_152++) {
            Gd_132 = MathMax(G_ibuf_112[Gi_152], Gd_132);
            Gd_140 = MathMin(G_ibuf_112[Gi_152], Gd_140);
         }
         for (Gi_152 = Gi_160 + 1; Gi_152 <= Gi_156; Gi_152++) {
            G_ibuf_124[Gi_152] = Gd_132;
            G_ibuf_128[Gi_152] = Gd_140;
         }
         SetLevelValue(1, Gd_132 + MathAbs(Gd_132 * PercentIncrease / 100.0));
         SetLevelValue(2, Gd_140 - MathAbs(Gd_140 * PercentIncrease / 100.0));
      }
   }
   return (0);
}

// 4D1BFCB584FB49C2CAAE9B4A108ED0D1
double f0_0(int Ai_0, int Ai_4) {
   double Ld_ret_8;
   switch (Ai_0) {
   case 0:
      Ld_ret_8 = iClose(NULL, TF, Ai_4);
      break;
   case 1:
      Ld_ret_8 = iOpen(NULL, TF, Ai_4);
      break;
   case 2:
      Ld_ret_8 = iHigh(NULL, TF, Ai_4);
      break;
   case 3:
      Ld_ret_8 = iLow(NULL, TF, Ai_4);
      break;
   case 4:
      Ld_ret_8 = (iHigh(NULL, TF, Ai_4) + iLow(NULL, TF, Ai_4)) / 2.0;
      break;
   case 5:
      Ld_ret_8 = (iHigh(NULL, TF, Ai_4) + iLow(NULL, TF, Ai_4) + iClose(NULL, TF, Ai_4)) / 3.0;
      break;
   case 6:
      Ld_ret_8 = (iHigh(NULL, TF, Ai_4) + iLow(NULL, TF, Ai_4) + 2.0 * iClose(NULL, TF, Ai_4)) / 4.0;
      break;
   default:
      Ld_ret_8 = 0.0;
   }
   return (Ld_ret_8);
}

// 63CC58CA5E714E7C12800B24D2F8CFE3
string f0_1(int Ai_0) {
   if (StringLen(DoubleToStr(Ai_0, 0)) < 2) Gs_204 = "0" + Ai_0;
   else Gs_204 = DoubleToStr(Ai_0, 0);
   return (Gs_204);
}