/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "basic Trix formula by Luis Damiani, all mods by Cobraforex, forbidden to distribute without permission of Cobraforex"
#property link      "www.cobraforex.com"

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Crimson
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Lime
#property indicator_color6 Red

string gs_unused_76 = "Hey, if you see this message you used either a decompiler or got";
string gs_unused_84 = "this indi on another ilegal source, my decision is not to share the mq4";
string gs_unused_92 = "and you should respect that, I will get really pissed off if I see my";
string gs_unused_100 = "work copied somewhere else.";
string gs_unused_108 = "I can be your best friend but also you worst enemy, you choose.";
string gs_unused_116 = " - Cobra -";
extern int Fast_Trix_period = 20;
extern int Slow_Trix_period = 35;
string gs_unused_132 = "===Trix level colors===";
int gi_140 = 2237106;
int gi_144 = 255;
int gi_148 = 6908265;
int gi_152 = 25600;
int gi_156 = 65280;
int gi_160 = 2;
int gi_164 = 0;
extern string note2 = "===Cobra Label===";
int g_window_176 = 0;
int gi_unused_180 = 30583;
int gi_unused_184 = 30583;
int g_color_188 = Green;
int gi_192 = 10;
int gi_196 = 35;
extern color Chart_Color = C'0x23,0x23,0x23';
string gs_unused_204 = "===OB/OS level colors===";
int gi_212 = 40;
int gi_216 = 60;
int gi_220 = 10240;
int gi_224 = 15360;
extern string note3 = "===== Alert Settings =====";
extern bool MsgAlerts = FALSE;
extern bool SoundAlerts = FALSE;
extern bool eMailAlerts = FALSE;
extern bool Alerts_on_OB_OS = TRUE;
extern bool Alert_On_Trix_Zero_Cross = TRUE;
extern bool Alert_On_Fast_Slow_Trix_Cross = TRUE;
extern bool Alert_On_Fast_Trix_Color_Change = TRUE;
extern string note4 = "===Sound files user defined===";
extern string Sound_On_Fast_Trix_Color_Change = "analyze exit.wav";
extern string AnalyseBuySound = "analyze buy.wav";
extern string AnalyseSellSound = "analyze sell.wav";
extern string Sound_On_Fast_Trix_Zero_Cross = "trixcross.wav";
extern string OSsound = "TrixOS.wav";
extern string OBsound = "TrixOB.wav";
extern string note5 = "=Where to place the alarm labels=";
extern int AnalyzeBoxWindow = 1;
extern int AnalyzeBoxCorner = 1;
extern bool Trix_back = TRUE;
int gi_unused_340 = 0;
double gd_344 = 0.0;
extern string note6 = "=How many Trix bars in history=";
extern int Max_Trix_Bars_Back = 750;
int gi_364 = 0;
int gi_368 = 0;
double gd_372 = 1.2;
double g_ibuf_380[];
double g_ibuf_384[];
double g_ibuf_388[];
double g_ibuf_392[];
double g_ibuf_396[];
double g_ibuf_400[];
double gd_404;
double gd_412;
int g_bars_420;
string gs_424;
string gs_432;
datetime g_time_440;
datetime g_time_444;
extern string note7 = "*** Divergence Settings ***";
extern int Max_Divergence_Bars = 500;
extern bool drawPriceTrendLines = FALSE;
extern bool drawIndicatorTrendLines = FALSE;
extern bool ShowIn1MChart = FALSE;
extern string note8 = "--- Divergence Alert Settings ---";
extern bool EnableAlerts = FALSE;
extern string _Info1 = "";
extern string _Info2 = "------------------------------------";
extern string _Info3 = "SoundAlertOnDivergence only works";
extern string _Info4 = "when EnableAlerts is true.";
extern string _Info5 = "";
extern string _Info6 = "If SoundAlertOnDivergence is true,";
extern string _Info7 = "then sound alert will be generated,";
extern string _Info8 = "otherwise a pop-up alert will be";
extern string _Info9 = "generated.";
extern string _Info10 = "------------------------------------";
extern string _Info11 = "";
extern bool SoundAlertOnDivergence = FALSE;
extern bool EmailDivergenceAlerts = FALSE;
extern string note9 = "--- Divergence Color Settings ---";
extern color BullishDivergenceColor = DodgerBlue;
extern color BearishDivergenceColor = FireBrick;
extern string note10 = "--- Divergence Sound Files ---";
extern string ClassicBullDivSound = "CBullishDiv.wav";
extern string ReverseBullDivSound = "RBullishDiv.wav";
extern string ClassicBearDivSound = "CBearishDiv.wav";
extern string ReverseBearDivSound = "RBearishDiv.wav";
double g_ibuf_636[];
double g_ibuf_640[];
extern color BoxColor = C'0x23,0x23,0x23';
extern color BoxColor2 = C'0x23,0x23,0x23';
extern color BoxColor3 = C'0x23,0x23,0x23';
int g_x_656 = 1;
int g_y_660 = 1;
extern string note11 = "=Market Hours Settings=";
extern int YourBroker_GMT_TimeZone = 0;
extern bool Show_Countdown = TRUE;
extern int Session_Close_Alarm_Minutes = 10;
extern string Trading_Times = "Just change above, no need to change below";
string gs_unused_692 = "";
extern string London_Settings = "<<< London settings >>>";
extern int LondonOpen_GMT = 7;
extern int LondonClose_GMT = 16;
extern color LondonColor = Orange;
string gs_unused_720 = "";
extern string NewYork_Settings = "<<< New York settings >>>";
extern int NewYorkOpen_GMT = 13;
extern int NewYorkClose_GMT = 22;
extern color NewYorkColor = Green;
string gs_unused_748 = "";
extern string Sydney_Settings = "<<< Sydney settings >>>";
extern int SydneyOpen_GMT = 1;
extern int SydneyClose_GMT = 8;
extern color SydneyColor = FireBrick;
string gs_unused_776 = "";
extern string Tokyo_Settings = "<<< Tokyo settings >>>";
extern int TokyoOpen_GMT = 0;
extern int TokyoClose_GMT = 9;
extern color TokyoColor = C'0x53,0x53,0xFF';
string gs_unused_804 = "";
string gs_unused_812 = "<<< Market Session Settings >>>";
int gi_820 = 5;
int gi_824 = 5;
int g_fontsize_828 = 9;
string g_fontname_832 = "Arial Bold";
int gi_840 = 0;
int gi_844 = 0;
int gi_848 = 0;
int gi_852 = 0;
int gi_856 = 0;
int gi_860 = 0;
int gi_864 = 0;
int gi_868 = 0;
int gi_872 = 0;
double gd_unused_876 = 0.0;
string gs_unused_884 = "Change pRICE font colors automatically? True = Yes";
bool gi_892 = TRUE;
string gs_unused_896 = "Default Font Color";
int g_color_904 = Black;
int g_fontsize_908 = 14;
string g_fontname_912 = "Arial Bold";
int gi_unused_920 = 3;
int gi_unused_924 = 1;
int gi_unused_928 = 20;
double g_bid_932;
double gd_940;
double gd_948;
bool gi_956 = FALSE;
bool gi_960 = FALSE;
bool gi_964 = FALSE;
bool gi_968 = FALSE;
extern bool Basic_Info = FALSE;
extern bool Show_Divergence_Arrows = TRUE;
extern bool Show_Price = TRUE;
bool gi_984 = TRUE;
int g_color_988 = CLR_NONE;
color g_color_992;
color g_color_996;
color g_color_1000;
int g_color_1004 = Orange;
int gi_1008 = 32768;
int gi_1012 = 2237106;
int g_color_1016 = C'0x00,0x28,0x00';
int g_color_1020 = C'0x28,0x00,0x00';
int gi_1024;
extern int CandleToUse = 0;
int g_timeframe_1032 = PERIOD_M5;
extern string Signal = " === THV Signal settings ===";
extern bool Trade_GLD_Oil = FALSE;
extern bool Signal_Sound = TRUE;
extern bool Scalp_mode = TRUE;
int gi_unused_1056 = 6;
extern bool Use_Coral_1M = TRUE;
extern bool Coral_next_TF = TRUE;
extern bool ChangeChartColor = TRUE;
extern bool Intro = FALSE;
int g_x_1076 = 1;
int g_y_1080 = 1;
string g_text_1084;

int init() {
   gi_840 = LondonOpen_GMT + YourBroker_GMT_TimeZone;
   if (gi_840 >= 24) gi_840 -= 24;
   if (gi_840 < 0) gi_840 += 24;
   gi_844 = LondonClose_GMT + YourBroker_GMT_TimeZone;
   if (gi_844 >= 24) gi_844 -= 24;
   if (gi_844 < 0) gi_844 += 24;
   gi_848 = NewYorkOpen_GMT + YourBroker_GMT_TimeZone;
   if (gi_848 >= 24) gi_848 -= 24;
   if (gi_848 < 0) gi_848 += 24;
   gi_852 = NewYorkClose_GMT + YourBroker_GMT_TimeZone;
   if (gi_852 >= 24) gi_852 -= 24;
   if (gi_852 < 0) gi_852 += 24;
   gi_856 = SydneyOpen_GMT + YourBroker_GMT_TimeZone;
   if (gi_856 >= 24) gi_856 -= 24;
   if (gi_856 < 0) gi_856 += 24;
   gi_860 = SydneyClose_GMT + YourBroker_GMT_TimeZone;
   if (gi_860 >= 24) gi_860 -= 24;
   if (gi_860 < 0) gi_860 += 24;
   gi_864 = TokyoOpen_GMT + YourBroker_GMT_TimeZone;
   if (gi_864 >= 24) gi_864 -= 24;
   if (gi_864 < 0) gi_864 += 24;
   gi_868 = TokyoClose_GMT + YourBroker_GMT_TimeZone;
   if (gi_868 >= 24) gi_868 -= 24;
   if (gi_868 < 0) gi_868 += 24;
   IndicatorBuffers(8);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_384);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, g_ibuf_388);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, g_ibuf_396);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, g_ibuf_400);
   if (Show_Divergence_Arrows == TRUE) {
      SetIndexBuffer(4, g_ibuf_636);
      SetIndexBuffer(5, g_ibuf_640);
   }
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexStyle(5, DRAW_ARROW);
   SetIndexArrow(4, 233);
   SetIndexArrow(5, 234);
   SetIndexDrawBegin(5, 9);
   IndicatorDigits(Digits + 2);
   SetIndexBuffer(6, g_ibuf_392);
   SetIndexBuffer(7, g_ibuf_380);
   gs_424 = "THV4 Trix V" + "1" + "." + "0";
   gs_432 = gs_424;
   IndicatorShortName(gs_424);
   return (0);
}

