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

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Purple
#property indicator_color4 Orange
#property indicator_color5 Blue
#property indicator_color6 White
#property indicator_color7 Yellow
#property indicator_color8 Brown

#import "FXI.dll"
   string gGrab(string a0, string a1);
#import "corr_upd.dll"
   string returnReg(string a0, string a1);
#import

bool gi_unused_76 = FALSE;
bool gi_80 = FALSE;
bool gi_84 = FALSE;
bool gi_88 = FALSE;
bool gi_92 = FALSE;
bool gi_96 = FALSE;
bool gi_100 = FALSE;
bool gi_104 = FALSE;
bool gi_108 = FALSE;
int gi_112 = 4;
bool gi_116 = FALSE;
bool gi_120 = FALSE;
bool gi_124 = FALSE;
bool gi_128 = FALSE;
int gi_132 = 0;
int gi_136 = 500;
int gi_140 = 5;
bool gi_144 = TRUE;
int gi_148 = -1;
int gi_unused_152 = -1;
int g_bars_156;
double g_ibuf_160[];
double g_ibuf_164[];
double g_ibuf_168[];
double g_ibuf_172[];
double g_ibuf_176[];
double g_ibuf_180[];
double g_ibuf_184[];
double g_ibuf_188[];
double gda_192[10];
double gda_196[5000];
string gsa_200[20];
string gsa_204[20];
bool gi_unused_208 = FALSE;
string gs_212 = "";
int gi_224 = 0;
double gda_unused_228[20];
double gda_232[500][2];
double gda_236[500][2];
double gda_240[500][2];
double gda_244[500][2];
double gda_248[500][2];
double gda_252[500][2];
double gda_256[500][2];
double gda_260[500][2];
int gi_unused_264;
int g_count_268;
int g_count_272;
int g_count_276;
int g_count_280;
int g_count_284;
int g_count_288;
int g_count_292;
int gi_296;
int gi_300;
int gi_304;
int gi_308;
int gi_312;
int gi_316;
int gi_320;
int gi_324;
int g_day_328 = -1;
double gd_332;
int gi_unused_340 = -1;
int g_index_344 = 0;
double gd_348 = -1.0;
double gd_356 = -1.0;
double gd_364 = -1.0;
double gd_372 = -1.0;
string gsa_380[500][3];
int g_index_384 = 0;
string gsa_388[500][3];
int g_index_392 = 0;
int gi_396 = -1;
string gsa_400[5][3];
extern string Copyright = "Copyright Sharptrade Partners, LLC - 2010";
extern string First = "FXI+DelphiScalper";
extern string Last = "http://www.foreximpact.com";
extern bool EasyMode = TRUE;
bool gi_432 = TRUE;
extern string lbl2 = "-- Other Settings --";
extern int MinDistance = 10;
extern color ValidColor = Green;
extern color OutsideColor = Red;
extern color EntryColor = Yellow;
extern int HourStart = 9;
extern int HourEnd = 18;
extern color BoxColor = Blue;
extern color TextColor = White;
bool gi_476 = FALSE;
double gda_480[];
double gd_484 = 1.01;
bool gi_492 = TRUE;
int gi_496 = 5;
int gi_500 = 40;
int gi_unused_504 = 5;
double gd_unused_508 = 100.0;
double gd_unused_516 = 0.0;
double gd_unused_524 = 100.0;
double gd_unused_532 = 0.0;
int gi_unused_540 = 5;
int gi_unused_544 = 5;
double gd_unused_548 = 100.0;
int g_period_556 = 14;
int g_period_560 = 3;
int g_slowing_564 = 3;
int gi_568 = 50;
int gi_572 = 50;
bool gi_unused_576 = FALSE;
bool gi_unused_580 = TRUE;
bool gi_unused_584 = FALSE;
bool gi_unused_588 = FALSE;
int gi_unused_592 = 1000;
double g_ibuf_596[];
double g_ibuf_600[];
double gda_unused_604[];
double gda_unused_608[];
double gda_unused_612[];
double gda_unused_616[];
int gi_620 = -1;
int gi_624 = -1;
int gi_unused_648 = -1;
int gi_unused_656 = 0;
double g_icustom_660;
double g_icustom_668;
double g_icustom_676;
double g_icustom_684;
int gi_unused_692;
bool gi_unused_696 = FALSE;
double gda_unused_700[];
double gda_unused_704[];
double g_icustom_708;
double g_icustom_716;
double g_icustom_724;
double g_icustom_732;
double g_icustom_756;
double g_icustom_764;
double g_icustom_772;
double g_icustom_780;
double g_istochastic_796;
double g_ibuf_804[];
double g_ibuf_808[];
int gt_unused_812 = -1;
int gt_unused_816 = -1;
int gi_unused_820 = -1;
int gi_824 = 0;
double g_icustom_828;
int g_time_836 = 0;
string gs_unused_840;
double gd_848 = 100.0;
double gd_856 = 0.0;
double gd_864 = 100.0;
double gd_872 = 0.0;
int gi_880 = 5;
int gi_884 = 5;
double g_pips_888 = 100.0;
double gda_896[50];
double gda_900[50];
double g_ibuf_904[];
double g_ibuf_908[];
double g_ibuf_912[];
double g_ibuf_916[];
bool gi_920 = TRUE;
bool gi_924 = TRUE;
double g_ibuf_928[];
double g_ibuf_932[];
double g_ibuf_936[];
double g_ibuf_940[];
double g_ibuf_944[];
int g_time_948 = 0;
double gd_952;
double g_ibuf_960[];
double g_ibuf_964[];
double g_ibuf_968[];
double g_ibuf_972[];
int gi_976 = 0;
string gs_dummy_980;
double g_ibuf_988[];
double g_ibuf_992[];
bool gi_unused_996 = FALSE;
int g_time_1000 = -1;
int g_time_1004 = -1;
bool gi_1008 = TRUE;
int g_file_1012;
bool gi_1016 = FALSE;
string gs_unused_1020;

int doTFInit() {
   string ls_0;
   if (Copyright == "koaijdsoDUDFIUONUIN") {
      IndicatorBuffers(4);
      SetIndexBuffer(0, g_ibuf_904);
      SetIndexStyle(0, DRAW_LINE);
      SetIndexBuffer(1, g_ibuf_908);
      SetIndexStyle(1, DRAW_LINE);
      SetIndexBuffer(2, g_ibuf_912);
      SetIndexStyle(2, DRAW_LINE, STYLE_DASH);
      SetIndexBuffer(3, g_ibuf_916);
      ls_0 = Symbol();
      if (StringFind(ls_0, "EURUSD") != -1) {
         gd_848 = 100;
         gd_856 = 0;
         gd_864 = 100;
         gd_872 = 0;
         gi_880 = 5;
         gi_884 = 5;
      }
      if (StringFind(ls_0, "USDCHF") != -1) {
         gd_848 = 100;
         gd_856 = 0;
         gd_864 = 100;
         gd_872 = 0;
         gi_880 = 5;
         gi_884 = 5;
      }
      if (StringFind(ls_0, "GBPUSD") != -1) {
         gd_848 = 100;
         gd_856 = 0;
         gd_864 = 100;
         gd_872 = 0;
         gi_880 = 5;
         gi_884 = 5;
      }
      if (StringFind(ls_0, "USDJPY") != -1) {
         gd_848 = 100;
         gd_856 = 0;
         gd_864 = 100;
         gd_872 = 0;
         gi_880 = 6;
         gi_884 = 6;
      }
      return (-1);
   }
   if (Copyright == "9jawe09j09j()J)(JJ") {
      IndicatorBuffers(6);
      SetIndexBuffer(0, g_ibuf_960);
      SetIndexStyle(0, DRAW_LINE);
      SetIndexLabel(0, "FXI Ratchet");
      SetIndexBuffer(1, g_ibuf_928);
      SetIndexStyle(1, DRAW_NONE);
      SetIndexLabel(1, "Debug 1");
      SetIndexBuffer(2, g_ibuf_932);
      SetIndexStyle(2, DRAW_NONE);
      SetIndexLabel(2, "Debug 2");
      SetIndexBuffer(3, g_ibuf_936);
      SetIndexStyle(3, DRAW_NONE);
      SetIndexLabel(3, "Debug 3");
      SetIndexBuffer(4, g_ibuf_940);
      SetIndexStyle(4, DRAW_NONE);
      SetIndexLabel(4, "Debug 4");
      SetIndexBuffer(5, g_ibuf_944);
      SetIndexStyle(5, DRAW_NONE);
      SetIndexLabel(5, "Debug 5");
      if (First == "1") {
         gi_920 = FALSE;
         gi_924 = TRUE;
      } else {
         gi_920 = FALSE;
         gi_924 = FALSE;
      }
      return (-1);
   }
   if (Copyright == "o999jjdjfjjfjfjfjfjfjf") {
      SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Crimson);
      SetIndexBuffer(0, g_ibuf_960);
      SetIndexLabel(0, "HA_0");
      SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1, RoyalBlue);
      SetIndexBuffer(1, g_ibuf_964);
      SetIndexLabel(1, "HA_1");
      SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, Crimson);
      SetIndexBuffer(2, g_ibuf_968);
      SetIndexLabel(2, "HA_Open");
      SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, RoyalBlue);
      SetIndexBuffer(3, g_ibuf_972);
      SetIndexLabel(3, "HA_Close");
      SetIndexDrawBegin(0, 10);
      SetIndexDrawBegin(1, 10);
      SetIndexDrawBegin(2, 10);
      SetIndexDrawBegin(3, 10);
      SetIndexBuffer(0, g_ibuf_960);
      SetIndexBuffer(1, g_ibuf_964);
      SetIndexBuffer(2, g_ibuf_968);
      SetIndexBuffer(3, g_ibuf_972);
      return (-1);
   }
   if (Copyright == "09uj089ju#$)JHFihuihdf") {
      if (First == "1") gi_500 = 5;
      else gi_500 = 40;
      SetIndexBuffer(0, g_ibuf_960);
      SetIndexStyle(0, DRAW_LINE);
      SetIndexBuffer(1, g_ibuf_964);
      SetIndexStyle(1, DRAW_LINE);
      SetIndexBuffer(2, g_ibuf_968);
      SetIndexStyle(2, DRAW_LINE);
      SetIndexBuffer(3, g_ibuf_988);
      SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 2);
      SetIndexBuffer(4, g_ibuf_992);
      SetIndexStyle(4, DRAW_HISTOGRAM, STYLE_SOLID, 2);
      SetIndexDrawBegin(0, gi_500);
      SetIndexDrawBegin(1, gi_500);
      SetIndexDrawBegin(2, gi_500);
      SetIndexDrawBegin(3, gi_500);
      SetIndexDrawBegin(4, gi_500);
      return (-1);
   }
   if (Copyright == "LoadTrendFinder") {
      IndicatorShortName("Trend Finder Ratchet v2 | ForexImpact.com");
      IndicatorBuffers(4);
      SetIndexBuffer(0, g_ibuf_596);
      SetIndexBuffer(1, g_ibuf_600);
      SetIndexBuffer(2, g_ibuf_804);
      SetIndexBuffer(3, g_ibuf_808);
      SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);
      SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2);
      SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 0);
      SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 0);
      SetIndexArrow(0, 233);
      SetIndexArrow(1, 234);
      SetIndexArrow(2, 233);
      SetIndexArrow(3, 234);
      SetIndexEmptyValue(0, 0.0);
      SetIndexEmptyValue(1, 0.0);
      SetIndexEmptyValue(2, 0.0);
      SetIndexEmptyValue(3, 0.0);
      SetIndexLabel(0, "Green Arrow");
      SetIndexLabel(1, "Red Arrow");
      SetIndexLabel(2, "Exit Long Arrow");
      SetIndexLabel(3, "Exit Short Arrow");
      SetIndexDrawBegin(0, 10);
      SetIndexDrawBegin(1, 10);
      SetIndexDrawBegin(2, 10);
      SetIndexDrawBegin(3, 10);
      if (Period() == PERIOD_M1) gs_unused_840 = "1 Minute";
      if (Period() == PERIOD_M5) gs_unused_840 = "5 Minute";
      if (Period() == PERIOD_M15) gs_unused_840 = "15 Minute";
      if (Period() == PERIOD_M30) gs_unused_840 = "30 Minute";
      if (Period() == PERIOD_H1) gs_unused_840 = "60 Minute";
      if (Period() == PERIOD_H4) gs_unused_840 = "4 Hour";
      if (Period() == PERIOD_D1) gs_unused_840 = "Daily";
      if (Period() == PERIOD_W1) gs_unused_840 = "Weekly";
      if (Period() == PERIOD_MN1) gs_unused_840 = "Monthly";
      return (-1);
   }
   return (0);
}

