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

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Pink
#property indicator_color2 Gold
#property indicator_color3 SkyBlue
#property indicator_color4 Blue
#property indicator_color5 Red

//#include <FDB_File.mqh>

extern int MaxBars = 500;
extern bool Show_Lines = TRUE;
extern bool Show_HiLo = TRUE;
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
int gi_108 = 0;
bool gi_112;
int g_str2dbl_116 = EMPTY_VALUE;
int g_str2dbl_120 = EMPTY_VALUE;

int init() {
   IndicatorBuffers(5);
   IndicatorShortName("FXDB_TPDots");
   SetIndexBuffer(0, g_ibuf_88);
   SetIndexBuffer(1, g_ibuf_92);
   SetIndexBuffer(2, g_ibuf_96);
   SetIndexBuffer(3, g_ibuf_100);
   SetIndexBuffer(4, g_ibuf_104);
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(3, DRAW_ARROW, EMPTY);
   SetIndexStyle(4, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 167);
   SetIndexArrow(3, 167);
   SetIndexArrow(4, 167);
//   if (FDB_Open("FDB.rkey")) {
//      if (FDB_GetStatus(1) == 1) g_str2dbl_120 = StrToDouble(FDB_GetValue(1));
//      if (FDB_GetStatus(2) == 1) g_str2dbl_116 = StrToDouble(FDB_GetValue(2));
//      Print("Run_Key loaded from file.");
//   } else Print("Run_Key file not found.");
   gi_112 = TRUE;
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   double ld_32;
   if (!IsConnected()) {
      if (gi_108 > 1) Print("No login Connection.");
      gi_108++;
   }
//   if (CheckKey() == 0 && AccountNumber() != 0) {
      for (int l_count_40 = 0; l_count_40 < 6; l_count_40++) {
//         if (CheckKey() == 1) break;
//         if (l_count_40 == 5 && CheckKey() == 0) {
//            Print("Registration Key Failed for Account#: " + AccountNumber());
//            deinit();
//            return (0);
//        }
//      }
   }
   int li_44 = IndicatorCounted();
   if (li_44 < 0) return (-1);
   if (li_44 > 0) li_44--;
   int li_48 = Bars - li_44;
   if (li_48 > MaxBars) li_48 = MaxBars;
   for (int li_52 = li_48; li_52 >= 0; li_52--) g_ibuf_88[li_52] = (High[li_52] + Low[li_52] + Close[li_52]) / 3.0;
   if (Show_Lines == TRUE) {
      for (li_52 = li_48; li_52 >= 0; li_52--) {
         g_ibuf_92[li_52] = iMAOnArray(g_ibuf_88, 0, 3, 0, MODE_SMA, li_52 + 1);
         g_ibuf_96[li_52] = iMAOnArray(g_ibuf_88, 0, 3, 1, MODE_SMA, li_52 + 1);
      }
   }
   if (Show_HiLo == TRUE) {
      for (li_52 = li_48; li_52 >= 0; li_52--) {
         ld_0 = (High[li_52 + 1] + (Low[li_52 + 1]) + (Close[li_52 + 1])) / 3.0;
         ld_8 = 2.0 * ld_0 - (Low[li_52 + 1]);
         ld_16 = 2.0 * ld_0 - (High[li_52 + 1]);
         ld_24 = ld_0 + (ld_8 - ld_16);
         ld_32 = ld_0 - (ld_8 - ld_16);
         if (g_ibuf_88[li_52] >= ld_0) {
            g_ibuf_100[li_52] = NormalizeDouble(ld_24, Digits);
            g_ibuf_104[li_52] = NormalizeDouble(ld_16, Digits);
         }
         if (g_ibuf_88[li_52] < ld_0) {
            g_ibuf_100[li_52] = NormalizeDouble(ld_8, Digits);
            g_ibuf_104[li_52] = NormalizeDouble(ld_32, Digits);
         }
      }
   }
   return (0);
}

/*int CheckKey() {
   double ld_0;
   double ld_8;
   double ld_16;
   int l_month_24 = TimeMonth(TimeCurrent());
   if (IsDemo() == TRUE) {
      ld_0 = NormalizeDouble(MathAbs(AccountNumber() << 2 - 3912671 * l_month_24), 0);
      ld_16 = NormalizeDouble(MathAbs(g_str2dbl_116), 0);
   } else {
      ld_0 = NormalizeDouble(MathAbs(AccountNumber() << 2 + 10110110 - 5382974 * l_month_24), 0);
      ld_16 = NormalizeDouble(MathAbs(g_str2dbl_120), 0);
   }
   if (TimeMonth(TimeCurrent() - 259200) == l_month_24 - 1 && ld_16 > 0.0) {
      if (IsDemo() == TRUE) ld_8 = NormalizeDouble(MathAbs(AccountNumber() << 2 - 3912671 * (l_month_24 - 1)), 0);
      else ld_8 = NormalizeDouble(MathAbs(AccountNumber() << 2 + 10110110 - 5382974 * (l_month_24 - 1)), 0);
   }
   if (gi_112 == TRUE && ld_16 == ld_8) {
      Print("Registration Key expires on the 3rd at Midnite.  Login and generate a new key.");
      gi_112 = FALSE;
   }
   if (ld_16 == ld_0 || ld_16 == ld_8 && ld_16 > 0.0) return (1);
   return (0);
} */