int deinit() {
   DeleteObjects("Trix_");
   Comment("");
   return (0);
}

void drawLine(string a_name_0, double a_price_8, color a_color_16, int a_style_20) {
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_HLINE, WindowFind(gs_424), Time[0], a_price_8);
   ObjectSet(a_name_0, OBJPROP_STYLE, a_style_20);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_16);
   ObjectSet(a_name_0, OBJPROP_WIDTH, 1);
   ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
}

void DeleteObjects(string as_0) {
   string l_name_8;
   for (int li_16 = ObjectsTotal() - 1; li_16 >= 0; li_16--) {
      l_name_8 = ObjectName(li_16);
      if (StringFind(l_name_8, as_0) > -1) ObjectDelete(l_name_8);
   }
   ObjectDelete("TrixBoxb");
   ObjectDelete("aTrixBox");
   ObjectDelete("cobratext1");
   ObjectDelete("cobratext2");
   ObjectDelete("cobratext3");
   ObjectDelete("Trix_Market_Price_Label");
   ObjectDelete("user_name");
   ObjectDelete("Exit_Label" + Time[0]);
   ObjectDelete("Order_Crossing_Label");
   ObjectDelete("aTrix_Label_back");
   ObjectDelete("aTrix_Label_backa");
   ObjectDelete("aTrix_Label_backb");
   ObjectDelete("aTrix_Label_backc");
   ObjectDelete("aTrix_Label_backd");
   ObjectDelete("aTrix_Label_backe");
   ObjectDelete("THVPair");
   ObjectDelete("THVTF");
   ObjectDelete("CobraCom");
   ObjectDelete("LWMAlabel");
   ObjectDelete("Cloud_Box");
   ObjectDelete("Coral5_Box");
   ObjectDelete("Trix_Box");
   ObjectDelete("Coral_Box");
   ObjectDelete("aChart_Box");
   ObjectDelete("aChart_Boxd");
   ObjectDelete("Coral_Error");
   ObjectDelete("Intro_Box");
   ObjectDelete("xintro");
   ObjectDelete("xintro1");
   ObjectDelete("xintro2");
   ObjectDelete("xintro3");
   ObjectDelete("xintro4");
   ObjectDelete("xintro5");
   ObjectDelete("xintro6");
   ObjectDelete("xintro7");
   ObjectDelete("xintro8");
}