int trendFinder_start() {
   if (g_time_836 != Time[0]) {
      if (g_ibuf_596[0] != 0.0 && g_ibuf_596[0] != EMPTY_VALUE && g_ibuf_596[1] == 0.0 || g_ibuf_596[1] == EMPTY_VALUE) g_time_836 = Time[0];
      if (g_ibuf_600[0] != 0.0 && g_ibuf_600[0] != EMPTY_VALUE && g_ibuf_600[1] == 0.0 || g_ibuf_600[1] == EMPTY_VALUE) g_time_836 = Time[0];
   }
   if (Copyright == "verCheckInfo") {
      gda_480[0] = gd_484;
      return (0);
   }
   if (Copyright == "9jawe09j09j()J)(JJ") {
      Ratchet();
      return (0);
   }
   if (Copyright == "koaijdsoDUDFIUONUIN") {
      SquishSquash();
      return (0);
   }
   if (Copyright == "o999jjdjfjjfjfjfjfjfjf") {
      HeikenAshi();
      return (0);
   }
   if (Copyright == "09uj089ju#$)JHFihuihdf") {
      PAC();
      return (0);
   }
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0;
   if (li_4 > 0) li_4--;
   if (li_4 < 0) return (-1);
   for (int l_shift_8 = li_4; l_shift_8 >= 0; l_shift_8--) {
      g_icustom_660 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "9jawe09j09j()J)(JJ", "1", 0, l_shift_8);
      g_icustom_668 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "9jawe09j09j()J)(JJ", "2", 0, l_shift_8);
      g_icustom_676 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "9jawe09j09j()J)(JJ", "1", 0, l_shift_8 + 1);
      g_icustom_684 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "9jawe09j09j()J)(JJ", "2", 0, l_shift_8 + 1);
      g_icustom_708 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "koaijdsoDUDFIUONUIN", "", 0, l_shift_8);
      g_icustom_716 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "koaijdsoDUDFIUONUIN", "", 1, l_shift_8);
      g_icustom_724 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "koaijdsoDUDFIUONUIN", "", 0, l_shift_8 + 1);
      g_icustom_732 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "koaijdsoDUDFIUONUIN", "", 1, l_shift_8 + 1);
      g_icustom_756 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "o999jjdjfjjfjfjfjfjfjf", "", 2, l_shift_8 + 1);
      g_icustom_764 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "o999jjdjfjjfjfjfjfjfjf", "", 3, l_shift_8 + 1);
      g_icustom_780 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "o999jjdjfjjfjfjfjfjfjf", "", 2, l_shift_8);
      g_icustom_772 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "o999jjdjfjjfjfjfjfjfjf", "", 3, l_shift_8);
      g_istochastic_796 = iStochastic(Symbol(), 0, g_period_556, g_period_560, g_slowing_564, MODE_SMA, 1, MODE_MAIN, l_shift_8);
      gi_unused_692 = 1;
      g_icustom_828 = g_icustom_772;
      if (gi_624 == -1 && g_ibuf_596[l_shift_8] != 0.0) g_ibuf_804[l_shift_8] = g_ibuf_596[l_shift_8];
      if (gi_624 == -1 && g_ibuf_600[l_shift_8] != 0.0) g_ibuf_808[l_shift_8] = g_ibuf_600[l_shift_8];
      if (gi_624 != -1 && g_ibuf_596[l_shift_8] != 0.0 || g_ibuf_600[l_shift_8] != 0.0 && g_ibuf_804[l_shift_8] != 0.0 || g_ibuf_808[l_shift_8] != 0.0) {
         g_ibuf_804[l_shift_8] = 0.0;
         g_ibuf_808[l_shift_8] = 0.0;
      }
      if (Close[l_shift_8] < iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "1", 2, l_shift_8)) gi_620 = 2;
      else gi_620 = 1;
      if (gi_624 == 1 && g_ibuf_596[l_shift_8 + 1] != 0.0) {
         if (g_icustom_772 < g_icustom_708 && (gi_492 && g_icustom_780 > g_icustom_772) || !gi_492) gi_624 = -1;
         if (Close[l_shift_8] < g_icustom_660) gi_624 = -1;
         if (Open[l_shift_8] < iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "1", 2, l_shift_8)) gi_624 = -1;
         if (gi_624 != 1) {
            gt_unused_812 = Time[l_shift_8];
            continue;
         }
         if (g_ibuf_596[l_shift_8] == 0.0 && gi_624 != -1) g_ibuf_596[l_shift_8] = iMA(Symbol(), 0, 5, 0, MODE_SMA, PRICE_LOW, l_shift_8) - 10.0 * Point;
      }
      if (gi_624 == 2 && g_ibuf_600[l_shift_8 + 1] != 0.0) {
         if (Close[l_shift_8] > g_icustom_660) gi_624 = -1;
         if (g_icustom_772 > g_icustom_716 && (gi_492 && g_icustom_780 < g_icustom_772) || !gi_492) gi_624 = -1;
         if (Open[l_shift_8] > iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "1", 2, l_shift_8)) gi_624 = -1;
         if (gi_624 != 2) {
            gt_unused_812 = Time[l_shift_8];
            continue;
         }
         if (g_ibuf_600[l_shift_8] == 0.0 && gi_624 != -1) g_ibuf_600[l_shift_8] = iMA(Symbol(), 0, 5, 0, MODE_SMA, PRICE_HIGH, l_shift_8) + 10.0 * Point;
      }
      if (gi_624 == -1 && gi_824 <= gi_496) {
         gi_624 = gi_620;
         if (gi_624 == 1 && Close[l_shift_8] < g_icustom_660) gi_624 = -1;
         if (gi_624 == 2 && Close[l_shift_8] > g_icustom_660) gi_624 = -1;
         if ((gi_624 == 1 && g_istochastic_796 < gi_568) || (gi_624 == 2 && g_istochastic_796 > gi_572)) gi_624 = -1;
         if (iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8) > g_icustom_716 && iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8) < g_icustom_708) {
            if (g_icustom_772 > iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8) && gi_624 == 2) gi_624 = -1;
            if (g_icustom_772 < iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8) && gi_624 == 1) gi_624 = -1;
         } else {
            if ((gi_624 == 1 && g_icustom_708 < iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8)) || (gi_624 == 2 && g_icustom_716 > iCustom(NULL, 0, "FXI+DelphiScalper", "09uj089ju#$)JHFihuihdf", "0", 2, l_shift_8)) &&
               gi_624 != -1) gi_624 = -1;
         }
         if ((gi_624 == 1 && iCCI(NULL, 0, 14, PRICE_CLOSE, l_shift_8) < 100.0) || (gi_624 == 2 && iCCI(NULL, 0, 14, PRICE_CLOSE, l_shift_8) > -100.0)) gi_624 = -1;
         if (gi_624 == 1) {
            if (g_icustom_828 <= g_icustom_708) gi_624 = -1;
            else {
               if (g_ibuf_596[l_shift_8] == 0.0) {
                  g_ibuf_596[l_shift_8] = iMA(Symbol(), 0, 5, 0, MODE_SMA, PRICE_LOW, l_shift_8) - 10.0 * Point;
                  gt_unused_816 = Time[l_shift_8];
               }
            }
         }
         if (gi_624 == 2) {
            if (g_icustom_828 >= g_icustom_716) gi_624 = -1;
            else {
               if (g_ibuf_600[l_shift_8] == 0.0) {
                  g_ibuf_600[l_shift_8] = iMA(Symbol(), 0, 5, 0, MODE_SMA, PRICE_HIGH, l_shift_8) + 10.0 * Point;
                  gt_unused_816 = Time[l_shift_8];
               }
            }
         }
      }
   }
   return (0);
}

void slideArray(int ai_0, double ad_4, int ai_12) {
   for (int li_16 = ai_12 - 1; li_16 >= 0; li_16--) {
      if (ai_0 == 1) gda_896[li_16 + 1] = gda_896[li_16];
      else gda_900[li_16 + 1] = gda_900[li_16];
   }
   if (ai_0 == 1) gda_896[0] = ad_4;
   if (ai_0 == 2) gda_900[0] = ad_4;
}

int SquishSquash() {
   int l_index_68;
   int l_ind_counted_0 = IndicatorCounted();
   double ld_52 = 0;
   double ld_60 = 0;
   if (ArrayResize(gda_896, gi_880 + 2) == -1) {
      Print("Cannot resize array!");
      return (0);
   }
   if (ArrayResize(gda_900, gi_884 + 2) == -1) {
      Print("Cannot resize array!");
      return (0);
   }
   if (l_ind_counted_0 < 0) return (-1);
   int li_76 = Bars - l_ind_counted_0;
   momentum(li_76);
   for (int li_80 = li_76; li_80 >= 0; li_80--) {
      for (int li_72 = li_80; li_72 < li_80 + gd_848; li_72++) ld_52 += gd_856 * ((High[li_72] - Open[li_72]) / 2.0);
      ld_60 = ld_52 / gd_848;
      ld_52 = 0;
      slideArray(1, ld_60, gi_880);
      for (li_72 = li_80; li_72 < li_80 + gd_864; li_72++) ld_52 += gd_872 * ((Open[li_72] - Low[li_72]) / 2.0);
      ld_60 = ld_52 / gd_864;
      ld_52 = 0;
      slideArray(2, ld_60, gi_884);
      if (gda_900[gi_884] == EMPTY_VALUE || gda_896[gi_880] == EMPTY_VALUE) continue;
      l_index_68 = 0;
      for (li_72 = li_80; li_72 < li_80 + gi_880; li_72++) {
         ld_52 += High[li_72] + gda_896[l_index_68];
         l_index_68++;
      }
      if ((High[li_80 + 1] + (Low[li_80 + 1])) / 2.0 < (High[li_80] + Low[li_80]) / 2.0 && g_pips_888 * Point < g_ibuf_916[li_80]) ld_60 = ld_52 / gi_880 + g_ibuf_916[li_80];
      else ld_60 = ld_52 / gi_880;
      ld_52 = 0;
      g_ibuf_904[li_80] = ld_60;
      l_index_68 = 0;
      for (li_72 = li_80; li_72 < li_80 + gi_884; li_72++) {
         ld_52 += Low[li_72] - gda_900[l_index_68];
         l_index_68++;
      }
      if ((High[li_80 + 1] + (Low[li_80 + 1])) / 2.0 > (High[li_80] + Low[li_80]) / 2.0 && g_pips_888 * Point < g_ibuf_916[li_80]) ld_60 = ld_52 / gi_884 - g_ibuf_916[li_80];
      else ld_60 = ld_52 / gi_884;
      ld_52 = 0;
      g_ibuf_908[li_80] = ld_60;
      g_ibuf_912[li_80] = (g_ibuf_904[li_80] + g_ibuf_908[li_80]) / 2.0;
   }
   return (0);
}

void momentum(int ai_0) {
   for (int l_index_4 = 0; l_index_4 <= ai_0; l_index_4++) g_ibuf_916[l_index_4] = MathAbs((High[l_index_4 + 1] + (Low[l_index_4 + 1])) / 2.0 - (High[l_index_4] + Low[l_index_4]) / 2.0) / 2.0;
}

int Ratchet() {
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0 - 1;
   if (li_4 > 0) li_4--;
   if (li_4 < 0) return (-1);
   for (int li_8 = li_4; li_8 >= 0; li_8--) {
      if (gi_920) gd_952 = Close[li_8];
      else gd_952 = Open[li_8];
      if (gi_624 == -1) {
         if (Open[li_8] > Close[li_8]) {
            gi_624 = 2;
            g_ibuf_928[li_8] = gi_624;
            g_time_948 = Time[li_8];
            g_ibuf_960[li_8] = High[li_8 + 1];
         } else {
            gi_624 = 1;
            g_ibuf_928[li_8] = gi_624;
            g_time_948 = Time[li_8];
            g_ibuf_960[li_8] = Low[li_8 + 1];
         }
      }
      if (gi_624 == 1 && Time[li_8] > g_time_948) {
         g_ibuf_928[li_8] = g_ibuf_928[li_8 + 1];
         if (gi_924) {
            if (Open[li_8 + 1] < Close[li_8 + 1]) g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1] + (Close[li_8 + 1] - (Open[li_8 + 1]));
            else g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1];
         } else g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1] + MathAbs(Close[li_8 + 1] - (Open[li_8 + 1]));
         if (gd_952 < g_ibuf_960[li_8]) {
            g_time_948 = Time[li_8];
            g_ibuf_960[li_8] = High[li_8 + 1];
            gi_624 = 2;
            g_ibuf_928[li_8] = gi_624;
         }
      }
      if (gi_624 == 2 && Time[li_8] > g_time_948) {
         g_ibuf_928[li_8] = g_ibuf_928[li_8 + 1];
         if (gi_924) {
            if (Open[li_8 + 1] > Close[li_8 + 1]) g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1] - (Open[li_8 + 1] - (Close[li_8 + 1]));
            else g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1];
         } else g_ibuf_960[li_8] = g_ibuf_960[li_8 + 1] - MathAbs(Open[li_8 + 1] - (Close[li_8 + 1]));
         if (gd_952 > g_ibuf_960[li_8]) {
            gi_624 = 1;
            g_ibuf_928[li_8] = gi_624;
            g_time_948 = Time[li_8];
            g_ibuf_960[li_8] = Low[li_8 + 1];
         }
      }
   }
   return (0);
}

int HeikenAshi() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   if (Bars <= 10) return (0);
   gi_976 = IndicatorCounted();
   if (gi_976 < 0) return (-1);
   if (gi_976 > 0) gi_976--;
   for (int li_32 = Bars - gi_976 - 1; li_32 >= 0; li_32--) {
      ld_24 = NormalizeDouble((Open[li_32] + High[li_32] + Low[li_32] + Close[li_32]) / 4.0, Digits);
      ld_0 = NormalizeDouble((g_ibuf_968[li_32 + 1] + (g_ibuf_972[li_32 + 1])) / 2.0, Digits);
      ld_8 = MathMax(High[li_32], MathMax(ld_0, ld_24));
      ld_16 = MathMin(Low[li_32], MathMin(ld_0, ld_24));
      if (ld_0 < ld_24) {
         g_ibuf_960[li_32] = ld_16;
         g_ibuf_964[li_32] = ld_8;
      } else {
         g_ibuf_960[li_32] = ld_8;
         g_ibuf_964[li_32] = ld_16;
      }
      g_ibuf_968[li_32] = ld_0;
      g_ibuf_972[li_32] = ld_24;
   }
   return (0);
}

int PAC() {
   double ld_8;
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0;
   if (li_4 > 0) li_4--;
   if (li_4 < 0) return (-1);
   for (int li_16 = li_4; li_16 >= 0; li_16--) {
      g_ibuf_960[li_16] = High[iHighest(NULL, 0, MODE_HIGH, gi_500, li_16 + 1)];
      g_ibuf_964[li_16] = Low[iLowest(NULL, 0, MODE_LOW, gi_500, li_16 + 1)];
      ld_8 = MathAbs(g_ibuf_960[li_16] - g_ibuf_964[li_16]);
      g_ibuf_968[li_16] = ld_8 / 2.0 + g_ibuf_964[li_16];
      if (Open[li_16] > g_ibuf_968[li_16]) {
         g_ibuf_988[li_16] = 1.0;
         g_ibuf_992[li_16] = 0.0;
      } else {
         g_ibuf_988[li_16] = 0.0;
         g_ibuf_992[li_16] = 1.0;
      }
   }
   return (0);
}

int loginStart() {
   int l_str2int_0;
   bool li_4;
   int li_8;
   g_file_1012 = FileOpen("fxi_d.bin", FILE_CSV|FILE_READ);
   if (g_file_1012 < 1) li_4 = FALSE;
   else {
      l_str2int_0 = StrToInteger(FileReadString(g_file_1012));
      FileClose(g_file_1012);
      li_4 = TRUE;
   }
   if (TimeLocal() - l_str2int_0 >= 259200 || li_4 == FALSE) {
      li_8 = doLogin();
      switch (li_8) {
      case 0:
         Alert("Delphi Scalping -- Logged In");
         g_file_1012 = FileOpen("fxi_d.bin", FILE_WRITE, 8);
         if (g_file_1012 < 1) {
            Print("Cannot open password cache!");
            return (0);
         }
         FileWrite(g_file_1012, TimeLocal());
         FileClose(g_file_1012);
         break;
      case 1:
         Alert("Invalid key provided!! Please re-install the software with the correct key.");
         gi_1016 = TRUE;
         break;
      case 4:
         Alert("Your account has been disabled! Please contact support@fximpact.com");
         gi_1016 = TRUE;
         break;
      case 5:
         Alert("Server error!! Please make sure you are connected to the Internet and try again.");
         gi_1016 = TRUE;
         break;
      case 6:
         Alert("No key found in your registry (bad install)! Please re-install the product.");
         gi_1016 = TRUE;
      }
   }
   return (0);
}

int doLogin() {
   string ls_unused_0;
   string ls_unused_8;
   string ls_unused_16;
   string ls_24 = returnReg("Software\\FXI\\Delphi", "key");
   if (ls_24 == "") return (6);
   string ls_32 = "key=" + ls_24;
   string ls_40 = gGrab("http://www.foreximpact.com/delphi/d_login.php", ls_32);
   if (StringSubstr(ls_40, 0, 1) == "0") {
      gs_unused_1020 = ls_40;
      return (0);
   }
   if (StringSubstr(ls_40, 0, 1) == "1") return (1);
   if (StringSubstr(ls_40, 0, 1) == "4") return (4);
   return (5);
}

int init() {
  // loginStart();
  // if (gi_1016) return (0);
   if (doTFInit() < 0) return (0);
   if (Digits == 5 || Digits == 3) {
      MinDistance = 10 * MinDistance;
      Print("Minimum Distance Modified -- ", MinDistance);
   }
   gi_unused_76 = FALSE;
   gi_80 = TRUE;
   gi_84 = TRUE;
   gi_88 = TRUE;
   gi_92 = TRUE;
   gi_96 = TRUE;
   gi_100 = TRUE;
   gi_104 = TRUE;
   gi_108 = TRUE;
   if (Period() >= PERIOD_M5) gi_80 = FALSE;
   if (Period() >= PERIOD_M15) gi_84 = FALSE;
   if (Period() >= PERIOD_M30) gi_88 = FALSE;
   if (Period() >= PERIOD_H1) gi_92 = FALSE;
   if (Period() >= PERIOD_H4) gi_96 = FALSE;
   if (Period() >= PERIOD_D1) gi_100 = FALSE;
   if (Period() >= PERIOD_W1) gi_104 = FALSE;
   if (Period() >= PERIOD_MN1) gi_108 = FALSE;
   gi_116 = FALSE;
   gi_120 = FALSE;
   gi_124 = FALSE;
   gi_128 = FALSE;
   if (Period() < PERIOD_D1) gi_116 = TRUE;
   else {
      if (Period() < PERIOD_W1) gi_120 = TRUE;
      else {
         if (Period() < PERIOD_MN1) gi_124 = TRUE;
         else gi_128 = TRUE;
      }
   }
   ArrayInitialize(gda_192, -1);
   gsa_200[0] = "USD";
   gsa_200[1] = "JPY";
   gsa_200[2] = "EUR";
   gsa_200[3] = "GBP";
   gsa_200[4] = "CAD";
   gsa_200[5] = "AUD";
   gsa_200[6] = "NZD";
   gsa_200[7] = "CHF";
   gi_unused_264 = 0;
   g_count_268 = 0;
   g_count_272 = 0;
   g_count_276 = 0;
   g_count_280 = 0;
   g_count_284 = 0;
   g_count_288 = 0;
   g_count_292 = 0;
   if (StringLen(Symbol()) > 6) gs_212 = StringSubstr(Symbol(), 6);
   else gs_212 = "";
   gi_224 = buildUSDPairs();
   if (gi_224 == 0) Print("Could not find any basis USD pairs.");
   else for (int l_index_0 = 0; l_index_0 < gi_224; l_index_0++) Print("USD Pair #" + ((l_index_0 + 1)) + " = ", gsa_204[l_index_0]);
   SetIndexBuffer(0, g_ibuf_160);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexLabel(0, "USD");
   SetIndexEmptyValue(0, 0.0);
   SetIndexBuffer(1, g_ibuf_164);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexLabel(1, "JPY");
   SetIndexEmptyValue(1, 0.0);
   SetIndexBuffer(2, g_ibuf_168);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexLabel(2, "EUR");
   SetIndexEmptyValue(2, 0.0);
   SetIndexBuffer(3, g_ibuf_172);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexLabel(3, "GBP");
   SetIndexEmptyValue(3, 0.0);
   SetIndexBuffer(4, g_ibuf_176);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexLabel(4, "CAD");
   SetIndexEmptyValue(4, 0.0);
   SetIndexBuffer(5, g_ibuf_180);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexLabel(5, "AUD");
   SetIndexEmptyValue(5, 0.0);
   SetIndexBuffer(6, g_ibuf_184);
   SetIndexStyle(6, DRAW_LINE);
   SetIndexLabel(6, "NZD");
   SetIndexEmptyValue(6, 0.0);
   SetIndexBuffer(7, g_ibuf_188);
   SetIndexStyle(7, DRAW_LINE);
   SetIndexLabel(7, "CHF");
   SetIndexEmptyValue(7, 0.0);
   ArrayInitialize(gda_232, 0.0);
   ArrayInitialize(gda_236, 0.0);
   ArrayInitialize(gda_240, 0.0);
   ArrayInitialize(gda_244, 0.0);
   ArrayInitialize(gda_248, 0.0);
   ArrayInitialize(gda_252, 0.0);
   ArrayInitialize(gda_256, 0.0);
   ArrayInitialize(gda_260, 0.0);
   if (gi_80) loadArray(PERIOD_M5, gda_232, 1);
   if (gi_84) loadArray(PERIOD_M15, gda_236, 1);
   if (gi_88) loadArray(PERIOD_M30, gda_240, 1);
   if (gi_92) loadArray(PERIOD_H1, gda_244, 1);
   if (gi_96) loadArray(PERIOD_H4, gda_248, 1);
   if (gi_100) loadArray(PERIOD_D1, gda_252, 1);
   if (gi_104) loadArray(PERIOD_W1, gda_256, 1);
   if (gi_108) loadArray(PERIOD_MN1, gda_260, 1);
   g_bars_156 = Bars;
   IndicatorShortName("FXI+DelphiScalper");
   return (0);
}