int start() {
   if (Intro == TRUE) {
      ObjectCreate("Intro_Box", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("Intro_Box", "g", 1500, "Webdings");
      ObjectSet("Intro_Box", OBJPROP_CORNER, 1);
      ObjectSet("Intro_Box", OBJPROP_XDISTANCE, 1);
      ObjectSet("Intro_Box", OBJPROP_YDISTANCE, 1);
      ObjectSet("Intro_Box", OBJPROP_COLOR, Black);
      ObjectSet("Intro_Box", OBJPROP_BACK, FALSE);
      ObjectCreate("xintro", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro", "Before you Start:", 16, "Arial Black", FireBrick);
      ObjectSet("xintro", OBJPROP_BACK, FALSE);
      ObjectSet("xintro", OBJPROP_XDISTANCE, 300);
      ObjectSet("xintro", OBJPROP_YDISTANCE, 30);
      ObjectCreate("xintro1", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro1", "Make sure you studied enough about THV trading.", 14, "Arial Black", Gray);
      ObjectSet("xintro1", OBJPROP_BACK, FALSE);
      ObjectSet("xintro1", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro1", OBJPROP_YDISTANCE, 90);
      ObjectCreate("xintro2", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro2", "This indicator gives scalp signals, but you need to have good ", 14, "Arial Black", Gray);
      ObjectSet("xintro2", OBJPROP_BACK, FALSE);
      ObjectSet("xintro2", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro2", OBJPROP_YDISTANCE, 130);
      ObjectCreate("xintro3", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro3", "additional reasons to take a signal trade like bounce from S&R,", 14, "Arial Black", Gray);
      ObjectSet("xintro3", OBJPROP_BACK, FALSE);
      ObjectSet("xintro3", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro3", OBJPROP_YDISTANCE, 170);
      ObjectCreate("xintro4", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro4", "Pivots, Divergence etc.", 14, "Arial Black", Gray);
      ObjectSet("xintro4", OBJPROP_BACK, FALSE);
      ObjectSet("xintro4", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro4", OBJPROP_YDISTANCE, 210);
      ObjectCreate("xintro5", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro5", "Analyse first on your 15M and higher chart to trigger the Trend", 14, "Arial Black", Gray);
      ObjectSet("xintro5", OBJPROP_BACK, FALSE);
      ObjectSet("xintro5", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro5", OBJPROP_YDISTANCE, 270);
      ObjectCreate("xintro6", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro6", "    Practice on demo before you risk you equity, please !!!", 14, "Arial Black", Orange);
      ObjectSet("xintro6", OBJPROP_BACK, FALSE);
      ObjectSet("xintro6", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro6", OBJPROP_YDISTANCE, 340);
      ObjectCreate("xintro7", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro7", "Go to THV4 Trix properties and set \'Intro\' to false to begin.", 14, "Arial Black", Gray);
      ObjectSet("xintro7", OBJPROP_BACK, FALSE);
      ObjectSet("xintro7", OBJPROP_XDISTANCE, 100);
      ObjectSet("xintro7", OBJPROP_YDISTANCE, 430);
      ObjectCreate("xintro8", OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSetText("xintro8", "Cobra", 17, "Arial italic", Gray);
      ObjectSet("xintro8", OBJPROP_BACK, FALSE);
      ObjectSet("xintro8", OBJPROP_XDISTANCE, 350);
      ObjectSet("xintro8", OBJPROP_YDISTANCE, 470);
   }
   int li_0 = 20;
   int li_4 = 0;
   int l_count_8 = 0;
   int li_12 = 0;
   int li_16 = 0;
   if (Basic_Info) gd_948 = -70;
   if (isMarketOpen(gi_840, gi_844, Time[0])) {
      l_count_8++;
      li_4 = (l_count_8 - 1) * li_0;
      if (gi_872 > 1) g_text_1084 = "London        (" + gi_872 + " hours left)";
      else {
         li_12 = 60 - TimeMinute(TimeCurrent());
         if (li_12 > 1) {
            g_text_1084 = "London (" + li_12 + " minutes left)";
            if (li_12 <= Session_Close_Alarm_Minutes && !gi_956) {
               Alert("London closing in " + li_12 + " minutes time.");
               gi_956 = TRUE;
            }
         } else {
            li_16 = 60 - TimeSeconds(TimeCurrent());
            if (!gi_956) {
               Alert("London closing in " + li_16 + " seconds time.");
               gi_956 = TRUE;
            }
            g_text_1084 = "London Session (" + li_16 + " seconds left)";
         }
      }
      if (!Show_Countdown) g_text_1084 = "London";
      ObjectDelete("LondonLabel");
      ObjectCreate("LondonLabel", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("LondonLabel", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("LondonLabel", OBJPROP_XDISTANCE, gi_820 + 6);
      ObjectSet("LondonLabel", OBJPROP_YDISTANCE, gi_824 + li_4 + gd_948);
      ObjectSet("LondonLabel", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("LondonLabel", g_text_1084, g_fontsize_828, g_fontname_832, LondonColor);
   } else {
      ObjectDelete("LondonLabel");
      gi_956 = FALSE;
   }
   if (isMarketOpen(gi_848, gi_852, Time[0])) {
      l_count_8++;
      li_4 = (l_count_8 - 1) * li_0;
      if (gi_872 > 1) g_text_1084 = "New York    (" + gi_872 + " hours left)";
      else {
         li_12 = 60 - TimeMinute(TimeCurrent());
         if (li_12 > 1) {
            g_text_1084 = "New York  (" + li_12 + " minutes left)";
            if (li_12 <= Session_Close_Alarm_Minutes && !gi_960) {
               Alert("New York  closing in " + li_12 + " minutes time.");
               gi_960 = TRUE;
            }
         } else {
            li_16 = 60 - TimeSeconds(TimeCurrent());
            if (!gi_960) {
               Alert("New York  closing in " + li_16 + " seconds time.");
               gi_960 = TRUE;
            }
            g_text_1084 = "New York  (" + li_16 + " seconds left)";
         }
      }
      if (!Show_Countdown) g_text_1084 = "New York";
      ObjectDelete("NewYorkLabel");
      ObjectCreate("NewYorkLabel", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("NewYorkLabel", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("NewYorkLabel", OBJPROP_XDISTANCE, gi_820 + 6);
      ObjectSet("NewYorkLabel", OBJPROP_YDISTANCE, gi_824 + li_4 + gd_948);
      ObjectSet("NewYorkLabel", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("NewYorkLabel", g_text_1084, g_fontsize_828, g_fontname_832, NewYorkColor);
   } else {
      ObjectDelete("NewYorkLabel");
      gi_960 = FALSE;
   }
   if (isMarketOpen(gi_856, gi_860, Time[0])) {
      l_count_8++;
      li_4 = (l_count_8 - 1) * li_0;
      if (gi_872 > 1) g_text_1084 = "Sydney        (" + gi_872 + " hours left)";
      else {
         li_12 = 60 - TimeMinute(TimeCurrent());
         if (li_12 > 1) {
            g_text_1084 = "Sydney  (" + li_12 + " minutes left)";
            if (li_12 <= Session_Close_Alarm_Minutes && !gi_964) {
               Alert("Sydney closing in " + li_12 + " minutes time.");
               gi_964 = TRUE;
            }
         } else {
            li_16 = 60 - TimeSeconds(TimeCurrent());
            if (!gi_964) {
               Alert("Sydney  closing in " + li_16 + " seconds time.");
               gi_964 = TRUE;
            }
            g_text_1084 = "Sydney    (" + li_16 + " seconds left)";
         }
      }
      if (!Show_Countdown) g_text_1084 = "Sydney";
      ObjectDelete("SydneyLabel");
      ObjectCreate("SydneyLabel", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("SydneyLabel", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("SydneyLabel", OBJPROP_XDISTANCE, gi_820 + 6);
      ObjectSet("SydneyLabel", OBJPROP_YDISTANCE, gi_824 + li_4 + gd_948);
      ObjectSet("SydneyLabel", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("SydneyLabel", g_text_1084, g_fontsize_828, g_fontname_832, SydneyColor);
   } else {
      ObjectDelete("SydneyLabel");
      gi_964 = FALSE;
   }
   if (isMarketOpen(gi_864, gi_868, Time[0])) {
      l_count_8++;
      li_4 = (l_count_8 - 1) * li_0;
      if (gi_872 > 1) g_text_1084 = "Tokyo           (" + gi_872 + " hours left)";
      else {
         li_12 = 60 - TimeMinute(TimeCurrent());
         if (li_12 > 1) {
            g_text_1084 = "Tokyo    (" + li_12 + " minutes left)";
            if (li_12 <= Session_Close_Alarm_Minutes && !gi_968) {
               Alert("Tokyo  closing in " + li_12 + " minutes time.");
               gi_968 = TRUE;
            }
         } else {
            li_16 = 60 - TimeSeconds(TimeCurrent());
            if (!gi_968) {
               Alert("Tokyo closing in " + li_16 + " seconds time.");
               gi_968 = TRUE;
            }
            g_text_1084 = "Tokyo (" + li_16 + " seconds left)";
         }
      }
      if (!Show_Countdown) g_text_1084 = "Tokyo";
      ObjectDelete("TokyoLabel");
      ObjectCreate("TokyoLabel", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("TokyoLabel", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("TokyoLabel", OBJPROP_XDISTANCE, gi_820 + 6);
      ObjectSet("TokyoLabel", OBJPROP_YDISTANCE, gi_824 + li_4 + gd_948);
      ObjectSet("TokyoLabel", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("TokyoLabel", g_text_1084, g_fontsize_828, g_fontname_832, TokyoColor);
   } else {
      ObjectDelete("TokyoLabel");
      gi_968 = FALSE;
   }
   return (0);
}

bool isMarketOpen(int ai_0, int ai_4, int ai_8) {
   int li_12;
   double ld_16;
   double ld_24;
   string ls_32;
   string l_text_40;
   string l_text_48;
   string l_text_56;
   string l_text_64;
   string l_text_72;
   int li_80;
   double l_icustom_84;
   double l_icustom_92;
   double l_ichimoku_100;
   double l_ichimoku_108;
   double l_icustom_116;
   double l_icustom_124;
   int l_hour_132 = TimeHour(ai_8);
   gi_872 = 0;
   if (l_hour_132 < ai_4) gi_872 = ai_4 - l_hour_132;
   if (l_hour_132 > ai_4) gi_872 = ai_4 + 24 - l_hour_132;
   if (ai_0 < ai_4 && (l_hour_132 >= ai_0 && l_hour_132 < ai_4)) return (TRUE);
   if (ai_0 > ai_4 && l_hour_132 >= ai_0 || l_hour_132 < ai_4) return (TRUE);
   if (gi_892 == TRUE) {
      if (Bid > g_bid_932) g_color_904 = LawnGreen;
      if (Bid < g_bid_932) g_color_904 = Red;
      g_bid_932 = Bid;
   }
   string ls_136 = StringSubstr(Symbol(), 3, 3);
   if (ls_136 == "JPY") li_12 = 2;
   else li_12 = 4;
   string l_dbl2str_144 = DoubleToStr(Bid, li_12);
   if (Show_Price == TRUE) {
      ObjectCreate("Trix_Market_Price_Label", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSetText("Trix_Market_Price_Label", l_dbl2str_144, g_fontsize_908, g_fontname_912, g_color_904);
      ObjectSet("Trix_Market_Price_Label", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Market_Price_Label", OBJPROP_XDISTANCE, gi_196 + 10);
      ObjectSet("Trix_Market_Price_Label", OBJPROP_YDISTANCE, gi_192 + 65 + gd_948);
   }
   int li_unused_152 = 20;
   int li_unused_156 = 0;
   int li_unused_160 = 0;
   int li_unused_164 = 0;
   int li_unused_168 = 0;
   if (AnalyzeBoxWindow == 0) g_window_176 = 1;
   /*ObjectCreate("cobratext1", OBJ_LABEL, g_window_176, 0, 0);
   ObjectSetText("cobratext1", "THV V 4", 14, "Arial Black", Black);
   ObjectSet("cobratext1", OBJPROP_CORNER, 1);
   ObjectSet("cobratext1", OBJPROP_XDISTANCE, gi_196 + 13);
   ObjectSet("cobratext1", OBJPROP_YDISTANCE, gi_192 + 1);
   ObjectSet("cobratext1", OBJPROP_BACK, FALSE);
   ObjectCreate("cobratext3", OBJ_LABEL, g_window_176, 0, 0);
   ObjectSetText("cobratext3", "", 8, "Arial", g_color_188);
   ObjectSet("cobratext3", OBJPROP_CORNER, 1);
   ObjectSet("cobratext3", OBJPROP_XDISTANCE, gi_196 + 13);
   ObjectSet("cobratext3", OBJPROP_YDISTANCE, gi_192 + 25);
   ObjectCreate("THVPair", OBJ_LABEL, g_window_176, 0, 0);
   ObjectSet("THVPair", OBJPROP_XDISTANCE, gi_196 + 10);
   ObjectSet("THVPair", OBJPROP_YDISTANCE, gi_192 + 50);
   ObjectSetText("THVPair", Symbol(), 13, "Neuropol", Black);
   ObjectSet("THVPair", OBJPROP_CORNER, 1);
   ObjectSet("THVPair", OBJPROP_BACK, FALSE);
   ObjectCreate("THVTF", OBJ_LABEL, g_window_176, 0, 0);
   ObjectSet("THVTF", OBJPROP_XDISTANCE, gd_940 + gi_196 + 18.0);
   ObjectSet("THVTF", OBJPROP_YDISTANCE, gi_192 + 76);
   ObjectSetText("THVTF", Period() + " M", 14, "Neuropol", Black);
   ObjectSet("THVTF", OBJPROP_CORNER, 1);
   ObjectSet("THVTF", OBJPROP_BACK, FALSE);
   ObjectCreate("CobraCom", OBJ_LABEL, WindowFind(gs_432), 0, 0);
   ObjectSet("CobraCom", OBJPROP_XDISTANCE, 280);
   ObjectSet("CobraCom", OBJPROP_YDISTANCE, 145);
   ObjectSetText("CobraCom", "www.cobraforex.com", 9, "Arial Bold", Black);
   ObjectSet("CobraCom", OBJPROP_CORNER, 0);
   ObjectSet("CobraCom", OBJPROP_BACK, FALSE);*/
   ObjectCreate("aTrix_Label_back", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_back", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_back", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_back", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_back", OBJPROP_YDISTANCE, g_y_660);
   ObjectSet("aTrix_Label_back", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_back", OBJPROP_BACK, FALSE);
   ObjectCreate("aTrix_Label_backa", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_backa", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_backa", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_backa", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_backa", OBJPROP_YDISTANCE, g_y_660 + 160);
   ObjectSet("aTrix_Label_backa", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_backa", OBJPROP_BACK, FALSE);
   ObjectCreate("aTrix_Label_backb", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_backb", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_backb", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_backb", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_backb", OBJPROP_YDISTANCE, g_y_660 + 320);
   ObjectSet("aTrix_Label_backb", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_backb", OBJPROP_BACK, FALSE);
   ObjectCreate("aTrix_Label_backc", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_backc", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_backc", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_backc", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_backc", OBJPROP_YDISTANCE, g_y_660 + 480);
   ObjectSet("aTrix_Label_backc", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_backc", OBJPROP_BACK, FALSE);
   ObjectCreate("aTrix_Label_backd", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_backd", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_backd", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_backd", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_backd", OBJPROP_YDISTANCE, g_y_660 + 540);
   ObjectSet("aTrix_Label_backd", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_backd", OBJPROP_BACK, FALSE);
   ObjectCreate("aTrix_Label_backe", OBJ_LABEL, g_window_176, 0, 0, 0, 0);
   ObjectSetText("aTrix_Label_backe", "g", 125, "Webdings");
   ObjectSet("aTrix_Label_backe", OBJPROP_CORNER, 1);
   ObjectSet("aTrix_Label_backe", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("aTrix_Label_backe", OBJPROP_YDISTANCE, g_y_660 + 700);
   ObjectSet("aTrix_Label_backe", OBJPROP_COLOR, Chart_Color);
   ObjectSet("aTrix_Label_backe", OBJPROP_BACK, FALSE);
   if (Period() == PERIOD_M1) gd_940 = 18;
   if (Period() == PERIOD_M5) gd_940 = 11;
   if (Period() == PERIOD_M15) gd_940 = 10;
   if (Period() == PERIOD_M30) gd_940 = 5;
   if (Period() == PERIOD_H1) gd_940 = 5;
   if (Period() == PERIOD_H4) gd_940 = -3;
   if (Period() == PERIOD_D1) gd_940 = -5;
   if (Period() == PERIOD_W1) gd_940 = -10;
   if (Period() == PERIOD_MN1) gd_940 = -15;
   if (Trix_back) {
      ObjectCreate("Trix_backa", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_backa", "g", 160, "Webdings");
      ObjectSet("Trix_backa", OBJPROP_CORNER, 1);
      ObjectSet("Trix_backa", OBJPROP_XDISTANCE, g_x_656);
      ObjectSet("Trix_backa", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_backa", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_backa", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back", "g", 160, "Webdings");
      ObjectSet("Trix_back", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back", OBJPROP_XDISTANCE, g_x_656 + 200);
      ObjectSet("Trix_back", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back1", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back1", "g", 160, "Webdings");
      ObjectSet("Trix_back1", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back1", OBJPROP_XDISTANCE, g_x_656 + 400);
      ObjectSet("Trix_back1", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back1", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back1", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back2", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back2", "g", 160, "Webdings");
      ObjectSet("Trix_back2", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back2", OBJPROP_XDISTANCE, g_x_656 + 600);
      ObjectSet("Trix_back2", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back2", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back2", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back3", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back3", "g", 160, "Webdings");
      ObjectSet("Trix_back3", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back3", OBJPROP_XDISTANCE, g_x_656 + 800);
      ObjectSet("Trix_back3", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back3", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back3", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back4", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back4", "g", 160, "Webdings");
      ObjectSet("Trix_back4", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back4", OBJPROP_XDISTANCE, g_x_656 + 1000);
      ObjectSet("Trix_back4", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back4", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back4", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back5", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back5", "g", 160, "Webdings");
      ObjectSet("Trix_back5", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back5", OBJPROP_XDISTANCE, g_x_656 + 1200);
      ObjectSet("Trix_back5", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back5", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back5", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back6", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back6", "g", 160, "Webdings");
      ObjectSet("Trix_back6", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back6", OBJPROP_XDISTANCE, g_x_656 + 1400);
      ObjectSet("Trix_back6", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back6", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back6", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back7", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back7", "g", 160, "Webdings");
      ObjectSet("Trix_back7", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back7", OBJPROP_XDISTANCE, g_x_656 + 1600);
      ObjectSet("Trix_back7", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back7", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back7", OBJPROP_BACK, TRUE);
      ObjectCreate("Trix_back8", OBJ_LABEL, WindowFind(gs_432), 0, 0, 0, 0);
      ObjectSetText("Trix_back8", "g", 160, "Webdings");
      ObjectSet("Trix_back8", OBJPROP_CORNER, 1);
      ObjectSet("Trix_back8", OBJPROP_XDISTANCE, g_x_656 + 1800);
      ObjectSet("Trix_back8", OBJPROP_YDISTANCE, g_y_660 - 1);
      ObjectSet("Trix_back8", OBJPROP_COLOR, BoxColor);
      ObjectSet("Trix_back8", OBJPROP_BACK, TRUE);
   }
   if (gi_984) ObjectCreate("TrixBoxb", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
   ObjectSetText("TrixBoxb", "g", 125, "Webdings");
   ObjectSet("TrixBoxb", OBJPROP_CORNER, AnalyzeBoxCorner);
   ObjectSet("TrixBoxb", OBJPROP_XDISTANCE, g_x_656);
   ObjectSet("TrixBoxb", OBJPROP_YDISTANCE, g_y_660 - 1);
   ObjectSet("TrixBoxb", OBJPROP_COLOR, BoxColor2);
   ObjectSet("TrixBoxb", OBJPROP_BACK, TRUE);
   if (gi_984) ObjectCreate("aTrixBox", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
   ObjectSetText("aTrixBox", "g", 122, "Webdings", BoxColor3);
   ObjectSet("aTrixBox", OBJPROP_CORNER, AnalyzeBoxCorner);
   ObjectSet("aTrixBox", OBJPROP_XDISTANCE, g_x_656 + 2);
   ObjectSet("aTrixBox", OBJPROP_YDISTANCE, g_y_660 + 1);
   ObjectSet("aTrixBox", OBJPROP_COLOR, BoxColor3);
   ObjectSet("aTrixBox", OBJPROP_BACK, FALSE);
   if (Period() == PERIOD_M1) ld_16 = 0.00018;
   if (Period() == PERIOD_M5) ld_16 = 0.00025;
   if (Period() == PERIOD_M15) ld_16 = 0.0005;
   if (Period() == PERIOD_M30) ld_16 = 0.001;
   if (Period() == PERIOD_H1) ld_16 = 0.0009;
   if (Period() == PERIOD_H4) ld_16 = 0.003;
   if (Period() == PERIOD_D1) ld_16 = 0.005;
   if (Period() == PERIOD_W1) ld_16 = 0.08;
   if (Period() == PERIOD_MN1) ld_16 = 0.015;
   if (Trade_GLD_Oil == TRUE) {
      if (Period() == PERIOD_M1) ld_16 = 0.0004;
      if (Period() == PERIOD_M5) ld_16 = 0.0006;
      if (Period() == PERIOD_M15) ld_16 = 0.0011;
      if (Period() == PERIOD_M30) ld_16 = 0.002;
      if (Period() == PERIOD_H1) ld_16 = 0.003;
      if (Period() == PERIOD_H4) ld_16 = 0.005;
      if (Period() == PERIOD_D1) ld_16 = 0.016;
      if (Period() == PERIOD_W1) ld_16 = 0.04;
      if (Period() == PERIOD_MN1) ld_16 = 0.08;
   }
   if (gd_344 > 0.0) ld_16 = gd_344;
   double ld_172 = ld_16;
   double ld_180 = -1.0 * ld_16;
   drawLine("Trix_" + "OVERBOUGHT", ld_172, gi_140, gi_160);
   drawLine("Trix_" + "ZERO_LINE", 0, gi_148, gi_160);
   drawLine("Trix_" + "OVERSOLD", ld_180, gi_152, gi_160);
   if (Period() == PERIOD_M1) ld_24 = 0.0003;
   if (Period() == PERIOD_M5) ld_24 = 0.0005;
   if (Period() == PERIOD_M15) ld_24 = 0.0008;
   if (Period() == PERIOD_M30) ld_24 = 0.0015;
   if (Period() == PERIOD_H1) ld_24 = 0.0013;
   if (Period() == PERIOD_H4) ld_24 = 0.004;
   if (Period() == PERIOD_D1) ld_24 = 0.006;
   if (Period() == PERIOD_W1) ld_24 = 0.1;
   if (Period() == PERIOD_MN1) ld_24 = 0.02;
   if (Trade_GLD_Oil == TRUE) {
      if (Period() == PERIOD_M1) ld_24 = 0.0008;
      if (Period() == PERIOD_M5) ld_24 = 0.001;
      if (Period() == PERIOD_M15) ld_24 = 0.002;
      if (Period() == PERIOD_M30) ld_24 = 0.003;
      if (Period() == PERIOD_H1) ld_24 = 0.005;
      if (Period() == PERIOD_H4) ld_24 = 0.008;
      if (Period() == PERIOD_D1) ld_24 = 0.024;
      if (Period() == PERIOD_W1) ld_24 = 0.06;
      if (Period() == PERIOD_MN1) ld_24 = 0.1;
      ObjectDelete("Trix_WTI_GLD");
      ObjectCreate("Trix_WTI_GLD", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Trix_WTI_GLD", OBJPROP_CORNER, 1);
      ObjectSet("Trix_WTI_GLD", OBJPROP_XDISTANCE, 25);
      ObjectSet("Trix_WTI_GLD", OBJPROP_YDISTANCE, 10);
      ObjectSet("Trix_WTI_GLD", OBJPROP_ANGLE, 90);
      ObjectSet("Trix_WTI_GLD", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("Trix_WTI_GLD", "OIL - GLD only", 10, "Arial Bold", LimeGreen);
   }
   if (gd_344 > 0.0) ld_24 = gd_344;
   double ld_188 = ld_24;
   double ld_196 = -1.0 * ld_24;
   drawLine("Trix_" + "EXTREME_OVERBOUGHT", ld_188, gi_144, gi_164);
   drawLine("Trix_" + "EXTREME_OVERSOLD", ld_196, gi_156, gi_164);
   int li_204 = 0;
   double ld_208 = 0;
   double ld_216 = 0;
   double ld_unused_224 = 0;
   double ld_232 = 0;
   double ld_240 = 0;
   double ld_248 = 0;
   double ld_256 = 0;
   double ld_264 = 0;
   double ld_272 = 0;
   double ld_280 = 0;
   double ld_288 = 0;
   double ld_296 = 0;
   double ld_304 = 0;
   double ld_312 = 0;
   double ld_320 = 0;
   double ld_328 = 0;
   double ld_336 = 0;
   double ld_344 = 0;
   double ld_352 = 0;
   double ld_360 = 0;
   double ld_368 = 0;
   double ld_376 = 0;
   double ld_384 = 0;
   double ld_392 = 0;
   double ld_400 = 0;
   double ld_408 = 0;
   double ld_416 = 0;
   double ld_424 = 0;
   double ld_432 = 0;
   double ld_440 = 0;
   double ld_448 = 0;
   double ld_456 = 0;
   double ld_464 = 0;
   double ld_472 = 0;
   double ld_480 = 0;
   double ld_488 = 0;
   double ld_496 = 0;
   double ld_504 = 0;
   double ld_512 = 0;
   double ld_520 = 0;
   double ld_528 = 1;
   double ld_536 = 0;
   double l_bars_544 = 0;
   double ld_552 = 0;
   double ld_560 = 0;
   double ld_568 = 0;
   double ld_576 = 0;
   string ls_584 = "nonono";
   int l_ind_counted_592 = IndicatorCounted();
   bool li_596 = TRUE;
   ld_560 = Max_Trix_Bars_Back + Fast_Trix_period + gi_364 + Slow_Trix_period + gi_368 + gd_372;
   if (ld_560 == ld_568 && ls_584 == Symbol() && ld_576 == Time[4] - Time[5] && Bars - l_bars_544 < 2.0) ld_552 = Bars - l_bars_544;
   else ld_552 = -1;
   ls_584 = Symbol();
   ld_576 = Time[4] - Time[5];
   l_bars_544 = Bars;
   ld_568 = ld_560;
   if (ld_552 == 1.0 || ld_552 == 0.0) ld_536 = ld_552;
   else ld_528 = 1;
   if (!ShowIn1MChart && Period() == PERIOD_M1) li_596 = FALSE;
   if (ld_528 == 1.0) {
      ld_512 = gd_372 * gd_372;
      ld_520 = ld_512 * gd_372;
      ld_296 = -ld_520;
      ld_304 = 3.0 * (ld_512 + ld_520);
      ld_312 = -3.0 * (2.0 * ld_512 + gd_372 + ld_520);
      ld_320 = 3.0 * gd_372 + 1.0 + ld_520 + 3.0 * ld_512;
      ld_472 = Fast_Trix_period;
      if (ld_472 < 1.0) ld_472 = 1;
      ld_472 = (ld_472 - 1.0) / 2.0 + 1.0;
      ld_480 = 2 / (ld_472 + 1.0);
      ld_488 = 1 - ld_480;
      ld_472 = Slow_Trix_period;
      if (ld_472 < 1.0) ld_472 = 1;
      ld_472 = (ld_472 - 1.0) / 2.0 + 1.0;
      ld_496 = 2 / (ld_472 + 1.0);
      ld_504 = 1 - ld_496;
      g_ibuf_380[Max_Trix_Bars_Back - 1] = 0;
      ld_424 = 0;
      ld_432 = 0;
      ld_440 = 0;
      ld_448 = 0;
      ld_456 = 0;
      ld_464 = 0;
      g_ibuf_392[Max_Trix_Bars_Back - 1] = 0;
      ld_328 = 0;
      ld_336 = 0;
      ld_344 = 0;
      ld_352 = 0;
      ld_360 = 0;
      ld_368 = 0;
      ld_536 = Max_Trix_Bars_Back - 2;
      ld_528 = 0;
   }
   if (gd_412 > ld_172) BoxColor = gi_212;
   if (gd_412 < ld_172 && gd_412 > ld_180) BoxColor = C'0x23,0x23,0x23';
   if (gd_412 < ld_180) BoxColor = gi_220;
   if (gd_412 > ld_188) BoxColor = gi_216;
   if (gd_412 < ld_196) BoxColor = gi_224;
   for (li_204 = ld_536; li_204 >= 0; li_204--) {
      if (gi_364 == 1) ld_376 = ld_480 * Open[li_204] + ld_488 * ld_424;
      else ld_376 = ld_480 * Close[li_204] + ld_488 * ld_424;
      ld_384 = ld_480 * ld_376 + ld_488 * ld_432;
      ld_392 = ld_480 * ld_384 + ld_488 * ld_440;
      ld_400 = ld_480 * ld_392 + ld_488 * ld_448;
      ld_408 = ld_480 * ld_400 + ld_488 * ld_456;
      ld_416 = ld_480 * ld_408 + ld_488 * ld_464;
      ld_208 = ld_296 * ld_416 + ld_304 * ld_408 + ld_312 * ld_400 + ld_320 * ld_392;
      if ((ld_552 == 1.0 && li_204 == 1) || ld_552 == -1.0) {
         ld_424 = ld_376;
         ld_432 = ld_384;
         ld_440 = ld_392;
         ld_448 = ld_400;
         ld_456 = ld_408;
         ld_464 = ld_416;
      }
      ld_248 = ld_496 * Close[li_204] + ld_504 * ld_328;
      ld_256 = ld_496 * ld_248 + ld_504 * ld_336;
      ld_264 = ld_496 * ld_256 + ld_504 * ld_344;
      ld_272 = ld_496 * ld_264 + ld_504 * ld_352;
      ld_280 = ld_496 * ld_272 + ld_504 * ld_360;
      ld_288 = ld_496 * ld_280 + ld_504 * ld_368;
      ld_232 = ld_296 * ld_288 + ld_304 * ld_280 + ld_312 * ld_272 + ld_320 * ld_264;
      if (gi_368 == 1) {
         g_ibuf_380[li_204] = (ld_208 - ld_216) / ld_216 + (ld_232 - ld_240) / ld_240;
         g_ibuf_392[li_204] = (ld_208 - ld_216) / ld_216;
         gd_412 = g_ibuf_392[li_204];
      } else {
         if (ld_240 > 0.0 && ld_216 > 0.0) {
            g_ibuf_380[li_204] = (ld_232 - ld_240) / ld_240;
            g_ibuf_392[li_204] = (ld_208 - ld_216) / ld_216;
            gd_412 = g_ibuf_392[li_204];
         }
      }
      g_ibuf_384[li_204] = EMPTY_VALUE;
      g_ibuf_388[li_204] = EMPTY_VALUE;
      if (g_ibuf_380[li_204 + 1] < g_ibuf_380[li_204]) {
         if (g_ibuf_384[li_204 + 1] == EMPTY_VALUE) g_ibuf_384[li_204 + 1] = g_ibuf_380[li_204 + 1];
         g_ibuf_384[li_204] = g_ibuf_380[li_204];
      } else {
         if (g_ibuf_380[li_204 + 1] > g_ibuf_380[li_204]) {
            if (g_ibuf_388[li_204 + 1] == EMPTY_VALUE) g_ibuf_388[li_204 + 1] = g_ibuf_380[li_204 + 1];
            g_ibuf_388[li_204] = g_ibuf_380[li_204];
         }
      }
      g_ibuf_396[li_204] = EMPTY_VALUE;
      g_ibuf_400[li_204] = EMPTY_VALUE;
      if (g_ibuf_392[li_204 + 1] < g_ibuf_392[li_204]) {
         if (g_ibuf_396[li_204 + 1] == EMPTY_VALUE) g_ibuf_396[li_204 + 1] = g_ibuf_392[li_204 + 1];
         g_ibuf_396[li_204] = g_ibuf_392[li_204];
      } else {
         if (g_ibuf_392[li_204 + 1] > g_ibuf_392[li_204]) {
            if (g_ibuf_400[li_204 + 1] == EMPTY_VALUE) g_ibuf_400[li_204 + 1] = g_ibuf_392[li_204 + 1];
            g_ibuf_400[li_204] = g_ibuf_392[li_204];
         }
      }
      if ((ld_552 == 1.0 && li_204 == 1) || ld_552 == -1.0) {
         ld_216 = ld_208;
         ld_240 = ld_232;
         ld_328 = ld_248;
         ld_336 = ld_256;
         ld_344 = ld_264;
         ld_352 = ld_272;
         ld_360 = ld_280;
         ld_368 = ld_288;
      }
      if (li_204 <= Max_Divergence_Bars && li_596) {
         CatchBullishDivergence(li_204 + 2);
         CatchBearishDivergence(li_204 + 2);
      }
   }
   if (gd_412 > ld_172) BoxColor = C'0x32,0x00,0x00';
   if (gd_412 < ld_172 && gd_412 > ld_180) BoxColor = C'0x23,0x23,0x23';
   if (gd_412 < ld_180) BoxColor = C'0x00,0x32,0x00';
   if (gd_412 > ld_188) BoxColor = C'0x50,0x00,0x00';
   if (gd_412 < ld_196) BoxColor = C'0x00,0x50,0x00';
   if (gd_412 > ld_172 && g_bars_420 < Bars) {
      if (gi_984) l_text_48 = "Overbought";
      ObjectDelete("Trix_OB");
      ObjectCreate("Trix_OB", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_OB", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_OB", OBJPROP_XDISTANCE, 160);
      ObjectSet("Trix_OB", OBJPROP_YDISTANCE, gd_948 + 85.0);
      ObjectSet("Trix_OB", OBJPROP_ANGLE, 90);
      ObjectSet("Trix_OB", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("Trix_OB", l_text_48, 9, "Arial Bold", LimeGreen);
      g_bars_420 = Bars;
      if (Alerts_on_OB_OS) PlaySound(OBsound);
   }
   if (gd_412 < ld_180 && g_bars_420 < Bars) {
      if (gi_984) l_text_48 = "OverSold";
      ObjectDelete("Trix_OB");
      ObjectCreate("Trix_OB", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_OB", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_OB", OBJPROP_XDISTANCE, 160);
      ObjectSet("Trix_OB", OBJPROP_YDISTANCE, gd_948 + 85.0);
      ObjectSet("Trix_OB", OBJPROP_ANGLE, 90);
      ObjectSet("Trix_OB", OBJPROP_COLOR, Red);
      ObjectSetText("Trix_OB", l_text_48, 9, "Arial Bold", Red);
      g_bars_420 = Bars;
      if (Alerts_on_OB_OS) PlaySound(OSsound);
   }
   if (gd_412 > ld_180 && gd_412 < ld_172)
      if (gi_984) ObjectDelete("Trix_OB");
   if (gd_412 < ld_196)
      if (gi_984) ObjectDelete("Trix_OB");
   if (gd_412 > ld_188)
      if (gi_984) ObjectDelete("Trix_OB");
   if (gd_412 > ld_188) {
      if (gi_984) l_text_72 = "Extreme Overbought";
      ObjectDelete("Trix_OB-E");
      ObjectCreate("Trix_OB-E", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_OB-E", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_OB-E", OBJPROP_XDISTANCE, 160);
      ObjectSet("Trix_OB-E", OBJPROP_YDISTANCE, gd_948 + 75.0);
      ObjectSet("Trix_OB-E", OBJPROP_ANGLE, 90);
      ObjectSet("Trix_OB-E", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("Trix_OB-E", l_text_72, 9, "Arial Bold", LimeGreen);
   }
   if (gd_412 < ld_196) {
      if (gi_984) l_text_72 = "Extreme OverSold";
      ObjectDelete("Trix_OB-E");
      ObjectCreate("Trix_OB-E", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_OB-E", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_OB-E", OBJPROP_XDISTANCE, 160);
      ObjectSet("Trix_OB-E", OBJPROP_YDISTANCE, gd_948 + 48.0);
      ObjectSet("Trix_OB-E", OBJPROP_COLOR, Red);
      ObjectSet("Trix_OB-E", OBJPROP_ANGLE, 90);
      ObjectSetText("Trix_OB-E", l_text_72, 9, "Arial Bold", Red);
   }
   if (gd_412 > ld_196 && gd_412 < ld_188)
      if (gi_984) ObjectDelete("Trix_OB-E");
   if (gd_412 > 0.0) {
      if (gi_984) l_text_40 = "Bull";
      ObjectDelete("Trix_Crossing_Label");
      ObjectCreate("Trix_Crossing_Label", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_Crossing_Label", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Crossing_Label", OBJPROP_XDISTANCE, 12);
      ObjectSet("Trix_Crossing_Label", OBJPROP_YDISTANCE, gd_948 + 95.0);
      ObjectSet("Trix_Crossing_Label", OBJPROP_COLOR, LimeGreen);
      ObjectSetText("Trix_Crossing_Label", l_text_40, 9, "Arial Bold", LimeGreen);
   }
   if (gd_412 < 0.0) {
      if (gi_984) l_text_40 = "Bear";
      ObjectDelete("Trix_Crossing_Label");
      ObjectCreate("Trix_Crossing_Label", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_Crossing_Label", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Crossing_Label", OBJPROP_XDISTANCE, 10);
      ObjectSet("Trix_Crossing_Label", OBJPROP_YDISTANCE, gd_948 + 95.0);
      ObjectSet("Trix_Crossing_Label", OBJPROP_COLOR, Red);
      ObjectSetText("Trix_Crossing_Label", l_text_40, 9, "Arial Bold", Red);
   }
   if (gd_404 < 0.0 && gd_412 > 0.0) {
      if (Alert_On_Trix_Zero_Cross)
         if (SoundAlerts) PlaySound(Sound_On_Fast_Trix_Zero_Cross);
   }
   gd_404 = gd_412;
   if (gi_984) {
      ObjectDelete("Trix_Trend");
      ObjectCreate("Trix_Trend", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_Trend", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Trend", OBJPROP_XDISTANCE, 70);
      ObjectSet("Trix_Trend", OBJPROP_YDISTANCE, gd_948 + 95.0);
      ObjectSetText("Trix_Trend", "Trix Cross  :", 9, "Arial", Gray);
   }
   if (gi_984) {
      ObjectDelete("Trix_Option");
      ObjectCreate("Trix_Option", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_Option", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Option", OBJPROP_XDISTANCE, 70);
      ObjectSet("Trix_Option", OBJPROP_YDISTANCE, gd_948 + 110.0);
      ObjectSetText("Trix_Option", "Option        :", 9, "Arial", Gray);
   }
   if (gi_984) {
      ObjectDelete("Trix_Action");
      ObjectCreate("Trix_Action", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_Action", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_Action", OBJPROP_XDISTANCE, 70);
      ObjectSet("Trix_Action", OBJPROP_YDISTANCE, gd_948 + 125.0);
      ObjectSetText("Trix_Action", "Action         :", 9, "Arial", Gray);
   }
   string ls_unused_600 = "  ";
   string ls_unused_608 = "  ";
   int li_616 = Time[0] + 60 * Period() - TimeCurrent();
   int li_620 = li_616 % 60;
   string ls_624 = li_620;
   if (li_620 < 10) ls_624 = "0" + ls_624;
   int li_632 = (li_616 - li_616 % 60) / 60;
   for (int l_count_636 = 0; l_count_636 < 24; l_count_636++) {
      if (li_632 >= 60) {
         li_632 -= 60;
         li_80++;
      }
   }
   string ls_640 = li_632;
   if (li_632 < 10) ls_640 = "0" + ls_640;
   string ls_648 = li_80;
   if (li_80 < 10) ls_648 = "0" + ls_648;
   string l_text_656 = ls_640 + ":" + ls_624;
   if (li_80 >= 1) l_text_656 = ls_648 + ":" + ls_640 + ":" + ls_624;
   if (Scalp_mode) {
      l_icustom_84 = iCustom(NULL, 0, "THV4 Trix called", 2, CandleToUse);
      l_icustom_92 = iCustom(NULL, 0, "THV4 Trix called", 3, CandleToUse);
      if (l_icustom_92 == EMPTY_VALUE) g_color_1004 = gi_1008;
      if (l_icustom_84 == EMPTY_VALUE) g_color_1004 = gi_1012;
      ObjectDelete("Trix_Box");
      ObjectCreate("Trix_Box", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
      ObjectSetText("Trix_Box", "0", 36, "Webdings");
      ObjectSet("Trix_Box", OBJPROP_CORNER, 1);
      ObjectSet("Trix_Box", OBJPROP_XDISTANCE, g_x_1076 + 5);
      ObjectSet("Trix_Box", OBJPROP_YDISTANCE, g_y_1080 + 26 + gd_948);
      ObjectSet("Trix_Box", OBJPROP_COLOR, g_color_1004);
      ObjectSet("Trix_Box", OBJPROP_BACK, FALSE);
      l_ichimoku_100 = iIchimoku(NULL, 0, 2, 5, 8, MODE_SENKOUSPANA, CandleToUse);
      l_ichimoku_108 = iIchimoku(NULL, 0, 2, 5, 8, MODE_SENKOUSPANB, CandleToUse);
      if (Bid < l_ichimoku_100) g_color_1000 = gi_1012;
      if (Bid > l_ichimoku_108) g_color_1000 = gi_1008;
      if (Bid < l_ichimoku_100 && Bid > l_ichimoku_108) g_color_1000 = Orange;
      ObjectDelete("Cloud_Box");
      ObjectCreate("Cloud_Box", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
      ObjectSetText("Cloud_Box", "0", 36, "Webdings");
      ObjectSet("Cloud_Box", OBJPROP_CORNER, 1);
      ObjectSet("Cloud_Box", OBJPROP_XDISTANCE, g_x_1076 + 35);
      ObjectSet("Cloud_Box", OBJPROP_YDISTANCE, g_y_1080 + 26 + gd_948);
      ObjectSet("Cloud_Box", OBJPROP_COLOR, g_color_1000);
      ObjectSet("Cloud_Box", OBJPROP_BACK, FALSE);
      l_icustom_116 = iCustom(NULL, 0, "THV3 Coral", 0, CandleToUse);
      l_icustom_124 = iCustom(NULL, g_timeframe_1032, "THV3 Coral", 0, CandleToUse);
      if (Coral_next_TF == TRUE) {
         if (Period() == PERIOD_M1) g_timeframe_1032 = 5;
         if (Period() == PERIOD_M5) g_timeframe_1032 = 15;
         if (Period() == PERIOD_M15) g_timeframe_1032 = 30;
         if (Period() == PERIOD_M30) g_timeframe_1032 = 60;
         if (Period() == PERIOD_H1) g_timeframe_1032 = 240;
         if (Period() == PERIOD_H4) g_timeframe_1032 = 1440;
         if (Period() == PERIOD_D1) g_timeframe_1032 = -10080;
         if (Period() == PERIOD_W1) g_timeframe_1032 = 43200;
         if (Period() == PERIOD_MN1) {
            g_timeframe_1032 = 43200;
            ObjectCreate("Coral_Error", OBJ_LABEL, 0, 0, 0);
            ObjectSet("Coral_Error", OBJPROP_CORNER, 0);
            ObjectSet("Coral_Error", OBJPROP_XDISTANCE, 10);
            ObjectSet("Coral_Error", OBJPROP_YDISTANCE, gd_948 + 30.0);
            ObjectSetText("Coral_Error", "Coral Error, no higher period available ==> Monthly applied", 12, "Arial Bold", Red);
         }
      }
      if (Bid >= l_icustom_124) g_color_992 = gi_1008;
      if (Bid <= l_icustom_124) g_color_992 = gi_1012;
      ObjectDelete("Coral5_Box");
      ObjectCreate("Coral5_Box", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
      ObjectSetText("Coral5_Box", "0", 36, "Webdings");
      ObjectSet("Coral5_Box", OBJPROP_CORNER, 1);
      ObjectSet("Coral5_Box", OBJPROP_XDISTANCE, g_x_1076 + 95);
      ObjectSet("Coral5_Box", OBJPROP_YDISTANCE, g_y_1080 + 26 + gd_948);
      ObjectSet("Coral5_Box", OBJPROP_COLOR, g_color_992);
      ObjectSet("Coral5_Box", OBJPROP_BACK, FALSE);
      if (Use_Coral_1M == TRUE) {
         if (Bid > l_icustom_116) g_color_996 = gi_1008;
         if (Bid < l_icustom_116) g_color_996 = gi_1012;
         ObjectDelete("Coral_Box");
         ObjectCreate("Coral_Box", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
         ObjectSetText("Coral_Box", "0", 36, "Webdings");
         ObjectSet("Coral_Box", OBJPROP_CORNER, 1);
         ObjectSet("Coral_Box", OBJPROP_XDISTANCE, g_x_1076 + 65);
         ObjectSet("Coral_Box", OBJPROP_YDISTANCE, g_y_1080 + 26 + gd_948);
         ObjectSet("Coral_Box", OBJPROP_COLOR, g_color_996);
         ObjectSet("Coral_Box", OBJPROP_BACK, FALSE);
      }
      if (ChangeChartColor == TRUE && Use_Coral_1M == TRUE) {
         if (Bid > l_ichimoku_108 && Bid >= l_icustom_124 && Bid >= l_icustom_116 && l_icustom_92 == EMPTY_VALUE && gd_412 < ld_172) {
            g_color_988 = g_color_1016;
            ObjectCreate("aChart_Box", OBJ_LABEL, 0, 0, 0, 0, 0);
            ObjectSetText("aChart_Box", "g", 1500, "Webdings");
            ObjectSet("aChart_Box", OBJPROP_CORNER, 1);
            ObjectSet("aChart_Box", OBJPROP_XDISTANCE, g_x_1076);
            ObjectSet("aChart_Box", OBJPROP_YDISTANCE, g_y_1080);
            ObjectSet("aChart_Box", OBJPROP_COLOR, g_color_1016);
            ObjectSet("aChart_Box", OBJPROP_BACK, TRUE);
         } else ObjectDelete("aChart_Box");
         if (Bid < l_ichimoku_108 && Bid <= l_icustom_124 && Bid <= l_icustom_116 && l_icustom_84 == EMPTY_VALUE && gd_412 > ld_180) {
            g_color_988 = g_color_1020;
            ObjectCreate("aChart_Boxd", OBJ_LABEL, 0, 0, 0, 0, 0);
            ObjectSetText("aChart_Boxd", "g", 1500, "Webdings");
            ObjectSet("aChart_Boxd", OBJPROP_CORNER, 1);
            ObjectSet("aChart_Boxd", OBJPROP_XDISTANCE, g_x_1076);
            ObjectSet("aChart_Boxd", OBJPROP_YDISTANCE, g_y_1080);
            ObjectSet("aChart_Boxd", OBJPROP_COLOR, g_color_1020);
            ObjectSet("aChart_Boxd", OBJPROP_BACK, TRUE);
         } else ObjectDelete("aChart_Boxd");
      }
   }
   if (Signal_Sound == TRUE) {
      if (g_color_988 == g_color_1020 && gi_1024 != -1) {
         gi_1024 = -1;
         PlaySound("wait.wav");
      }
      if (g_color_988 == g_color_1016 && gi_1024 != -1) {
         gi_1024 = -1;
         PlaySound("wait.wav");
      }
      if (ChangeChartColor == TRUE && Use_Coral_1M == FALSE) {
         ObjectDelete("Coral_Box");
         ObjectCreate("Coral_Box", OBJ_LABEL, AnalyzeBoxWindow, 0, 0, 0, 0);
         ObjectSetText("Coral_Box", "r", 12, "Webdings");
         ObjectSet("Coral_Box", OBJPROP_CORNER, 1);
         ObjectSet("Coral_Box", OBJPROP_XDISTANCE, g_x_1076 + 80);
         ObjectSet("Coral_Box", OBJPROP_YDISTANCE, g_y_1080 + 56 + gd_948);
         ObjectSet("Coral_Box", OBJPROP_COLOR, FireBrick);
         ObjectSet("Coral_Box", OBJPROP_BACK, FALSE);
         if (Bid > l_ichimoku_108 && Bid >= l_icustom_124 && l_icustom_92 == EMPTY_VALUE && gd_412 < ld_172) {
            g_color_988 = g_color_1016;
            ObjectCreate("aChart_Box", OBJ_LABEL, 0, 0, 0, 0, 0);
            ObjectSetText("aChart_Box", "g", 1500, "Webdings");
            ObjectSet("aChart_Box", OBJPROP_CORNER, 1);
            ObjectSet("aChart_Box", OBJPROP_XDISTANCE, g_x_1076);
            ObjectSet("aChart_Box", OBJPROP_YDISTANCE, g_y_1080);
            ObjectSet("aChart_Box", OBJPROP_COLOR, g_color_1016);
            ObjectSet("aChart_Box", OBJPROP_BACK, TRUE);
         } else ObjectDelete("aChart_Box");
         if (Bid < l_ichimoku_108 && Bid <= l_icustom_124 && l_icustom_84 == EMPTY_VALUE && gd_412 > ld_180) {
            g_color_988 = g_color_1020;
            ObjectCreate("aChart_Boxd", OBJ_LABEL, 0, 0, 0, 0, 0);
            ObjectSetText("aChart_Boxd", "g", 1500, "Webdings");
            ObjectSet("aChart_Boxd", OBJPROP_CORNER, 1);
            ObjectSet("aChart_Boxd", OBJPROP_XDISTANCE, g_x_1076);
            ObjectSet("aChart_Boxd", OBJPROP_YDISTANCE, g_y_1080);
            ObjectSet("aChart_Boxd", OBJPROP_COLOR, g_color_1020);
            ObjectSet("aChart_Boxd", OBJPROP_BACK, TRUE);
         } else ObjectDelete("aChart_Boxd");
      }
   }
   if (gi_984) {
      ObjectDelete("Trix_candle");
      ObjectCreate("Trix_candle", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_candle", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_candle", OBJPROP_XDISTANCE, 70);
      ObjectSet("Trix_candle", OBJPROP_YDISTANCE, gd_948 + 142.0);
      ObjectSet("Trix_candle", OBJPROP_COLOR, Gold);
      ObjectSet("Trix_candle", OBJPROP_BACK, FALSE);
      ObjectSetText("Trix_candle", "Candle       :", 9, "Arial Bold", Orange);
      ObjectDelete("Trix_candle1");
      ObjectCreate("Trix_candle1", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
      ObjectSet("Trix_candle1", OBJPROP_CORNER, AnalyzeBoxCorner);
      ObjectSet("Trix_candle1", OBJPROP_XDISTANCE, 12);
      ObjectSet("Trix_candle1", OBJPROP_YDISTANCE, gd_948 + 142.0);
      ObjectSet("Trix_candle1", OBJPROP_COLOR, Gold);
      ObjectSet("Trix_candle1", OBJPROP_BACK, FALSE);
      ObjectSetText("Trix_candle1", l_text_656, 9, "Arial Bold", Orange);
   }
   if (Alert_On_Fast_Slow_Trix_Cross) {
      if (g_ibuf_392[2] < g_ibuf_380[2] && g_ibuf_392[1] > g_ibuf_380[1] && g_bars_420 < Bars) {
         if (gi_984) l_text_56 = "Buy";
         ObjectDelete("Order_Crossing_Label");
         ObjectCreate("Order_Crossing_Label", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
         ObjectSet("Order_Crossing_Label", OBJPROP_CORNER, AnalyzeBoxCorner);
         ObjectSet("Order_Crossing_Label", OBJPROP_XDISTANCE, 12);
         ObjectSet("Order_Crossing_Label", OBJPROP_YDISTANCE, gd_948 + 110.0);
         ObjectSet("Order_Crossing_Label", OBJPROP_COLOR, Red);
         ObjectSetText("Order_Crossing_Label", l_text_56, 9, "Arial Bold", Lime);
         ls_32 = gs_424 + " " + Symbol() + " " + TF2Str(Period()) + " BUY ALARM @ " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES);
         DoAlerts(ls_32, ls_32);
         g_bars_420 = Bars;
         if (SoundAlerts) PlaySound(AnalyseBuySound);
      } else {
         if (g_ibuf_392[2] > g_ibuf_380[2] && g_ibuf_392[1] < g_ibuf_380[1] && g_bars_420 < Bars) {
            if (gi_984) l_text_56 = "Sell";
            ObjectDelete("Order_Crossing_Label");
            ObjectCreate("Order_Crossing_Label", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
            ObjectSet("Order_Crossing_Label", OBJPROP_CORNER, AnalyzeBoxCorner);
            ObjectSet("Order_Crossing_Label", OBJPROP_XDISTANCE, 12);
            ObjectSet("Order_Crossing_Label", OBJPROP_YDISTANCE, gd_948 + 110.0);
            ObjectSet("Order_Crossing_Label", OBJPROP_COLOR, Red);
            ObjectSetText("Order_Crossing_Label", l_text_56, 9, "Arial Bold", Red);
            ls_32 = gs_424 + " " + Symbol() + " " + TF2Str(Period()) + " SELL ALARM @ " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES);
            DoAlerts(ls_32, ls_32);
            g_bars_420 = Bars;
            if (SoundAlerts) PlaySound(AnalyseSellSound);
         }
      }
   }
   if (gi_984)
      if (gd_412 > ld_172) l_text_64 = "Sell OB";
   ObjectDelete("Order_Crossing_Label_OB");
   ObjectCreate("Order_Crossing_Label_OB", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_CORNER, AnalyzeBoxCorner);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_XDISTANCE, 12);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_YDISTANCE, gd_948 + 110.0);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_COLOR, Red);
   ObjectSetText("Order_Crossing_Label_OB", l_text_64, 9, "Arial Bold", Red);
   if (gd_412 > ld_172) ObjectDelete("Order_Crossing_Label");
   if (gi_984)
      if (gd_412 < ld_180) l_text_64 = "Buy OS";
   ObjectDelete("Order_Crossing_Label_OB");
   ObjectCreate("Order_Crossing_Label_OB", OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_CORNER, AnalyzeBoxCorner);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_XDISTANCE, 12);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_YDISTANCE, gd_948 + 110.0);
   ObjectSet("Order_Crossing_Label_OB", OBJPROP_COLOR, Red);
   ObjectSetText("Order_Crossing_Label_OB", l_text_64, 9, "Arial Bold", Red);
   if (gd_412 < ld_180) ObjectDelete("Order_Crossing_Label");
   if (Alert_On_Fast_Trix_Color_Change) {
      if (g_ibuf_392[1] > g_ibuf_380[1] && g_ibuf_396[2] != EMPTY_VALUE && g_ibuf_396[1] == EMPTY_VALUE && g_bars_420 < Bars) {
         if (gi_984) l_text_40 = "Exit Long";
         if (ObjectFind("Exit_Label" + Time[0]) == -1) {
            ObjectDelete("Exit_Label" + Time[0]);
            ObjectCreate("Exit_Label" + Time[0], OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
            ObjectSet("Exit_Label" + Time[0], OBJPROP_CORNER, AnalyzeBoxCorner);
            ObjectSet("Exit_Label" + Time[0], OBJPROP_XDISTANCE, 12);
            ObjectSet("Exit_Label" + Time[0], OBJPROP_YDISTANCE, gd_948 + 125.0);
            ObjectSet("Exit_Label" + Time[0], OBJPROP_COLOR, Orange);
            ObjectSet("Exit_Label", OBJPROP_BACK, FALSE);
            ObjectSetText("Exit_Label" + Time[0], l_text_40, 9, "Arial Bold", Gold);
         }
         ls_32 = gs_424 + " " + Symbol() + " " + TF2Str(Period()) + " TRIX EXIT ALARM @ " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES);
         DoAlerts(ls_32, ls_32);
         g_bars_420 = Bars;
         if (SoundAlerts) PlaySound(Sound_On_Fast_Trix_Color_Change);
      } else {
         if (g_ibuf_392[1] < g_ibuf_380[1] && g_ibuf_400[2] != EMPTY_VALUE && g_ibuf_400[1] == EMPTY_VALUE && g_bars_420 < Bars) {
            if (gi_984) l_text_40 = "Exit Short";
            if (ObjectFind("Exit_Label" + Time[0]) == -1) {
               if (gi_984) {
                  ObjectDelete("Exit_Label");
                  ObjectCreate("Exit_Label" + Time[0], OBJ_LABEL, AnalyzeBoxWindow, 0, 0);
                  ObjectSet("Exit_Label" + Time[0], OBJPROP_CORNER, AnalyzeBoxCorner);
                  ObjectSet("Exit_Label" + Time[0], OBJPROP_XDISTANCE, 12);
                  ObjectSet("Exit_Label" + Time[0], OBJPROP_YDISTANCE, gd_948 + 125.0);
                  ObjectSet("Exit_Label" + Time[0], OBJPROP_COLOR, Gold);
                  ObjectSet("Exit_Label", OBJPROP_BACK, FALSE);
                  ObjectSetText("Exit_Label" + Time[0], l_text_40, 9, "Arial Bold", Orange);
               }
            }
            ls_32 = gs_424 + " " + Symbol() + " " + TF2Str(Period()) + " TRIX EXIT ALARM @ " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES);
            DoAlerts(ls_32, ls_32);
            g_bars_420 = Bars;
            if (SoundAlerts) PlaySound(Sound_On_Fast_Trix_Color_Change);
         }
      }
      if (ObjectFind("Exit_Label" + Time[1]) != -1) ObjectDelete("Exit_Label" + Time[1]);
   }
   return (FALSE);
}

void DoAlerts(string as_0, string as_8) {
   if (MsgAlerts) Alert(as_8);
   if (eMailAlerts) SendMail(as_0, as_8);
}

string TF2Str(int ai_0) {
   switch (ai_0) {
   case 1:
      return ("M1");
   case 5:
      return ("M5");
   case 15:
      return ("M15");
   case 30:
      return ("M30");
   case 60:
      return ("H1");
   case 240:
      return ("H4");
   case 1440:
      return ("D1");
   case 10080:
      return ("W1");
   case 43200:
      return ("MN");
   }
   return (Period());
}

void CatchBullishDivergence(int ai_0) {
   int li_4;
   int li_8;
   if (IsIndicatorTrough(ai_0) != 0) {
      li_4 = ai_0;
      li_8 = GetIndicatorLastTrough(ai_0);
      if (g_ibuf_392[li_4] > g_ibuf_392[li_8] && Low[li_4] < Low[li_8]) {
         g_ibuf_636[li_4] = g_ibuf_392[li_4] - 0.0001;
         if (drawPriceTrendLines == TRUE) DrawPriceTrendLine(Time[li_4], Time[li_8], Low[li_4], Low[li_8], BullishDivergenceColor, STYLE_SOLID);
         if (drawIndicatorTrendLines == TRUE) DrawIndicatorTrendLine(Time[li_4], Time[li_8], g_ibuf_392[li_4], g_ibuf_392[li_8], BullishDivergenceColor, STYLE_SOLID);
         if (EnableAlerts == TRUE) {
            if (SoundAlertOnDivergence == TRUE) SoundAlert(ClassicBullDivSound, li_4);
            else DisplayAlert("Classical bullish divergence on: ", li_4);
         }
      }
      if (g_ibuf_392[li_4] < g_ibuf_392[li_8] && Low[li_4] > Low[li_8]) {
         g_ibuf_636[li_4] = g_ibuf_392[li_4] - 0.0001;
         if (drawPriceTrendLines == TRUE) DrawPriceTrendLine(Time[li_4], Time[li_8], Low[li_4], Low[li_8], BullishDivergenceColor, STYLE_DOT);
         if (drawIndicatorTrendLines == TRUE) DrawIndicatorTrendLine(Time[li_4], Time[li_8], g_ibuf_392[li_4], g_ibuf_392[li_8], BullishDivergenceColor, STYLE_DOT);
         if (EnableAlerts == TRUE) {
            if (SoundAlertOnDivergence == TRUE) {
               SoundAlert(ReverseBullDivSound, li_4);
               return;
            }
            DisplayAlert("Reverse bullish divergence on: ", li_4);
         }
      }
   }
}

void CatchBearishDivergence(int ai_0) {
   int li_4;
   int li_8;
   if (IsIndicatorPeak(ai_0) != 0) {
      li_4 = ai_0;
      li_8 = GetIndicatorLastPeak(ai_0);
      if (g_ibuf_392[li_4] < g_ibuf_392[li_8] && High[li_4] > High[li_8]) {
         g_ibuf_640[li_4] = g_ibuf_392[li_4] + 0.0001;
         if (drawPriceTrendLines == TRUE) DrawPriceTrendLine(Time[li_4], Time[li_8], High[li_4], High[li_8], BearishDivergenceColor, STYLE_SOLID);
         if (drawIndicatorTrendLines == TRUE) DrawIndicatorTrendLine(Time[li_4], Time[li_8], g_ibuf_392[li_4], g_ibuf_392[li_8], BearishDivergenceColor, STYLE_SOLID);
         if (EnableAlerts == TRUE) {
            if (SoundAlertOnDivergence == TRUE) SoundAlert(ClassicBearDivSound, li_4);
            else DisplayAlert("Classical bearish divergence on: ", li_4);
         }
      }
      if (g_ibuf_392[li_4] > g_ibuf_392[li_8] && High[li_4] < High[li_8]) {
         g_ibuf_640[li_4] = g_ibuf_392[li_4] + 0.0001;
         if (drawPriceTrendLines == TRUE) DrawPriceTrendLine(Time[li_4], Time[li_8], High[li_4], High[li_8], BearishDivergenceColor, STYLE_DOT);
         if (drawIndicatorTrendLines == TRUE) DrawIndicatorTrendLine(Time[li_4], Time[li_8], g_ibuf_392[li_4], g_ibuf_392[li_8], BearishDivergenceColor, STYLE_DOT);
         if (EnableAlerts == TRUE) {
            if (SoundAlertOnDivergence == TRUE) {
               SoundAlert(ReverseBearDivSound, li_4);
               return;
            }
            DisplayAlert("Reverse bearish divergence on: ", li_4);
         }
      }
   }
}

int IsIndicatorTrough(int ai_0) {
   if (g_ibuf_392[ai_0] <= g_ibuf_392[ai_0 + 1] && g_ibuf_392[ai_0] < g_ibuf_392[ai_0 + 2] && g_ibuf_392[ai_0] < g_ibuf_392[ai_0 - 1]) return (1);
   return (0);
}

int GetIndicatorLastTrough(int ai_0) {
   for (int li_4 = ai_0 + 5; li_4 < Bars; li_4++) {
      if (g_ibuf_380[li_4] <= g_ibuf_380[li_4 + 1] && g_ibuf_380[li_4] <= g_ibuf_380[li_4 + 2] && g_ibuf_380[li_4] <= g_ibuf_380[li_4 - 1] && g_ibuf_380[li_4] <= g_ibuf_380[li_4 - 2]) {
         for (int li_ret_8 = li_4; li_ret_8 < Bars; li_ret_8++)
            if (g_ibuf_392[li_ret_8] <= g_ibuf_392[li_ret_8 + 1] && g_ibuf_392[li_ret_8] < g_ibuf_392[li_ret_8 + 2] && g_ibuf_392[li_ret_8] <= g_ibuf_392[li_ret_8 - 1] && g_ibuf_392[li_ret_8] < g_ibuf_392[li_ret_8 - 2]) return (li_ret_8);
      }
   }
   return (-1);
}

void DrawPriceTrendLine(int a_datetime_0, int a_datetime_4, double a_price_8, double a_price_16, color a_color_24, double a_style_28) {
   string l_name_36 = "THV4 Trix V" + "1" + "_Trix_DivergenceLine_# " + DoubleToStr(a_datetime_0, 0);
   ObjectDelete(l_name_36);
   ObjectCreate(l_name_36, OBJ_TREND, 0, a_datetime_0, a_price_8, a_datetime_4, a_price_16, 0, 0);
   ObjectSet(l_name_36, OBJPROP_RAY, FALSE);
   ObjectSet(l_name_36, OBJPROP_COLOR, a_color_24);
   ObjectSet(l_name_36, OBJPROP_STYLE, a_style_28);
   ObjectSet(l_name_36, OBJPROP_BACK, TRUE);
}

void DrawIndicatorTrendLine(int a_datetime_0, int a_datetime_4, double a_price_8, double a_price_16, color a_color_24, double a_style_28) {
   string l_name_36;
   int l_window_44 = WindowFind(gs_432);
   if (l_window_44 >= 0) {
      l_name_36 = "THV4 Trix V" + "1" + "_Trix_DivergenceLine_$# " + DoubleToStr(a_datetime_0, 0);
      ObjectDelete(l_name_36);
      ObjectCreate(l_name_36, OBJ_TREND, l_window_44, a_datetime_0, a_price_8, a_datetime_4, a_price_16, 0, 0);
      ObjectSet(l_name_36, OBJPROP_RAY, FALSE);
      ObjectSet(l_name_36, OBJPROP_COLOR, a_color_24);
      ObjectSet(l_name_36, OBJPROP_STYLE, a_style_28);
      ObjectSet(l_name_36, OBJPROP_BACK, TRUE);
   }
}

void DisplayAlert(string as_0, int ai_8) {
   string ls_unused_12;
   string ls_20;
   if (ai_8 <= 2 && Time[ai_8] != g_time_440) {
      g_time_440 = Time[ai_8];
      Alert(as_0, Symbol(), " , ", TF2Str(Period()), " minutes chart");
      ls_20 = "Divergence on " + TF2Str(Period());
      if (EmailDivergenceAlerts) SendMail(ls_20, as_0);
   }
}

void SoundAlert(string as_0, int ai_8) {
   if (ai_8 <= 2 && Time[ai_8] != g_time_444) {
      g_time_444 = Time[ai_8];
      PlaySound(as_0);
   }
}

int IsIndicatorPeak(int ai_0) {
   if (g_ibuf_392[ai_0] >= g_ibuf_392[ai_0 + 1] && g_ibuf_392[ai_0] > g_ibuf_392[ai_0 + 2] && g_ibuf_392[ai_0] > g_ibuf_392[ai_0 - 1]) return (1);
   return (0);
}

int GetIndicatorLastPeak(int ai_0) {
   for (int li_4 = ai_0 + 5; li_4 < Bars; li_4++) {
      if (g_ibuf_380[li_4] >= g_ibuf_380[li_4 + 1] && g_ibuf_380[li_4] >= g_ibuf_380[li_4 + 2] && g_ibuf_380[li_4] >= g_ibuf_380[li_4 - 1] && g_ibuf_380[li_4] >= g_ibuf_380[li_4 - 2]) {
         for (int li_ret_8 = li_4; li_ret_8 < Bars; li_ret_8++)
            if (g_ibuf_392[li_ret_8] >= g_ibuf_392[li_ret_8 + 1] && g_ibuf_392[li_ret_8] > g_ibuf_392[li_ret_8 + 2] && g_ibuf_392[li_ret_8] >= g_ibuf_392[li_ret_8 - 1] && g_ibuf_392[li_ret_8] > g_ibuf_392[li_ret_8 - 2]) return (li_ret_8);
      }
   }
   return (-1);
}