int deinit() {
   bool li_4 = TRUE;
   bool li_8 = FALSE;
   if (li_4) {
      for (int li_0 = 0; li_0 <= ObjectsTotal(); li_0++) {
         if (StringFind(ObjectName(li_0), "Box_", 0) != -1) {
            ObjectDelete(ObjectName(li_0));
            li_8 = TRUE;
         }
      }
      if (li_8) {
         li_8 = FALSE;
//???/*empty:24520:(@)*/
      }
   }
   ObjectsDeleteAll(0, OBJ_HLINE);
   ObjectsDeleteAll(0, OBJ_ARROW);
   Comment("");
   return (0);
}

int start() {
   string ls_52;
 //  if (gi_1016) return (0);
   if (Copyright == "LoadTrendFinder" || Copyright == "koaijdsoDUDFIUONUIN" || Copyright == "9jawe09j09j()J)(JJ" || Copyright == "o999jjdjfjjfjfjfjfjfjf" || Copyright == "09uj089ju#$)JHFihuihdf") {
      trendFinder_start();
      return (0);
   }
   for (int l_index_0 = 0; l_index_0 < gi_224; l_index_0++) {
      if (downloadData(gsa_204[l_index_0], Period()) < 0) {
         Comment("-==--==-- DOWNLOADING DATA -==--==--\nWhen All Neccesary Data Is Downloaded, This Indicator Will Update\nOn The Next Tick. If You Choose Not To Wait, You\nMay Re-Attach The Indicator When The Data Is Finished Loading.");
         gi_1008 = FALSE;
         return (0);
      }
      if (downloadData(gsa_204[l_index_0], PERIOD_M1) < 0) {
         Comment("-==--==-- DOWNLOADING DATA -==--==--\nWhen All Neccesary Data Is Downloaded, This Indicator Will Update\nOn The Next Tick. If You Choose Not To Wait, You\nMay Re-Attach The Indicator When The Data Is Finished Loading.");
         gi_1008 = FALSE;
         return (0);
      }
   }
   int l_ind_counted_4 = IndicatorCounted();
   int li_8 = Bars - l_ind_counted_4;
   if (li_8 > 0) li_8--;
   if (li_8 < 0) return (-1);
   if (li_8 > gi_136) li_8 = gi_136;
   if (!gi_1008) li_8 = gi_136;
   double l_icustom_12 = 0;
   double l_icustom_20 = 0;
   double l_icustom_28 = 0;
   double l_icustom_36 = 0;
   for (int li_44 = li_8; li_44 >= 0; li_44--) {
      l_icustom_12 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "LoadTrendFinder", 0, li_44);
      l_icustom_20 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "LoadTrendFinder", 1, li_44);
      l_icustom_28 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "LoadTrendFinder", 0, li_44 + 1);
      l_icustom_36 = iCustom(Symbol(), 0, "FXI+DelphiScalper", "LoadTrendFinder", 1, li_44 + 1);
      if (l_icustom_28 == 0.0 && l_icustom_12 != 0.0 && TimeHour(Time[li_44]) >= HourStart && TimeHour(Time[li_44]) < HourEnd) {
         if (ObjectFind("FXI_StrengthScalpL_" + Time[li_44]) == -1) {
            ObjectCreate("FXI_StrengthScalpL_" + Time[li_44], OBJ_ARROW, 0, Time[li_44], Low[li_44] - 10.0 * Point);
            ObjectSet("FXI_StrengthScalpL_" + Time[li_44], OBJPROP_ARROWCODE, 233);
            ObjectSet("FXI_StrengthScalpL_" + Time[li_44], OBJPROP_COLOR, Green);
            ObjectSet("FXI_StrengthScalpL_" + Time[li_44], OBJPROP_WIDTH, 2);
         }
      }
      if (l_icustom_36 == 0.0 && l_icustom_20 != 0.0 && TimeHour(Time[li_44]) >= HourStart && TimeHour(Time[li_44]) < HourEnd) {
         if (ObjectFind("FXI_StrengthScalpS_" + Time[li_44]) == -1) {
            ObjectCreate("FXI_StrengthScalpS_" + Time[li_44], OBJ_ARROW, 0, Time[li_44], High[li_44] + 10.0 * Point);
            ObjectSet("FXI_StrengthScalpS_" + Time[li_44], OBJPROP_ARROWCODE, 234);
            ObjectSet("FXI_StrengthScalpS_" + Time[li_44], OBJPROP_COLOR, Red);
            ObjectSet("FXI_StrengthScalpS_" + Time[li_44], OBJPROP_WIDTH, 2);
         }
      }
      if ((TimeHour(Time[li_44]) == gi_132 && TimeMinute(Time[li_44]) == 0 && gi_116) || (gi_120 && TimeDayOfWeek(Time[li_44]) < TimeDayOfWeek(Time[li_44 + 1])) || (gi_124 &&
         TimeDay(Time[li_44]) < TimeDay(Time[li_44 + 1])) || (gi_128 && TimeDayOfYear(Time[li_44]) < TimeDayOfYear(Time[li_44 + 1]))) {
         if (li_44 == 0) {
            g_ibuf_160[li_44] = findMashUSD("USD", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_164[li_44] = findMash2("JPY", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_168[li_44] = findMash2("EUR", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_172[li_44] = findMash2("GBP", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_176[li_44] = findMash2("CAD", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_180[li_44] = findMash2("AUD", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_184[li_44] = findMash2("NZD", PERIOD_M1, Period(), TimeCurrent());
            g_ibuf_188[li_44] = findMash2("CHF", PERIOD_M1, Period(), TimeCurrent());
         } else {
            g_ibuf_160[li_44] = findMashUSD("USD", Period(), Period(), Time[li_44]);
            g_ibuf_164[li_44] = findMash2("JPY", Period(), Period(), Time[li_44]);
            g_ibuf_168[li_44] = findMash2("EUR", Period(), Period(), Time[li_44]);
            g_ibuf_172[li_44] = findMash2("GBP", Period(), Period(), Time[li_44]);
            g_ibuf_176[li_44] = findMash2("CAD", Period(), Period(), Time[li_44]);
            g_ibuf_180[li_44] = findMash2("AUD", Period(), Period(), Time[li_44]);
            g_ibuf_184[li_44] = findMash2("NZD", Period(), Period(), Time[li_44]);
            g_ibuf_188[li_44] = findMash2("CHF", Period(), Period(), Time[li_44]);
            continue;
         }
      }
      if (li_44 == 0) {
         g_ibuf_160[li_44] = g_ibuf_160[li_44 + 1] + findMashUSD("USD", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_164[li_44] = g_ibuf_164[li_44 + 1] + findMash2("JPY", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_168[li_44] = g_ibuf_168[li_44 + 1] + findMash2("EUR", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_172[li_44] = g_ibuf_172[li_44 + 1] + findMash2("GBP", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_176[li_44] = g_ibuf_176[li_44 + 1] + findMash2("CAD", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_180[li_44] = g_ibuf_180[li_44 + 1] + findMash2("AUD", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_184[li_44] = g_ibuf_184[li_44 + 1] + findMash2("NZD", PERIOD_M1, Period(), TimeCurrent());
         g_ibuf_188[li_44] = g_ibuf_188[li_44 + 1] + findMash2("CHF", PERIOD_M1, Period(), TimeCurrent());
      } else {
         g_ibuf_160[li_44] = g_ibuf_160[li_44 + 1] + findMashUSD("USD", Period(), Period(), Time[li_44]);
         g_ibuf_164[li_44] = g_ibuf_164[li_44 + 1] + findMash2("JPY", Period(), Period(), Time[li_44]);
         g_ibuf_168[li_44] = g_ibuf_168[li_44 + 1] + findMash2("EUR", Period(), Period(), Time[li_44]);
         g_ibuf_172[li_44] = g_ibuf_172[li_44 + 1] + findMash2("GBP", Period(), Period(), Time[li_44]);
         g_ibuf_176[li_44] = g_ibuf_176[li_44 + 1] + findMash2("CAD", Period(), Period(), Time[li_44]);
         g_ibuf_180[li_44] = g_ibuf_180[li_44 + 1] + findMash2("AUD", Period(), Period(), Time[li_44]);
         g_ibuf_184[li_44] = g_ibuf_184[li_44 + 1] + findMash2("NZD", Period(), Period(), Time[li_44]);
         g_ibuf_188[li_44] = g_ibuf_188[li_44 + 1] + findMash2("CHF", Period(), Period(), Time[li_44]);
      }
   }
   doLinesIndy();
   hiliteTime();
   doTheRest();
   drawYellowLines();
   g_index_384 = 0;
   g_index_392 = 0;
   for (int l_index_48 = 0; l_index_48 <= 7; l_index_48++) fillGlobalArray(gsa_200[l_index_48]);
   buildHUD();
   if (TimeHour(Time[0]) < HourStart || TimeHour(Time[0]) >= HourEnd) Comment("-- Strength Scalp --\nNot Currently In Trading Time");
   else {
      if (TimeHour(Time[0]) >= HourStart && TimeHour(Time[0]) < HourEnd) {
         ls_52 = "-- Strength Scalp --\n";
         if (gd_348 > 0.0) {
            ls_52 = ls_52 + "Long Entry Price: " + DoubleToStr(gd_348, Digits) 
            + "\n";
            ls_52 = ls_52 + "Long Exit Price: " + DoubleToStr(gd_356, Digits) 
            + "\n";
         } else ls_52 = ls_52 + "Long Entry: N/A\n";
         if (gd_364 > 0.0) {
            ls_52 = ls_52 + "Short Entry Price: " + DoubleToStr(gd_364, Digits) 
            + "\n";
            ls_52 = ls_52 + "Short Exit Price: " + DoubleToStr(gd_372, Digits) 
            + "\n";
         } else ls_52 = ls_52 + "Short Entry: N/A";
         Comment(ls_52);
      }
   }
   gi_1008 = TRUE;
   return (0);
}

void drawYellowLines() {
   string l_name_0;
   double lda_8[100];
   double lda_12[100];
   bool li_80;
   bool li_84;
   ArrayInitialize(lda_8, 0.0);
   ArrayInitialize(lda_12, 0.0);
   int li_16 = 0;
   int li_20 = 0;
   int l_day_24 = -1;
   int l_shift_28 = -1;
   int li_32 = -1;
   int li_36 = -1;
   int li_40 = -1;
   int li_44 = -1;
   double l_high_48 = -1;
   double l_low_56 = -1;
   int l_index_64 = 0;
   string ls_unused_68 = "";
   while (TimeHour(Time[l_index_64]) < HourStart) {
      l_index_64++;
      if (l_index_64 > Bars) break;
   }
   l_day_24 = TimeDay(Time[l_index_64]);
   l_shift_28 = iBarShift(Symbol(), PERIOD_D1, Time[l_index_64]);
   while (TimeHour(Time[l_index_64]) >= HourStart) {
      if (TimeHour(Time[l_index_64]) < HourEnd && li_36 == -1) li_36 = l_index_64;
      l_index_64++;
      if (l_index_64 > Bars) break;
   }
   li_32 = l_index_64 - 1;
   while (TimeDay(Time[l_index_64]) == l_day_24) {
      if (High[l_index_64] > l_high_48 || l_high_48 == -1.0) l_high_48 = High[l_index_64];
      if (Low[l_index_64] < l_low_56 || l_low_56 == -1.0) l_low_56 = Low[l_index_64];
      if (l_index_64 > Bars) break;
      l_index_64++;
   }
   for (int li_76 = 0; li_76 < g_index_344; li_76++) {
      if (gda_196[li_76] > l_high_48 && gda_196[li_76] < iOpen(Symbol(), PERIOD_D1, l_shift_28) + gd_332) {
         lda_8[li_16] = gda_196[li_76];
         li_16++;
      }
      if (gda_196[li_76] < l_low_56 && gda_196[li_76] > iOpen(Symbol(), PERIOD_D1, l_shift_28) - gd_332) {
         lda_12[li_20] = gda_196[li_76];
         li_20++;
      }
   }
   ArraySort(lda_8, li_16, 0, MODE_ASCEND);
   ArraySort(lda_12, li_20, 0, MODE_DESCEND);
   gd_348 = -1;
   gd_356 = -1;
   gd_364 = -1;
   gd_372 = -1;
   li_40 = -1;
   li_44 = -1;
   if (li_16 >= 2) {
      for (li_76 = 0; li_76 < li_16 - 1; li_76++) {
         if (MathAbs(lda_8[li_76] - (lda_8[li_76 + 1])) >= MinDistance * Point) {
            gd_348 = lda_8[li_76];
            gd_356 = lda_8[li_76 + 1];
            li_40 = li_76;
            break;
         }
      }
   }
   if (li_20 >= 2) {
      for (li_76 = 0; li_76 < li_20 - 1; li_76++) {
         if (MathAbs(lda_12[li_76] - (lda_12[li_76 + 1])) >= MinDistance * Point) {
            gd_364 = lda_12[li_76];
            gd_372 = lda_12[li_76 + 1];
            li_44 = li_76;
            break;
         }
      }
   }
   if (gi_432) {
      if (gi_476) {
         if (ObjectFind("HighEntryLine") != -1) {
            gd_348 = ObjectGet("HighEntryLine", OBJPROP_PRICE1);
            gd_364 = ObjectGet("LowEntryLine", OBJPROP_PRICE1);
         }
      }
      li_80 = FALSE;
      li_84 = FALSE;
      for (int li_88 = li_32; li_88 >= li_36; li_88--) {
         if (gd_348 > 0.0 && !li_80) {
            while (High[li_88] > gd_348) {
               Print("Checking On Arrow...");
               Print("High Val -- ", gd_348);
               if (ObjectFind("FXI_StrengthScalpL_" + Time[li_88]) == -1) {
                  Print("None There! Modidfying.....");
                  if (g_time_1000 == Time[li_88]) break;
                  g_time_1000 = Time[li_88];
                  gd_348 = -1;
                  gd_356 = -1;
                  for (li_76 = li_40 + 1; li_76 < li_16 - 1; li_76++) {
                     if (MathAbs(lda_8[li_76] - (lda_8[li_76 + 1])) >= MinDistance * Point) {
                        gd_348 = lda_8[li_76];
                        gd_356 = lda_8[li_76 + 1];
                        li_40 = li_76;
                        break;
                     }
                  }
                  if (gd_348 == -1.0) break;
               } else {
                  li_80 = TRUE;
                  break;
               }
            }
         }
         if (gd_364 > 0.0 && !li_84) {
            while (Low[li_88] < gd_364) {
               Print("moe! checking..");
               if (ObjectFind("FXI_StrengthScalpS_" + Time[li_88]) != -1) break;
               Print("No Short Arrow Found! Making A New One...");
               if (g_time_1004 == Time[li_88]) break;
               g_time_1004 = Time[li_88];
               gd_364 = -1;
               gd_372 = -1;
               for (li_76 = li_44 + 1; li_76 < li_20 - 1; li_76++) {
                  if (MathAbs(lda_12[li_76] - (lda_12[li_76 + 1])) >= MinDistance * Point) {
                     gd_364 = lda_12[li_76];
                     gd_372 = lda_12[li_76 + 1];
                     li_44 = li_76;
                     break;
                  }
               }
               if (gd_364 == -1.0) break;
            }
         }
      }
   }
   if (EasyMode) {
      if (gd_348 > -1.0) {
         if (ObjectFind("HighEntryLine") == -1) {
            ObjectCreate("HighEntryLine", OBJ_HLINE, 0, 0, 0);
            ObjectSet("HighEntryLine", OBJPROP_COLOR, EntryColor);
            ObjectSet("HighEntryLine", OBJPROP_WIDTH, 2);
         }
         ObjectSet("HighEntryLine", OBJPROP_PRICE1, gd_348);
         if (ObjectFind("HighExitLine") == -1) {
            ObjectCreate("HighExitLine", OBJ_HLINE, 0, 0, 0);
            ObjectSet("HighExitLine", OBJPROP_COLOR, EntryColor);
            ObjectSet("HighExitLine", OBJPROP_WIDTH, 2);
         }
         ObjectSet("HighExitLine", OBJPROP_PRICE1, gd_356);
      }
   } else {
      if (gd_348 > -1.0) {
         for (li_76 = 0; li_76 < ObjectsTotal(); li_76++) {
            l_name_0 = ObjectName(li_76);
            if (ObjectGet(l_name_0, OBJPROP_PRICE1) == gd_348 && StringFind(l_name_0, "ScalpLine") != -1) {
               ObjectSet(l_name_0, OBJPROP_COLOR, EntryColor);
               ObjectSet(l_name_0, OBJPROP_WIDTH, 2);
            }
            if (ObjectGet(l_name_0, OBJPROP_PRICE1) == gd_356 && StringFind(l_name_0, "ScalpLine") != -1) {
               ObjectSet(l_name_0, OBJPROP_COLOR, EntryColor);
               ObjectSet(l_name_0, OBJPROP_WIDTH, 2);
            }
         }
      }
   }
   if (EasyMode) {
      if (gd_364 > -1.0) {
         if (ObjectFind("LowEntryLine") == -1) {
            ObjectCreate("LowEntryLine", OBJ_HLINE, 0, 0, 0);
            ObjectSet("LowEntryLine", OBJPROP_COLOR, EntryColor);
            ObjectSet("LowEntryLine", OBJPROP_WIDTH, 2);
         }
         ObjectSet("LowEntryLine", OBJPROP_PRICE1, gd_364);
         if (ObjectFind("LowExitLine") == -1) {
            ObjectCreate("LowExitLine", OBJ_HLINE, 0, 0, 0);
            ObjectSet("LowExitLine", OBJPROP_COLOR, EntryColor);
            ObjectSet("LowExitLine", OBJPROP_WIDTH, 2);
         }
         ObjectSet("LowExitLine", OBJPROP_PRICE1, gd_372);
      }
   } else {
      if (gd_364 > -1.0) {
         for (li_76 = 0; li_76 < ObjectsTotal(); li_76++) {
            l_name_0 = ObjectName(li_76);
            if (ObjectGet(l_name_0, OBJPROP_PRICE1) == gd_364) {
               ObjectSet(l_name_0, OBJPROP_COLOR, EntryColor);
               ObjectSet(l_name_0, OBJPROP_WIDTH, 2);
            }
            if (ObjectGet(l_name_0, OBJPROP_PRICE1) == gd_372) {
               ObjectSet(l_name_0, OBJPROP_COLOR, EntryColor);
               ObjectSet(l_name_0, OBJPROP_WIDTH, 2);
            }
         }
      }
   }
   gi_unused_996 = TRUE;
}

void doTheRest() {
   string l_name_12;
   double ld_0 = 0;
   if (g_day_328 != TimeDay(Time[0])) {
      g_day_328 = TimeDay(Time[0]);
      for (int li_8 = 1; li_8 <= gi_140; li_8++) ld_0 += iHigh(Symbol(), PERIOD_D1, li_8) - iLow(Symbol(), PERIOD_D1, li_8);
      gd_332 = ld_0 / gi_140;
      if (!EasyMode) {
         for (li_8 = 0; li_8 < ObjectsTotal(); li_8++) {
            l_name_12 = ObjectName(li_8);
            if (ObjectGet(l_name_12, OBJPROP_PRICE1) < Open[0] + gd_332 && ObjectGet(l_name_12, OBJPROP_PRICE1) > Open[0] - gd_332 && ObjectType(l_name_12) == 1) ObjectSet(l_name_12, OBJPROP_COLOR, ValidColor);
         }
      }
   }
}

int hiliteTime() {
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0;
   if (li_4 > 0) li_4--;
   if (li_4 < 0) return (-1);
   if (li_4 > gi_136) li_4 = gi_136;
   if (!gi_1008) li_4 = gi_136;
   if (MathAbs(Bars - g_bars_156) >= 2.0) {
      l_ind_counted_0 = 0;
      li_4 = Bars - 1;
      gi_144 = TRUE;
      Print("More Than 1 Bar Fed To Indicator...Reloading!");
   }
   g_bars_156 = Bars;
   for (int li_8 = li_4; li_8 >= 0; li_8--) {
      if (gi_144) {
         if (HourStart < HourEnd) {
            if (gi_148 == -1) {
               if (TimeHour(Time[li_8]) == HourStart) gi_148 = li_8;
            } else {
               if (TimeHour(Time[li_8]) == HourEnd) {
                  if (ObjectFind("Box_" + Time[li_8]) == -1) {
                     ObjectCreate("Box_" + Time[li_8], OBJ_RECTANGLE, 0, Time[gi_148], High[iHighest(Symbol(), 0, MODE_HIGH, gi_148 - li_8, li_8)], Time[li_8], Low[iLowest(Symbol(), 0, MODE_LOW, gi_148 - li_8, li_8)]);
                     ObjectSet("Box_" + Time[li_8], OBJPROP_COLOR, BoxColor);
                  }
                  gi_148 = -1;
               }
            }
         } else {
            if (gi_148 == -1) {
               if (TimeHour(Time[li_8]) == HourStart) gi_148 = li_8;
            } else {
               if (TimeHour(Time[li_8]) == HourEnd) {
                  if (ObjectFind("Box_" + Time[li_8]) == -1) {
                     ObjectCreate("Box_" + Time[li_8], OBJ_RECTANGLE, 0, Time[gi_148], High[iHighest(Symbol(), 0, MODE_HIGH, gi_148 - li_8, li_8)], Time[li_8], Low[iLowest(Symbol(), 0, MODE_LOW, gi_148 - li_8, li_8)]);
                     ObjectSet("Box_" + Time[li_8], OBJPROP_COLOR, BoxColor);
                  }
                  gi_148 = -1;
               }
            }
         }
      }
   }
   if (gi_144) {
      gi_144 = FALSE;
      if (gi_148 != -1) {
         gi_148 = Time[gi_148];
         if (ObjectFind("Box_" + gi_148) == -1) {
            ObjectCreate("Box_" + gi_148, OBJ_RECTANGLE, 0, Time[iBarShift(Symbol(), 0, gi_148, TRUE)], High[iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, gi_148, TRUE) +
               1, 0)], Time[0], Low[iLowest(Symbol(), 0, MODE_LOW, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
         } else {
            ObjectSet("Box_" + gi_148, OBJPROP_PRICE1, High[iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
            ObjectSet("Box_" + gi_148, OBJPROP_PRICE2, Low[iLowest(Symbol(), 0, MODE_LOW, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
            ObjectSet("Box_" + gi_148, OBJPROP_TIME2, Time[0]);
         }
      }
   } else {
      if (gi_148 == -1) {
         if (TimeHour(Time[0]) == HourStart) gi_148 = Time[0];
      } else {
         if (ObjectFind("Box_" + gi_148) == -1) {
            ObjectCreate("Box_" + gi_148, OBJ_RECTANGLE, 0, Time[iBarShift(Symbol(), 0, gi_148, TRUE)], High[iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, gi_148, TRUE) +
               1, 0)], Time[0], Low[iLowest(Symbol(), 0, MODE_LOW, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
         } else {
            ObjectSet("Box_" + gi_148, OBJPROP_PRICE1, High[iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
            ObjectSet("Box_" + gi_148, OBJPROP_PRICE2, Low[iLowest(Symbol(), 0, MODE_LOW, iBarShift(Symbol(), 0, gi_148, TRUE) + 1, 0)]);
            ObjectSet("Box_" + gi_148, OBJPROP_TIME2, Time[0]);
         }
         if (TimeHour(Time[0]) == HourEnd) gi_148 = -1;
      }
   }
   return (0);
}

void doLinesIndy() {
   if (gi_296 != iBars(Symbol(), PERIOD_M5) && gi_80) {
      loadArray(PERIOD_M5, gda_232, 0);
      gi_296 = iBars(Symbol(), PERIOD_M5);
   }
   if (gi_300 != iBars(Symbol(), PERIOD_M15) && gi_84) {
      loadArray(PERIOD_M15, gda_236, 0);
      gi_300 = iBars(Symbol(), PERIOD_M15);
   }
   if (gi_304 != iBars(Symbol(), PERIOD_M30) && gi_88) {
      loadArray(PERIOD_M30, gda_240, 0);
      gi_304 = iBars(Symbol(), PERIOD_M30);
   }
   if (gi_308 != iBars(Symbol(), PERIOD_H1) && gi_92) {
      loadArray(PERIOD_H1, gda_244, 0);
      gi_308 = iBars(Symbol(), PERIOD_H1);
   }
   if (gi_312 != iBars(Symbol(), PERIOD_H4) && gi_96) {
      loadArray(PERIOD_H4, gda_248, 0);
      gi_312 = iBars(Symbol(), PERIOD_H4);
   }
   if (gi_316 != iBars(Symbol(), PERIOD_D1) && gi_100) {
      loadArray(PERIOD_D1, gda_252, 0);
      gi_316 = iBars(Symbol(), PERIOD_D1);
   }
   if (gi_320 != iBars(Symbol(), PERIOD_W1) && gi_104) {
      loadArray(PERIOD_W1, gda_256, 0);
      gi_320 = iBars(Symbol(), PERIOD_W1);
   }
   if (gi_324 != iBars(Symbol(), PERIOD_MN1) && gi_108) {
      loadArray(PERIOD_MN1, gda_260, 0);
      gi_324 = iBars(Symbol(), PERIOD_MN1);
   }
}

void loadArray(int a_timeframe_0, double &ada_4[500][2], bool ai_8) {
   int l_datetime_20;
   string lsa_28[200];
   string l_name_32;
   int li_12 = 0;
   int li_16 = 1;
   if (ai_8) {
      for (li_12 = gi_136; li_12 >= 0; li_12--) {
         if (iHighest(Symbol(), a_timeframe_0, MODE_HIGH, gi_112 * 2 + 2, li_12) == li_12 + gi_112 + 1) {
            ada_4[li_16][0] = iHigh(Symbol(), a_timeframe_0, li_12 + gi_112 + 1);
            ada_4[li_16][1] = iTime(Symbol(), a_timeframe_0, li_12 + gi_112 + 1);
            li_16++;
         }
         if (iLowest(Symbol(), a_timeframe_0, MODE_LOW, gi_112 * 2 + 2, li_12) == li_12 + gi_112 + 1) {
            ada_4[li_16][0] = iLow(Symbol(), a_timeframe_0, li_12 + gi_112 + 1);
            ada_4[li_16][1] = iTime(Symbol(), a_timeframe_0, li_12 + gi_112 + 1);
            li_16++;
         }
      }
      Print("Number of lines created for timefame " + a_timeframe_0 + " -- ", li_16 - 1);
      ada_4[0][0] = li_16;
   } else {
      li_16 = ada_4[0][0];
      l_datetime_20 = iTime(Symbol(), a_timeframe_0, gi_136);
      for (int li_24 = 1; li_24 < li_16; li_24++) {
         if (ada_4[li_24][1] < l_datetime_20) {
            Print("Deleting Line On Period " + a_timeframe_0 + " With Time " + TimeToStr(ada_4[li_24][1], TIME_DATE|TIME_MINUTES));
            removeAndShift(ada_4, li_24, li_16);
            li_16--;
            li_24--;
         }
      }
      if (iHighest(Symbol(), a_timeframe_0, MODE_HIGH, gi_112 * 2 + 2, 0) == gi_112 + 1) {
         ada_4[li_16][0] = iHigh(Symbol(), a_timeframe_0, gi_112 + 1);
         ada_4[li_16][1] = iTime(Symbol(), a_timeframe_0, gi_112 + 1);
         li_16++;
      }
      if (iLowest(Symbol(), a_timeframe_0, MODE_LOW, gi_112 * 2 + 2, 0) == gi_112 + 1) {
         ada_4[li_16][0] = iLow(Symbol(), a_timeframe_0, gi_112 + 1);
         ada_4[li_16][1] = iTime(Symbol(), a_timeframe_0, gi_112 + 1);
         li_16++;
      }
      ada_4[0][0] = li_16;
   }
   int l_index_40 = 0;
   for (int li_44 = 0; li_44 < ObjectsTotal(); li_44++) {
      l_name_32 = ObjectName(li_44);
      if (StringFind(l_name_32, "_" + a_timeframe_0 + "_") != -1) {
         lsa_28[l_index_40] = l_name_32;
         l_index_40++;
      }
   }
   for (li_44 = 0; li_44 < l_index_40; li_44++) ObjectDelete(lsa_28[li_44]);
   for (li_44 = 0; li_44 < ada_4[0][0]; li_44++) {
      if (!EasyMode) {
         if (ObjectFind("ScalpLine_" + a_timeframe_0 + "_" + ada_4[li_44][1]) == -1) {
            ObjectCreate("ScalpLine_" + a_timeframe_0 + "_" + ada_4[li_44][1], OBJ_HLINE, 0, ada_4[li_44][1], ada_4[li_44][0]);
            ObjectSet("ScalpLine_" + a_timeframe_0 + "_" + ada_4[li_44][1], OBJPROP_COLOR, OutsideColor);
         }
      }
   }
   rebuildBigAssArray();
}

void rebuildBigAssArray() {
   g_index_344 = 0;
   ArrayInitialize(gda_196, -1);
   if (gi_80) {
      for (int l_index_0 = 0; l_index_0 < gda_232[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_232[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_84) {
      for (l_index_0 = 0; l_index_0 < gda_236[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_236[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_88) {
      for (l_index_0 = 0; l_index_0 < gda_240[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_240[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_92) {
      for (l_index_0 = 0; l_index_0 < gda_244[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_244[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_96) {
      for (l_index_0 = 0; l_index_0 < gda_248[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_248[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_100) {
      for (l_index_0 = 0; l_index_0 < gda_252[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_252[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_104) {
      for (l_index_0 = 0; l_index_0 < gda_256[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_256[l_index_0][0];
         g_index_344++;
      }
   }
   if (gi_108) {
      for (l_index_0 = 0; l_index_0 < gda_260[0][0]; l_index_0++) {
         gda_196[g_index_344] = gda_260[l_index_0][0];
         g_index_344++;
      }
   }
   Comment("Big Ass Lines -- ", g_index_344);
}

void removeAndShift(double &ada_0[500][2], int ai_4, int ai_8) {
   for (int li_12 = ai_4; li_12 < ai_8; li_12++) {
      if (li_12 == ai_8 - 1) {
         ada_0[li_12][0] = 0;
         ada_0[li_12][1] = 0;
      } else {
         ada_0[li_12][0] = ada_0[li_12 + 1][0];
         ada_0[li_12][1] = ada_0[li_12 + 1][1];
      }
   }
}

double findMash2(string as_0, int a_timeframe_8, int a_timeframe_12, int ai_16) {
   double l_point_36;
   double ld_44;
   double ld_52;
   int l_shift_80;
   double l_digits_84;
   double l_digits_92;
   int l_shift_112;
   string ls_20 = "";
   double ld_ret_28 = 0;
   int li_100 = -1;
   for (int l_index_104 = 0; l_index_104 < gi_224; l_index_104++) {
      if (StringFind(gsa_204[l_index_104], as_0, 0) != -1) {
         ls_20 = gsa_204[l_index_104];
         break;
      }
   }
   if (ls_20 == "") return (0);
   if (StringFind(ls_20, "USD") == 0) li_100 = 50;
   else li_100 = 60;
   int l_shift_76 = iBarShift(ls_20, a_timeframe_8, ai_16);
   int l_shift_108 = iBarShift(ls_20, a_timeframe_12, ai_16);
   double ld_unused_60 = 1;
   double ld_unused_68 = 1;
   for (l_index_104 = 0; l_index_104 < gi_224; l_index_104++) {
      if (gsa_204[l_index_104] != ls_20) {
         l_digits_84 = MarketInfo(ls_20, MODE_DIGITS);
         l_digits_92 = MarketInfo(gsa_204[l_index_104], MODE_DIGITS);
         l_point_36 = MarketInfo(gsa_204[l_index_104], MODE_POINT);
         l_shift_80 = iBarShift(gsa_204[l_index_104], a_timeframe_8, ai_16);
         l_shift_112 = iBarShift(gsa_204[l_index_104], a_timeframe_12, ai_16);
         if (li_100 == 50) {
            if (StringFind(gsa_204[l_index_104], "USD") == 0) {
               ld_44 = 1 / iOpen(ls_20, a_timeframe_12, l_shift_108) / (1 / iOpen(gsa_204[l_index_104], a_timeframe_12, l_shift_112));
               ld_52 = 1 / iClose(ls_20, a_timeframe_8, l_shift_76) / (1 / iClose(gsa_204[l_index_104], a_timeframe_8, l_shift_80));
               if (StringFind(ls_20, "JPY") != -1) {
                  if (Digits == 5 || Digits == 3) ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT) / 10.0;
                  else ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT);
               } else ld_ret_28 += (ld_52 - ld_44) / l_point_36;
            } else {
               ld_44 = 1 / iOpen(ls_20, a_timeframe_12, l_shift_108) / iOpen(gsa_204[l_index_104], a_timeframe_12, l_shift_112);
               ld_52 = 1 / iClose(ls_20, a_timeframe_8, l_shift_76) / iClose(gsa_204[l_index_104], a_timeframe_8, l_shift_80);
               if (StringFind(ls_20, "JPY") != -1) {
                  if (Digits == 5 || Digits == 3) ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT) / 10.0;
                  else ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT);
               } else ld_ret_28 += (ld_52 - ld_44) / l_point_36;
            }
         } else {
            if (li_100 == 60) {
               if (StringFind(gsa_204[l_index_104], "USD") == 0) {
                  ld_44 = iOpen(ls_20, a_timeframe_12, l_shift_108) / (1 / iOpen(gsa_204[l_index_104], a_timeframe_12, l_shift_112));
                  ld_52 = iClose(ls_20, a_timeframe_8, l_shift_76) / (1 / iClose(gsa_204[l_index_104], a_timeframe_8, l_shift_80));
                  if (StringFind(ls_20, "JPY") != -1) {
                     if (Digits == 5 || Digits == 3) ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT) / 10.0;
                     else ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT);
                  } else ld_ret_28 += (ld_52 - ld_44) / l_point_36;
               } else {
                  ld_44 = iOpen(ls_20, a_timeframe_12, l_shift_108) / iOpen(gsa_204[l_index_104], a_timeframe_12, l_shift_112);
                  ld_52 = iClose(ls_20, a_timeframe_8, l_shift_76) / iClose(gsa_204[l_index_104], a_timeframe_8, l_shift_80);
                  if (StringFind(ls_20, "JPY") != -1) {
                     if (Digits == 5 || Digits == 3) ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT) / 10.0;
                     else ld_ret_28 += (ld_52 - ld_44) / l_point_36 / MarketInfo(ls_20, MODE_POINT);
                  } else ld_ret_28 += (ld_52 - ld_44) / l_point_36;
               }
            }
         }
      }
   }
   return (ld_ret_28);
}

double findMashUSD(string as_unused_0, int a_timeframe_8, int a_timeframe_12, int ai_16) {
   int li_ret_20 = 0;
   int l_shift_24 = 0;
   int l_shift_28 = 0;
   for (int l_index_32 = 0; l_index_32 < gi_224; l_index_32++) {
      l_shift_24 = iBarShift(gsa_204[l_index_32], a_timeframe_8, ai_16);
      l_shift_28 = iBarShift(gsa_204[l_index_32], a_timeframe_12, ai_16);
      if (StringFind(gsa_204[l_index_32], "USD") == 0) li_ret_20 += (iClose(gsa_204[l_index_32], a_timeframe_8, l_shift_24) - iOpen(gsa_204[l_index_32], a_timeframe_12, l_shift_28)) / MarketInfo(gsa_204[l_index_32], MODE_POINT);
      else li_ret_20 += (iOpen(gsa_204[l_index_32], a_timeframe_12, l_shift_28) - iClose(gsa_204[l_index_32], a_timeframe_8, l_shift_24)) / MarketInfo(gsa_204[l_index_32], MODE_POINT);
   }
   return (li_ret_20);
}

int buildUSDPairs() {
   string l_str_concat_0;
   int l_index_8 = 0;
   for (int li_12 = 1; li_12 <= 7; li_12++) {
      l_str_concat_0 = StringConcatenate(gsa_200[0], gsa_200[li_12], gs_212);
      if (MarketInfo(l_str_concat_0, MODE_BID) > 0.0 && MarketInfo(l_str_concat_0, MODE_ASK) > 0.0) {
         gsa_204[l_index_8] = l_str_concat_0;
         l_index_8++;
         if (StringFind(gsa_200[li_12], "JPY", 0) != -1) g_count_268++;
         if (StringFind(gsa_200[li_12], "EUR", 0) != -1) g_count_272++;
         if (StringFind(gsa_200[li_12], "GBP", 0) != -1) g_count_276++;
         if (StringFind(gsa_200[li_12], "CAD", 0) != -1) g_count_280++;
         if (StringFind(gsa_200[li_12], "AUD", 0) != -1) g_count_284++;
         if (StringFind(gsa_200[li_12], "NZD", 0) != -1) g_count_288++;
         if (StringFind(gsa_200[li_12], "CHF", 0) != -1) g_count_292++;
      }
      l_str_concat_0 = StringConcatenate(gsa_200[li_12], gsa_200[0], gs_212);
      if (MarketInfo(l_str_concat_0, MODE_BID) > 0.0 && MarketInfo(l_str_concat_0, MODE_ASK) > 0.0) {
         gsa_204[l_index_8] = l_str_concat_0;
         l_index_8++;
         if (StringFind(gsa_200[li_12], "JPY", 0) != -1) g_count_268++;
         if (StringFind(gsa_200[li_12], "EUR", 0) != -1) g_count_272++;
         if (StringFind(gsa_200[li_12], "GBP", 0) != -1) g_count_276++;
         if (StringFind(gsa_200[li_12], "CAD", 0) != -1) g_count_280++;
         if (StringFind(gsa_200[li_12], "AUD", 0) != -1) g_count_284++;
         if (StringFind(gsa_200[li_12], "NZD", 0) != -1) g_count_288++;
         if (StringFind(gsa_200[li_12], "CHF", 0) != -1) g_count_292++;
      }
   }
   return (l_index_8);
}

void buildHUD() {
   buildTopThree();
   int l_window_0 = WindowFind("FXI+DelphiScalper");
   if (l_window_0 != -1) {
      if (ObjectFind("HUD_" + l_window_0 + "_Title") == -1) {
         ObjectCreate("HUD_" + l_window_0 + "_Title", OBJ_LABEL, l_window_0, 0, 0);
         ObjectSet("HUD_" + l_window_0 + "_Title", OBJPROP_XDISTANCE, 5);
         ObjectSet("HUD_" + l_window_0 + "_Title", OBJPROP_YDISTANCE, 15);
      }
      ObjectSetText("HUD_" + l_window_0 + "_Title", "Pairs Of Interest (On This Candle):", 8, "Tahoma", TextColor);
      if (ObjectFind("HUD_" + l_window_0 + "_Number1") == -1) {
         ObjectCreate("HUD_" + l_window_0 + "_Number1", OBJ_LABEL, l_window_0, 0, 0);
         ObjectSet("HUD_" + l_window_0 + "_Number1", OBJPROP_XDISTANCE, 5);
         ObjectSet("HUD_" + l_window_0 + "_Number1", OBJPROP_YDISTANCE, 30);
      }
      ObjectSetText("HUD_" + l_window_0 + "_Number1", "1) " + gsa_400[0][0] + " - " + gsa_400[0][2], 8, "Tahoma", TextColor);
      if (ObjectFind("HUD_" + l_window_0 + "_Number2") == -1) {
         ObjectCreate("HUD_" + l_window_0 + "_Number2", OBJ_LABEL, l_window_0, 0, 0);
         ObjectSet("HUD_" + l_window_0 + "_Number2", OBJPROP_XDISTANCE, 5);
         ObjectSet("HUD_" + l_window_0 + "_Number2", OBJPROP_YDISTANCE, 42);
      }
      ObjectSetText("HUD_" + l_window_0 + "_Number2", "2) " + gsa_400[1][0] + " - " + gsa_400[1][2], 8, "Tahoma", TextColor);
      if (ObjectFind("HUD_" + l_window_0 + "_Number3") == -1) {
         ObjectCreate("HUD_" + l_window_0 + "_Number3", OBJ_LABEL, l_window_0, 0, 0);
         ObjectSet("HUD_" + l_window_0 + "_Number3", OBJPROP_XDISTANCE, 5);
         ObjectSet("HUD_" + l_window_0 + "_Number3", OBJPROP_YDISTANCE, 54);
      }
      ObjectSetText("HUD_" + l_window_0 + "_Number3", "3) " + gsa_400[2][0] + " - " + gsa_400[2][2], 8, "Tahoma", TextColor);
   }
}

void buildTopThree() {
   gsa_400[0][0] = "";
   gsa_400[0][1] = "0";
   gsa_400[0][2] = "";
   gsa_400[1][0] = "";
   gsa_400[1][1] = "0";
   gsa_400[1][2] = "";
   gsa_400[2][0] = "";
   gsa_400[2][1] = "0";
   gsa_400[2][2] = "";
   for (int l_index_0 = 0; l_index_0 < g_index_384; l_index_0++) {
      if (StrToDouble(gsa_380[l_index_0][1]) > StrToDouble(gsa_400[0][1])) {
         gsa_400[2][0] = gsa_400[1][0];
         gsa_400[2][1] = gsa_400[1][1];
         gsa_400[2][2] = gsa_400[1][2];
         gsa_400[1][0] = gsa_400[0][0];
         gsa_400[1][1] = gsa_400[0][1];
         gsa_400[1][2] = gsa_400[0][2];
         gsa_400[0][0] = gsa_380[l_index_0][0];
         gsa_400[0][1] = gsa_380[l_index_0][1];
         gsa_400[0][2] = gsa_380[l_index_0][2];
      } else {
         if (StrToDouble(gsa_380[l_index_0][1]) > StrToDouble(gsa_400[1][1])) {
            gsa_400[2][0] = gsa_400[1][0];
            gsa_400[2][1] = gsa_400[1][1];
            gsa_400[2][2] = gsa_400[1][2];
            gsa_400[1][0] = gsa_380[l_index_0][0];
            gsa_400[1][1] = gsa_380[l_index_0][1];
            gsa_400[1][2] = gsa_380[l_index_0][2];
         } else {
            if (StrToDouble(gsa_380[l_index_0][1]) > StrToDouble(gsa_400[2][1])) {
               gsa_400[2][0] = gsa_380[l_index_0][0];
               gsa_400[2][1] = gsa_380[l_index_0][1];
               gsa_400[2][2] = gsa_380[l_index_0][2];
            }
         }
      }
   }
   for (l_index_0 = 0; l_index_0 < g_index_392; l_index_0++) {
      if (StrToDouble(gsa_388[l_index_0][1]) > StrToDouble(gsa_400[0][1])) {
         gsa_400[2][0] = gsa_400[1][0];
         gsa_400[2][1] = gsa_400[1][1];
         gsa_400[2][2] = gsa_400[1][2];
         gsa_400[1][0] = gsa_400[0][0];
         gsa_400[1][1] = gsa_400[0][1];
         gsa_400[1][2] = gsa_400[0][2];
         gsa_400[0][0] = gsa_388[l_index_0][0];
         gsa_400[0][1] = gsa_388[l_index_0][1];
         gsa_400[0][2] = gsa_388[l_index_0][2];
      } else {
         if (StrToDouble(gsa_388[l_index_0][1]) > StrToDouble(gsa_400[1][1])) {
            gsa_400[2][0] = gsa_400[1][0];
            gsa_400[2][1] = gsa_400[1][1];
            gsa_400[2][2] = gsa_400[1][2];
            gsa_400[1][0] = gsa_388[l_index_0][0];
            gsa_400[1][1] = gsa_388[l_index_0][1];
            gsa_400[1][2] = gsa_388[l_index_0][2];
         } else {
            if (StrToDouble(gsa_388[l_index_0][1]) > StrToDouble(gsa_400[2][1])) {
               gsa_400[2][0] = gsa_388[l_index_0][0];
               gsa_400[2][1] = gsa_388[l_index_0][1];
               gsa_400[2][2] = gsa_388[l_index_0][2];
            }
         }
      }
   }
}

void fillGlobalArray(string as_0) {
   string l_str_concat_8;
   int li_16 = 0;
   int li_20 = 0;
   for (int l_index_24 = 0; l_index_24 <= 7; l_index_24++) {
      if (as_0 != gsa_200[l_index_24]) {
         l_str_concat_8 = StringConcatenate(as_0, gsa_200[l_index_24], gs_212);
         if (MarketInfo(l_str_concat_8, MODE_BID) > 0.0 && MarketInfo(l_str_concat_8, MODE_ASK) > 0.0) {
            li_16 = isAlligator(as_0, gsa_200[l_index_24], 70);
            li_20 = isAlligator(as_0, gsa_200[l_index_24], 80);
            if (li_16 > 0) addToArray(l_str_concat_8, li_16, 70, as_0, gsa_200[l_index_24]);
            if (li_20 > 0) addToArray(l_str_concat_8, li_20, 80, as_0, gsa_200[l_index_24]);
         }
         l_str_concat_8 = StringConcatenate(gsa_200[l_index_24], as_0, gs_212);
         if (MarketInfo(l_str_concat_8, MODE_BID) > 0.0 && MarketInfo(l_str_concat_8, MODE_ASK) > 0.0) {
            li_16 = isAlligator(as_0, gsa_200[l_index_24], 70);
            if (li_16 > 0) addToArray(l_str_concat_8, li_16, 70, as_0, gsa_200[l_index_24]);
            li_20 = isAlligator(as_0, gsa_200[l_index_24], 80);
            if (li_20 > 0) addToArray(l_str_concat_8, li_20, 80, as_0, gsa_200[l_index_24]);
         }
      }
   }
}

void addToArray(string as_0, int ai_8, int ai_12, string as_16, string as_24) {
   int li_32 = gi_396;
   if (ai_12 == 70) {
      for (int l_index_36 = 0; l_index_36 < g_index_384; l_index_36++)
         if (gsa_380[l_index_36][0] == as_0) return;
      if (li_32 == 90) {
         if (StringFind(as_0, as_16) == 0) gsa_380[g_index_384][2] = "LONG";
         else gsa_380[g_index_384][2] = "SHORT";
      } else {
         if (StringFind(as_0, as_24) == 0) gsa_380[g_index_384][2] = "LONG";
         else gsa_380[g_index_384][2] = "SHORT";
      }
      gsa_380[g_index_384][0] = as_0;
      gsa_380[g_index_384][1] = DoubleToStr(ai_8, Digits);
      g_index_384++;
   }
   if (ai_12 == 80) {
      for (l_index_36 = 0; l_index_36 < g_index_392; l_index_36++)
         if (gsa_388[l_index_36][0] == as_0) return;
      if (li_32 == 90) {
         if (StringFind(as_0, as_16) == 0) gsa_388[g_index_392][2] = "SHORT";
         else gsa_388[g_index_392][2] = "LONG";
      } else {
         if (StringFind(as_0, as_24) == 0) gsa_388[g_index_392][2] = "SHORT";
         else gsa_388[g_index_392][2] = "LONG";
      }
      gsa_388[g_index_392][0] = as_0;
      gsa_388[g_index_392][1] = DoubleToStr(ai_8, Digits);
      g_index_392++;
   }
}

int isAlligator(string as_0, string as_8, int ai_16) {
   gi_396 = -1;
   double ld_unused_20 = 0;
   double ld_unused_28 = 0;
   double ld_36 = 0;
   double ld_44 = 0;
   double ld_52 = 0;
   double ld_60 = 0;
   int li_unused_68 = 0;
   if (as_0 == "USD") {
      ld_unused_20 = g_ibuf_160[0];
      ld_36 = g_ibuf_160[0];
      ld_44 = g_ibuf_160[1];
   }
   if (as_0 == "JPY") {
      ld_unused_20 = g_ibuf_164[0];
      ld_36 = g_ibuf_164[0];
      ld_44 = g_ibuf_164[1];
   }
   if (as_0 == "EUR") {
      ld_unused_20 = g_ibuf_168[0];
      ld_36 = g_ibuf_168[0];
      ld_44 = g_ibuf_168[1];
   }
   if (as_0 == "GBP") {
      ld_unused_20 = g_ibuf_172[0];
      ld_36 = g_ibuf_172[0];
      ld_44 = g_ibuf_172[1];
   }
   if (as_0 == "CAD") {
      ld_unused_20 = g_ibuf_176[0];
      ld_36 = g_ibuf_176[0];
      ld_44 = g_ibuf_176[1];
   }
   if (as_0 == "AUD") {
      ld_unused_20 = g_ibuf_180[0];
      ld_36 = g_ibuf_180[0];
      ld_44 = g_ibuf_180[1];
   }
   if (as_0 == "NZD") {
      ld_unused_20 = g_ibuf_184[0];
      ld_36 = g_ibuf_184[0];
      ld_44 = g_ibuf_184[1];
   }
   if (as_0 == "CHF") {
      ld_unused_20 = g_ibuf_188[0];
      ld_36 = g_ibuf_188[0];
      ld_44 = g_ibuf_188[1];
   }
   if (as_8 == "USD") {
      ld_unused_28 = g_ibuf_160[0];
      ld_52 = g_ibuf_160[0];
      ld_60 = g_ibuf_160[1];
   }
   if (as_8 == "JPY") {
      ld_unused_28 = g_ibuf_164[0];
      ld_52 = g_ibuf_164[0];
      ld_60 = g_ibuf_164[1];
   }
   if (as_8 == "EUR") {
      ld_unused_28 = g_ibuf_168[0];
      ld_52 = g_ibuf_168[0];
      ld_60 = g_ibuf_168[1];
   }
   if (as_8 == "GBP") {
      ld_unused_28 = g_ibuf_172[0];
      ld_52 = g_ibuf_172[0];
      ld_60 = g_ibuf_172[1];
   }
   if (as_8 == "CAD") {
      ld_unused_28 = g_ibuf_176[0];
      ld_52 = g_ibuf_176[0];
      ld_60 = g_ibuf_176[1];
   }
   if (as_8 == "AUD") {
      ld_unused_28 = g_ibuf_180[0];
      ld_52 = g_ibuf_180[0];
      ld_60 = g_ibuf_180[1];
   }
   if (as_8 == "NZD") {
      ld_unused_28 = g_ibuf_184[0];
      ld_52 = g_ibuf_184[0];
      ld_60 = g_ibuf_184[1];
   }
   if (as_8 == "CHF") {
      ld_unused_28 = g_ibuf_188[0];
      ld_52 = g_ibuf_188[0];
      ld_60 = g_ibuf_188[1];
   }
   if (ld_36 > ld_52) {
      gi_396 = 90;
      if (ai_16 == 70) {
         if (!(ld_36 > ld_44 && ld_52 < ld_60)) return (-1);
         return (MathAbs(ld_36 - ld_52));
      }
      if (ld_36 < ld_44 && ld_52 > ld_60) return (MathAbs(ld_52 - ld_36));
   } else {
      gi_396 = 100;
      if (ai_16 == 70) {
         if (!(ld_36 < ld_44 && ld_52 > ld_60)) return (-1);
         return (MathAbs(ld_52 - ld_36));
      }
      if (ld_36 > ld_44 && ld_52 < ld_60) return (MathAbs(ld_36 - ld_52));
   }
   return (-1);
}

int downloadData(string a_symbol_0, int a_timeframe_8) {
   int li_unused_12 = 1;
   if (!IsConnected()) return (-2);
   RefreshRates();
   if (MarketInfo(a_symbol_0, MODE_BID) == iClose(a_symbol_0, a_timeframe_8, 0)) return (0);
   return (-1);
}