//+------------------------------------------------------------------------------+//
//)   ____  _  _  ____  ____  ____  ____  __  __    __      ___  _____  __  __   (//
//)  ( ___)( \/ )(  _ \(  _ \( ___)( ___)(  \/  )  /__\    / __)(  _  )(  \/  )  (//
//)   )__)  )  (  )(_) ))   / )__)  )__)  )    (  /(__)\  ( (__  )(_)(  )    (   (//
//)  (__)  (_/\_)(____/(_)\_)(____)(____)(_/\/\_)(__)(__)()\___)(_____)(_/\/\_)  (//
//)   http://fxdreema.com                              Copyright 2017, fxDreema  (//
//+------------------------------------------------------------------------------+//
#property copyright ""
#property link      "https://fxdreema.com"
//#property strict

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                       INPUT PARAMETERS, GLOBAL VARIABLES, CONSTANTS, IMPORTS and INCLUDES                        | //
// |                      System and Custom variables and other definitions used in the project                       | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// System constants (project settings) //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//--
#define PROJECT_ID "mt5-8244"
//--
// Point Format Rules
#define POINT_FORMAT_RULES "0.001=0.01,0.00001=0.0001,0.000001=0.0001"
//--
// Events On/Off
#define ENABLE_EVENT_TICK 1 // enable "Tick" event
#define ENABLE_EVENT_TRADE 0 // enable "Trade" event
#define ENABLE_EVENT_TIMER 0 // enable "Timer" event
//--
// Settings for events
#define ON_TIMER_PERIOD 60 // Timer event period (in seconds)

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// System constants (predefined constants) //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//--
#define TLOBJPROP_TIME1 801
#define OBJPROP_TL_PRICE_BY_SHIFT 802
#define OBJPROP_TL_SHIFT_BY_PRICE 803
#define OBJPROP_FIBOVALUE 804
#define OBJPROP_FIBOPRICEVALUE 805
#define OBJPROP_FIRSTLEVEL 806
#define OBJPROP_TIME1 807
#define OBJPROP_TIME2 808
#define OBJPROP_TIME3 809
#define OBJPROP_PRICE1 810
#define OBJPROP_PRICE2 811
#define OBJPROP_PRICE3 812
#define OBJPROP_BARSHIFT1 813
#define OBJPROP_BARSHIFT2 814
#define OBJPROP_BARSHIFT3 815
#define SEL_CURRENT 0
#define SEL_INITIAL 1

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// Imports, Constants, Variables //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//



//--
// Constants (Input Parameters)
input double minHammerBodyPercent = 7;input double maxHammerBodyPercent = 30;input int MagicStart = 8244; // Magic Number, kind of...
class c
{
	public:
	static double minHammerBodyPercent;
	static double maxHammerBodyPercent;
	static int MagicStart;
};
double c::minHammerBodyPercent;
double c::maxHammerBodyPercent;
int c::MagicStart;


//--
// Variables (Global Variables)
class v
{
	public:
	static double Open;
	static double Close;
	static double High;
	static double Low;
	static bool conditionPass;
};
double v::Open;
double v::Close;
double v::High;
double v::Low;
bool v::conditionPass;




//VVVVVVVVVVVVVVVVVVVVVVVVV//
// System global variables //
//^^^^^^^^^^^^^^^^^^^^^^^^^//
//--
int FXD_CURRENT_FUNCTION_ID = 0;
double FXD_MILS_INIT_END    = 0;
int FXD_TICKS_FROM_START    = 0;
int FXD_MORE_SHIFT          = 0;
bool FXD_DRAW_SPREAD_INFO   = false;
bool FXD_FIRST_TICK_PASSED  = false;
bool FXD_BREAK              = false;
bool FXD_CONTINUE           = false;
string FXD_CURRENT_SYMBOL   = "";
int FXD_BLOCKS_COUNT        = 57;
datetime FXD_TICKSKIP_UNTIL = 0;

//- for use in OnChart() event
struct fxd_onchart
{
int id;
long lparam;
double dparam;
string sparam;
};
fxd_onchart FXD_ONCHART;

//VVVVVVVVVVVVVVVVVVV//
// System structures //
//^^^^^^^^^^^^^^^^^^^//
struct position
{
    ulong    position_id;
    long     type,
             magic;
    datetime time;
    double   volume,
             price_open,
             sl,
             tp,
             price_current,
             comission,
             swap,
             profit;
    string   symbol,
             comment;
};
struct order
{
    datetime time_setup,
             time_expiration,
             time_done;
    long     type,
             state,
             type_filling,
             type_time,
             magic,
             position_id;
    ulong    ticket;
    double   volume_initial,
             volume_current,
             price_open,
             sl,
             tp,
             price_current,
             price_stoplimit;
    string   symbol,
             comment;
};

position  EGV_PositionsList[];
position  EGV_PositionsList0[];
order     EGV_OrderList[];
order     EGV_OrderList0[];

//--
// Variables for On/Off
bool disabled[57];

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                                 EVENT FUNCTIONS                                                  | //
// |                           These are the main functions that controls the whole project                           | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed once when the program starts //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
int OnInit()
{


    // Initiate Constants
    	c::minHammerBodyPercent = minHammerBodyPercent;
	c::maxHammerBodyPercent = maxHammerBodyPercent;
	c::MagicStart = MagicStart;




    // do or do not not initilialize on reload
    if (UninitializeReason() != 0)
    {
        if (UninitializeReason() == REASON_CHARTCHANGE)
        {
            // if the symbol is the same, do not reload, otherwise continue below
            if (FXD_CURRENT_SYMBOL == Symbol()) {return INIT_SUCCEEDED;}
        }
        else
        {
            return INIT_SUCCEEDED;
        }
    }
    FXD_CURRENT_SYMBOL = Symbol();

	v::Open = 0;
	v::Close = 0;
	v::High = 0;
	v::Low = 0;
	v::conditionPass = false;




    Comment("");
    for (int i=ObjectsTotal(ChartID()); i>=0; i--)
    {
        string name = ObjectName(ChartID(), i);
        if (StringSubstr(name,0,8) == "fxd_cmnt") {ObjectDelete(ChartID(), name);}
    }
    ChartRedraw();



    // This is needed for OnTrade event
    BuildPositionsList(EGV_PositionsList0);
    BuildOrdersList(EGV_OrderList0);

    //-- set initial local and server time
    TimeAtStart("set");

    //-- set initial balance
    AccountBalanceAtStart();

    //-- draw the initial spread info meter
    FXD_DRAW_SPREAD_INFO = !(MQLInfoInteger(MQL_TESTER) && !MQLInfoInteger(MQL_VISUAL_MODE));
    if (FXD_DRAW_SPREAD_INFO) DrawSpreadInfo();

    //-- draw initial status
    DrawStatus("waiting for tick...");

    if (ENABLE_EVENT_TIMER) {
        OnTimerSet(ON_TIMER_PERIOD);
    }



    FXD_MILS_INIT_END     = (double)GetTickCount();
    FXD_FIRST_TICK_PASSED = false; // reset is needed when changing inputs

    return(INIT_SUCCEEDED);
}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed on every incoming tick //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnTick()
{
    FXD_TICKS_FROM_START++;

    if (FXD_TICKS_FROM_START == 1) DrawStatus("working");

    //-- special system actions
    if (FXD_DRAW_SPREAD_INFO) DrawSpreadInfo();
    TicksData(""); // Collect ticks (if needed)
    TicksPerSecond(false, true); // Collect ticks per second
    OCODriver(); // Check and close OCO orders

    // skip ticks
    if (TimeLocal() < FXD_TICKSKIP_UNTIL) {return;}

	block5(0);
	block11(0);
	block12(0);
	block22(0);
	block29(0);
	block32(0);
	block35(0);
	block39(0);


    return;
}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed on trade events - open, close, modify //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnTrade()
{
    OnTradeQueue(1);


    OnTradeQueue(-1);
}


//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed on a period basis //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnTimer()
{

}


//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed when chart event happens //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnChartEvent(
    const int id,         // Event ID
    const long& lparam,   // Parameter of type long event
    const double& dparam, // Parameter of type double event
    const string& sparam  // Parameter of type string events
)
{
    //-- write parameter to the system global variables
    FXD_ONCHART.id     = id;
    FXD_ONCHART.lparam = lparam;
    FXD_ONCHART.dparam = dparam;
    FXD_ONCHART.sparam = sparam;


    return;
}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed once when the program ends //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnDeinit(const int reason)
{
    int reson = UninitializeReason();
    if (reson == REASON_CHARTCHANGE || reson == REASON_PARAMETERS || reason == REASON_TEMPLATE) {return;}

    //-- if Timer was set, kill it here
    EventKillTimer();

    DrawStatus("stopped");
    DrawSpreadInfo();



    if (MQLInfoInteger(MQL_TESTER)) {
        Print("Backtested in "+DoubleToString((GetTickCount()-FXD_MILS_INIT_END)/1000, 2)+" seconds");
        double tc = GetTickCount()-FXD_MILS_INIT_END;
        if (tc > 0)
        {
            Print("Average ticks per second: "+DoubleToString(FXD_TICKS_FROM_START/tc, 0));
        }
    }

    if (MQLInfoInteger(MQL_PROGRAM_TYPE) == PROGRAM_EXPERT)
    {
        switch(UninitializeReason())
        {
            case REASON_PROGRAM		: Print("Expert Advisor self terminated"); break;
            case REASON_REMOVE		: Print("Expert Advisor removed from the chart"); break;
            case REASON_RECOMPILE	: Print("Expert Advisorhas been recompiled"); break;
            case REASON_CHARTCHANGE	: Print("Symbol or chart period has been changed"); break;
            case REASON_CHARTCLOSE	: Print("Chart has been closed"); break;
            case REASON_PARAMETERS	: Print("Input parameters have been changed by a user"); break;
            case REASON_ACCOUNT		: Print("Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings"); break;
            case REASON_TEMPLATE		: Print("A new template has been applied"); break;
            case REASON_INITFAILED	: Print("OnInit() handler has returned a nonzero value"); break;
            case REASON_CLOSE			: Print("Terminal has been closed"); break;
        }
    }

    return;
}

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                             Functions of blocks                                                  | //
// |              Functions that contain the actual code of the blocks and their input parameters as well             | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/


// Block 1
void block0(int _parent_=0)
{
if (disabled[0] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=0;
	
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int PassMaxTimes = 1;
	
	
	static int times = 0;
	datetime Time[];
	static datetime time0;
	ArraySetAsSeries(Time,true);
	CopyTime(SYMBOL,TIMEFRAME,0,1,Time);
	datetime time=Time[0];
	if (time0<time) {
		times++;
		if (times >= PassMaxTimes)
		{
			time0=time;
			times=0;
		}
			block1(0);
	
	}
	else {/* Yellow Output */}
}



// Block 2
void block1(int _parent_=0)
{
if (disabled[1] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=1;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block2(1);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 3
void block2(int _parent_=0)
{
if (disabled[2] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=2;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iHigh", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block3(2);
	 	block4(2);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 4
void block3(int _parent_=0)
{
if (disabled[3] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=3;
	
	static string AlertTitle = "Bull Engulfing";
	static string AlertLabel1 = "BuE";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 5
void block4(int _parent_=0)
{
if (disabled[4] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=4;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "BuE_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_TOP;
	color ObjColor = clrDeepSkyBlue;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","5","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 6
void block5(int _parent_=0)
{
if (disabled[5] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=5;
	
	
		block0(5);
	
}



// Block 7
void block6(int _parent_=0)
{
if (disabled[6] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=6;
	
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int PassMaxTimes = 1;
	
	
	static int times = 0;
	datetime Time[];
	static datetime time0;
	ArraySetAsSeries(Time,true);
	CopyTime(SYMBOL,TIMEFRAME,0,1,Time);
	datetime time=Time[0];
	if (time0<time) {
		times++;
		if (times >= PassMaxTimes)
		{
			time0=time;
			times=0;
		}
			block7(6);
	
	}
	else {/* Yellow Output */}
}



// Block 8
void block7(int _parent_=0)
{
if (disabled[7] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=7;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block8(7);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 9
void block8(int _parent_=0)
{
if (disabled[8] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=8;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iLow", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block9(8);
	 	block10(8);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 10
void block9(int _parent_=0)
{
if (disabled[9] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=9;
	
	static string AlertTitle = "Bear Engulfing";
	static string AlertLabel1 = "BeE";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 11
void block10(int _parent_=0)
{
if (disabled[10] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=10;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "BeE_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_BOTTOM;
	color ObjColor = clrDeepPink;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","11","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 12
void block11(int _parent_=0)
{
if (disabled[11] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=11;
	
	
		block6(11);
	
}



// Block 13
void block12(int _parent_=0)
{
if (disabled[12] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=12;
	
	
		block13(12);
	
}



// Block 14
void block13(int _parent_=0)
{
if (disabled[13] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=13;
	
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int PassMaxTimes = 1;
	
	
	static int times = 0;
	datetime Time[];
	static datetime time0;
	ArraySetAsSeries(Time,true);
	CopyTime(SYMBOL,TIMEFRAME,0,1,Time);
	datetime time=Time[0];
	if (time0<time) {
		times++;
		if (times >= PassMaxTimes)
		{
			time0=time;
			times=0;
		}
			block14(13);
	
	}
	else {/* Yellow Output */}
}



// Block 15
void block14(int _parent_=0)
{
if (disabled[14] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=14;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iBody", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_value_value((double)1.5);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block15(14);
	 	block16(14);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 16
void block15(int _parent_=0)
{
if (disabled[15] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=15;
	
	static string AlertTitle = "Doji";
	static string AlertLabel1 = "Doji";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 17
void block16(int _parent_=0)
{
if (disabled[16] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=16;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "Doji_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 118;
	int ObjAnchor = ANCHOR_BOTTOM;
	color ObjColor = clrOrange;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 2;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","17","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4)+toDigits(3,CurrentSymbol()));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 18
void block17(int _parent_=0)
{
if (disabled[17] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=17;
	
	static string SignalType = "once";
	int RowSize = 2;
	double MinBodySize = 50;
	static string RowMode = "normal";
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int SHIFT = 1;
	
	
	bool success=true;
	double cSizePrev=0;
	static datetime bartime=0;
	bool pass=false;
	if (SignalType=="continuous" || bartime<iTime(SYMBOL,TIMEFRAME,0)) {
	   for (int id=SHIFT+RowSize-1; id>=SHIFT; id--) {
	      double cSize=iClose(SYMBOL,TIMEFRAME,id)-iOpen(SYMBOL,TIMEFRAME,id);
	      if (cSize<toDigs(MinBodySize)) {success=false; break;}
	      if (RowMode=="bigger" && cSizePrev>0 && cSize<=cSizePrev) {success=false; break;}
	      if (RowMode=="smaller" && cSizePrev>0 && cSize>=cSizePrev) {success=false; break;}
	      cSizePrev=cSize;
	   }
	   if (success==true) {
	      if (SignalType!="continuous") {bartime=(int)iTime(SYMBOL,TIMEFRAME,0);}
	      pass=true;
	   }
	}
	if (pass==true) {	block33(17);
	 	block34(17);
	} else {/* Yellow Output */}
}



// Block 22
void block18(int _parent_=0)
{
if (disabled[18] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=18;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block19(18);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 23
void block19(int _parent_=0)
{
if (disabled[19] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=19;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iOpen", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block20(19);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 24
void block20(int _parent_=0)
{
if (disabled[20] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=20;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iClose", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block21(20);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 25
void block21(int _parent_=0)
{
if (disabled[21] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=21;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block23(21);
	 	block24(21);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 26
void block22(int _parent_=0)
{
if (disabled[22] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=22;
	
	
		block55(22);
	
}



// Block 27
void block23(int _parent_=0)
{
if (disabled[23] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=23;
	
	static string AlertTitle = "Three White Soldiers";
	static string AlertLabel1 = "TWS";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 28
void block24(int _parent_=0)
{
if (disabled[24] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=24;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "TWS_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_BOTTOM;
	color ObjColor = clrLime;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","28","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 32
void block25(int _parent_=0)
{
if (disabled[25] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=25;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block26(25);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 33
void block26(int _parent_=0)
{
if (disabled[26] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=26;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iOpen", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iOpen", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block27(26);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 34
void block27(int _parent_=0)
{
if (disabled[27] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=27;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iClose", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block28(27);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 35
void block28(int _parent_=0)
{
if (disabled[28] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=28;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iClose", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iClose", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block30(28);
	 	block31(28);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 36
void block29(int _parent_=0)
{
if (disabled[29] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=29;
	
	
		block56(29);
	
}



// Block 37
void block30(int _parent_=0)
{
if (disabled[30] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=30;
	
	static string AlertTitle = "Three Black Crows";
	static string AlertLabel1 = "TBC";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 38
void block31(int _parent_=0)
{
if (disabled[31] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=31;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "TBC_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_TOP;
	color ObjColor = clrOrangeRed;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","38","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 39
void block32(int _parent_=0)
{
if (disabled[32] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=32;
	
	
		block17(32);
	
}



// Block 40
void block33(int _parent_=0)
{
if (disabled[33] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=33;
	
	static string AlertTitle = "2 Bulls in Row";
	static string AlertLabel1 = "twoBulls";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 41
void block34(int _parent_=0)
{
if (disabled[34] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=34;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "twoBulls_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_BOTTOM;
	color ObjColor = clrRed;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","41","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 63
void block35(int _parent_=0)
{
if (disabled[35] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=35;
	
	
		block38(35);
	
}



// Block 64
void block36(int _parent_=0)
{
if (disabled[36] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=36;
	
	static string AlertTitle = "2 Bears in Row";
	static string AlertLabel1 = "twoBears";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 65
void block37(int _parent_=0)
{
if (disabled[37] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=37;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "twoBears";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 115;
	int ObjAnchor = ANCHOR_TOP;
	color ObjColor = clrBlue;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","65","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 66
void block38(int _parent_=0)
{
if (disabled[38] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=38;
	
	static string SignalType = "once";
	int RowSize = 2;
	double MinBodySize = 50;
	static string RowMode = "normal";
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int SHIFT = 1;
	
	
	bool success=true;
	double cSizePrev=0;
	static datetime bartime=0;
	bool pass=false;
	if (SignalType=="continuous" || bartime<iTime(SYMBOL,TIMEFRAME,0)) {
	   for (int id=SHIFT+RowSize-1; id>=SHIFT; id--) {
	      double cSize=iOpen(SYMBOL,TIMEFRAME,id)-iClose(SYMBOL,TIMEFRAME,id);
	      if (cSize<toDigs(MinBodySize)) {success=false; break;}
	      if (RowMode=="bigger" && cSizePrev>0 && cSize<=cSizePrev) {success=false; break;}
	      if (RowMode=="smaller" && cSizePrev>0 && cSize>=cSizePrev) {success=false; break;}
	      cSizePrev=cSize;
	   }
	   if (success==true) {
	      if (SignalType!="continuous") {bartime=(int)iTime(SYMBOL,TIMEFRAME,0);}
	      pass=true;
	   }
	}
	if (pass==true) {	block36(38);
	 	block37(38);
	} else {/* Yellow Output */}
}



// Block 67
void block39(int _parent_=0)
{
if (disabled[39] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=39;
	
	
		block40(39);
	
}



// Block 68
void block40(int _parent_=0)
{
if (disabled[40] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=40;
	
	int Variable1 = v::Open;
	int Variable2 = v::Close;
	int Variable3 = v::High;
	int Variable4 = v::Low;
	int Variable5 = 0;
	
	
	v::Open=ic_candles_candles((string)"iOpen", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	v::Close=ic_candles_candles((string)"iClose", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	v::High=ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	v::Low=ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	//=ic_value_value((double)1);
	
		block41(40);
	
}



// Block 69
void block41(int _parent_=0)
{
if (disabled[41] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=41;
	
	
	v::conditionPass=false;
	
	double candleSize;
	double bodySize;
	double percentBodySize;
	double midCandle=(v::High+v::Low)/2;
	int candleType=0; //bull is 1, bear-1
	
	candleSize=v::High-v::Low;
	if(v::Open<v::Close) { bodySize=v::Close-v::Open; candleType=1; }
	else if(v::Open>v::Close) { bodySize=v::Open-v::Close; candleType=-1; }
	else{ bodySize=0; candleType=0; }
	
	//prevent from null dividing
	if(candleSize==0) { candleSize=0.00001; }
	
	//how much% is bodySize from candleSize
	percentBodySize=(bodySize/candleSize)*100;
	
	//bull open is above candle mid, or bear open is below, and body size is less than maxHammerBodyPercent and more than minHammerBodyPercent 
	if( (((candleType>0)&&(v::Open>midCandle))||((candleType<0)&&(v::Open<midCandle))) && (percentBodySize<c::maxHammerBodyPercent) && (percentBodySize>c::minHammerBodyPercent)) {v::conditionPass=true;}
	else{ v::conditionPass=false; }
		block42(41);
	
}



// Block 70
void block42(int _parent_=0)
{
if (disabled[42] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=42;
	
	
	if ((v::conditionPass==true) + 0) {	block43(42);
	 	block44(42);
	} else {/* Yellow Output */}
}



// Block 71
void block43(int _parent_=0)
{
if (disabled[43] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=43;
	
	static string AlertTitle = "Hammer";
	static string AlertLabel1 = "Hammer";
	static string AlertLabel2 = "";
	static string AlertLabel3 = "";
	static string AlertLabel4 = "";
	static string AlertLabel5 = "";
	static string AlertLabel6 = "";
	static string AlertLabel7 = "";
	static string AlertLabel8 = "";
	static string AlertLabel9 = "";
	static string AlertLabel10 = "";
	bool AlsoSendNotification = false;
	
	
	string AlertDataRows="";
	if (AlertLabel1!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel1,": ",ic_candles_candles((string)"iTime", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4));
	if (AlertLabel2!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel2+": ",ic_value_value((double)0));
	if (AlertLabel3!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel3+": ",ic_value_value((double)0));
	if (AlertLabel4!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel4+": ",ic_value_value((double)0));
	if (AlertLabel5!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel5+": ",ic_value_value((double)0));
	if (AlertLabel6!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel6+": ",ic_value_value((double)0));
	if (AlertLabel7!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel7+": ",ic_value_value((double)0));
	if (AlertLabel8!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel8+": ",ic_value_value((double)0));
	if (AlertLabel9!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel9+": ",ic_value_value((double)0));
	if (AlertLabel10!="") StringConcatenate(AlertDataRows, AlertDataRows,"\n",AlertLabel10+": ",ic_value_value((double)0));
	Alert(AlertTitle+"\n"+AlertDataRows);
	if (AlsoSendNotification==true) {
	   SendNotification(AlertTitle+"\n"+AlertDataRows);  
	}
	/* Orange Output */
}



// Block 72
void block44(int _parent_=0)
{
if (disabled[44] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=44;
	
	bool ObjectPerBar = true;
	bool ObjectUpdate = true;
	static string ObjName = "Hammer_";
	ENUM_OBJECT ObjectType = OBJ_ARROW;
	int ObjArrowCode = 118;
	int ObjAnchor = ANCHOR_TOP;
	color ObjColor = clrMagenta;
	ENUM_LINE_STYLE ObjStyle = STYLE_SOLID;
	int ObjWidth = 3;
	bool ObjBack = false;
	bool ObjSelectable = false;
	bool ObjSelected = false;
	bool ObjHidden = false;
	int ObjZorder = 0;
	static string ObjChartSubWindow = "";
	
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   string name          = "";
	   string name_base     = "";
	   static int count     = 0;
	   static datetime time0= 0;
	   bool get_new_name    = false;
	   bool do_update       = true;
	   
	   if (ObjectPerBar==true) {
	      datetime time=iTime(Symbol(),0,0);
	      if (time0 < time) {
	         time0 = time;
	         get_new_name = true;
	      } else {
	         if (ObjectUpdate==false) {do_update = false;}
	      }
	   }
	   else {
	      if (ObjectUpdate==false) {get_new_name = true;}
	   }
	   
	   if (do_update)
	   {
	      if (ObjName!="") {name_base=ObjName;} else {StringConcatenate(name_base, "fxd_arrow_","72","_");}
	      if (get_new_name == false) {
	         StringConcatenate(name, name_base,count);
	      } else {
	         while(true) {
	            count++;
	            StringConcatenate(name, name_base,count);
	            if (ObjectFind(ObjChartID,name)<0) {break;}
	         }
	      }
	      if (ObjName!="" && count==0) {name = ObjName;}
	      
	      if(ObjectFind(ObjChartID,name)<0 && !ObjectCreate(ObjChartID,name,(ENUM_OBJECT)ObjectType,subwindow_id,0,0))
	      {
	         Print(__FUNCTION__,": failed to create arrow object! Error code = ",GetLastError());
	      }
	   
	      if (ObjectType==OBJ_ARROW) {ObjectSetInteger(ObjChartID,name,OBJPROP_ARROWCODE,ObjArrowCode);}
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,(long)ic_value_time((int)3, (int)0, (string)"00:00", (int)1, (string)"", (ENUM_TIMEFRAMES)PERIOD_H4, (int)0, (int)0, (int)0, (int)12, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (bool)false));
	      ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,(double)ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4)+toDigits(3,CurrentSymbol()));
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	   
	      ObjectSetInteger(ObjChartID,name,OBJPROP_STYLE,ObjStyle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,ObjColor);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,ObjBack);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_WIDTH,ObjWidth);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,ObjSelectable);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,ObjSelected);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,ObjHidden);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_ZORDER,ObjZorder);
	   
	      ChartRedraw();
	   }
	}
	/* Orange Output */
}



// Block 73
void block45(int _parent_=0)
{
if (disabled[45] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=45;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iHigh", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iHigh", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block46(45);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 74
void block46(int _parent_=0)
{
if (disabled[46] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=46;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iHigh", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block47(46);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 75
void block47(int _parent_=0)
{
if (disabled[47] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=47;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iLow", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iLow", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block48(47);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 76
void block48(int _parent_=0)
{
if (disabled[48] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=48;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iLow", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo<Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro<Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block18(48);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 77
void block49(int _parent_=0)
{
if (disabled[49] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=49;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iHigh", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iHigh", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block50(49);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 78
void block50(int _parent_=0)
{
if (disabled[50] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=50;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iHigh", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iHigh", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block51(50);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 79
void block51(int _parent_=0)
{
if (disabled[51] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=51;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iLow", (string)"id", (int)3, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iLow", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block52(51);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 80
void block52(int _parent_=0)
{
if (disabled[52] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=52;
	
	
	int crossover = 0;
	int crosswidth = 1;
	bool o1=false, o2=false;
	
	for (int i=0; i<=crossover; i++)
	{
	   // i=0 - normal pass, i=1 - crossover pass
	
	   // Left operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Lo=ic_candles_candles((string)"iLow", (string)"id", (int)2, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=ic_candles_candles((string)"iLow", (string)"id", (int)1, (string)"00:00", (string)CurrentSymbol(), (ENUM_TIMEFRAMES)PERIOD_H4);
	   if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	   
	   // Conditions
	   if (Lo>Ro) {if(i==0){o1=true;}}else{if(i==0){o2=true;}else{o2=false;}}
	   if (crossover==1) {if (Ro>Lo) {if(i==0){o2=true;}}else{if(i==1){o1=false;}}}
	}
	IndicatorMoreShift(true,0); // reset
	// Outputs
	if (o1==true) {	block25(52);
	} else if (o2==true) {/* Yellow Output */}
	
}



// Block 82
void block53(int _parent_=0)
{
if (disabled[53] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=53;
	
	static string SignalType = "continuous";
	int RowSize = 3;
	double MinBodySize = 10;
	static string RowMode = "normal";
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int SHIFT = 1;
	
	
	bool success=true;
	double cSizePrev=0;
	static datetime bartime=0;
	bool pass=false;
	if (SignalType=="continuous" || bartime<iTime(SYMBOL,TIMEFRAME,0)) {
	   for (int id=SHIFT+RowSize-1; id>=SHIFT; id--) {
	      double cSize=iClose(SYMBOL,TIMEFRAME,id)-iOpen(SYMBOL,TIMEFRAME,id);
	      if (cSize<toDigs(MinBodySize)) {success=false; break;}
	      if (RowMode=="bigger" && cSizePrev>0 && cSize<=cSizePrev) {success=false; break;}
	      if (RowMode=="smaller" && cSizePrev>0 && cSize>=cSizePrev) {success=false; break;}
	      cSizePrev=cSize;
	   }
	   if (success==true) {
	      if (SignalType!="continuous") {bartime=(int)iTime(SYMBOL,TIMEFRAME,0);}
	      pass=true;
	   }
	}
	if (pass==true) {	block45(53);
	} else {/* Yellow Output */}
}



// Block 83
void block54(int _parent_=0)
{
if (disabled[54] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=54;
	
	static string SignalType = "continuous";
	int RowSize = 3;
	double MinBodySize = 10;
	static string RowMode = "normal";
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int SHIFT = 1;
	
	
	bool success=true;
	double cSizePrev=0;
	static datetime bartime=0;
	bool pass=false;
	if (SignalType=="continuous" || bartime<iTime(SYMBOL,TIMEFRAME,0)) {
	   for (int id=SHIFT+RowSize-1; id>=SHIFT; id--) {
	      double cSize=iOpen(SYMBOL,TIMEFRAME,id)-iClose(SYMBOL,TIMEFRAME,id);
	      if (cSize<toDigs(MinBodySize)) {success=false; break;}
	      if (RowMode=="bigger" && cSizePrev>0 && cSize<=cSizePrev) {success=false; break;}
	      if (RowMode=="smaller" && cSizePrev>0 && cSize>=cSizePrev) {success=false; break;}
	      cSizePrev=cSize;
	   }
	   if (success==true) {
	      if (SignalType!="continuous") {bartime=(int)iTime(SYMBOL,TIMEFRAME,0);}
	      pass=true;
	   }
	}
	if (pass==true) {	block49(54);
	} else {/* Yellow Output */}
}



// Block 84
void block55(int _parent_=0)
{
if (disabled[55] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=55;
	
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int PassMaxTimes = 1;
	
	
	static int times = 0;
	datetime Time[];
	static datetime time0;
	ArraySetAsSeries(Time,true);
	CopyTime(SYMBOL,TIMEFRAME,0,1,Time);
	datetime time=Time[0];
	if (time0<time) {
		times++;
		if (times >= PassMaxTimes)
		{
			time0=time;
			times=0;
		}
			block53(55);
	
	}
	else {/* Yellow Output */}
}



// Block 90
void block56(int _parent_=0)
{
if (disabled[56] || FXD_BREAK) {return;}
	FXD_CURRENT_FUNCTION_ID=56;
	
	static string SYMBOL; SYMBOL = CurrentSymbol();
	ENUM_TIMEFRAMES TIMEFRAME = PERIOD_H4;
	int PassMaxTimes = 1;
	
	
	static int times = 0;
	datetime Time[];
	static datetime time0;
	ArraySetAsSeries(Time,true);
	CopyTime(SYMBOL,TIMEFRAME,0,1,Time);
	datetime time=Time[0];
	if (time0<time) {
		times++;
		if (times >= PassMaxTimes)
		{
			time0=time;
			times=0;
		}
			block54(56);
	
	}
	else {/* Yellow Output */}
}



double ic_candles_candles(string iOHLC, string ModeCandleFindBy, int CandleID, string TimeStamp, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME)
{
double retval=0;
	double cOpen[];
	double cHigh[];
	double cLow[];
	double cClose[]; 
	long cTickVolume[];
	long cRealVolume[];
	datetime cTime[];
	
	if (ModeCandleFindBy == "time")
	{
	   CandleID = iCandleID(SYMBOL, TIMEFRAME, StringToTimeEx(TimeStamp, "server"));
	}
	
	CandleID=CandleID+IndicatorMoreShift();
	
	if (iOHLC=="iOpen") {
	   CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
	   retval=cOpen[0];
	}
	else if (iOHLC=="iHigh") {
	   CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
	   retval=cHigh[0];
	}
	else if (iOHLC=="iLow") {
	   CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
	   retval=cLow[0];
	}
	else if (iOHLC=="iClose") {
	   CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=cClose[0];
	}
	else if (iOHLC=="iTickVolume") {
		CopyTickVolume(SYMBOL,TIMEFRAME,CandleID,1,cTickVolume);
		retval=(double)cTickVolume[0];
		
		return retval;
	}
	else if (iOHLC=="iRealVolume") {
		CopyRealVolume(SYMBOL,TIMEFRAME,CandleID,1,cRealVolume);
		retval=(double)cRealVolume[0];
		
		return retval;
	}
	else if (iOHLC=="iTime") {
		CopyTime(SYMBOL,TIMEFRAME,CandleID,1,cTime);
		retval=(double)cTime[0];
		
		return retval;
	}
	else if (iOHLC=="iTypical") {
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=((cLow[0]+cHigh[0]+cClose[0])/3);
	}
	else if (iOHLC=="iMedian") {
	   CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		retval=((cLow[0]+cHigh[0])/2);
	}
	else if (iOHLC=="iAverage") {
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=((cLow[0]+cHigh[0]+cClose[0]+cClose[0])/4);
	}
	else if (iOHLC=="iTotal") {
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		retval=toPips(MathAbs(cHigh[0]-cLow[0]),SYMBOL);
	}
	else if (iOHLC=="iBody") {
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips(MathAbs(cClose[0]-cOpen[0]),SYMBOL);
	}
	else if (iOHLC=="iUpperWick") {
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		retval=0;
		if (cClose[0]>cOpen[0]) {
		   retval=toPips(MathAbs(cHigh[0]-cClose[0]),SYMBOL);
		} else {
		   retval=toPips(MathAbs(cHigh[0]-cOpen[0]),SYMBOL);
		}
	}
	else if (iOHLC=="iGap")
	{
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID+1,1,cClose);
	
		retval = toPips(MathAbs(cOpen[0]-cClose[0]),SYMBOL);
	}
	else if (iOHLC=="iBottomWick") {
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		retval=0;
		if (cClose[0]>cOpen[0]) {
		   retval=toPips(MathAbs(cOpen[0]-cLow[0]),SYMBOL);
		} else {
		   retval=toPips(MathAbs(cClose[0]-cLow[0]),SYMBOL);
		}
	}
	else if (iOHLC=="iBullTotal") {
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		retval=toPips((cHigh[0]-cLow[0]),SYMBOL);
		if (cClose[0]<cOpen[0]) {return(EMPTY_VALUE);}
	}
	else if (iOHLC=="iBullBody") {
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cClose[0]-cOpen[0]),SYMBOL);
		if (cClose[0]<cOpen[0]) {return(EMPTY_VALUE);}
		}
	else if (iOHLC=="iBullUpperWick") {
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cHigh[0]-cClose[0]),SYMBOL);
		if (cClose[0]<cOpen[0]) {return(EMPTY_VALUE);}
		}
	else if (iOHLC=="iBullBottomWick") {
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cOpen[0]-cLow[0]),SYMBOL);
		if (cClose[0]<cOpen[0]) {return(EMPTY_VALUE);}
	}
	else if (iOHLC=="iBearTotal") {
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		retval=toPips((cHigh[0]-cLow[0]),SYMBOL);
		if (cOpen[0]<cClose[0]) {return(EMPTY_VALUE);}
	}
	else if (iOHLC=="iBearBody") {
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cOpen[0]-cClose[0]),SYMBOL);
		if (cOpen[0]<cClose[0]) {return(EMPTY_VALUE);}
	}
	else if (iOHLC=="iBearUpperWick") {
		CopyHigh(SYMBOL,TIMEFRAME,CandleID,1,cHigh);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cHigh[0]-cOpen[0]),SYMBOL);
		if (cOpen[0]<cClose[0]) {return(EMPTY_VALUE);}
	}
	else if (iOHLC=="iBearBottomWick") {
		CopyLow(SYMBOL,TIMEFRAME,CandleID,1,cLow);
		CopyOpen(SYMBOL,TIMEFRAME,CandleID,1,cOpen);
		CopyClose(SYMBOL,TIMEFRAME,CandleID,1,cClose);
		retval=toPips((cClose[0]-cLow[0]),SYMBOL);
		if (cOpen[0]<cClose[0]) {return(EMPTY_VALUE);}
	}
	
	return(NormalizeDouble(retval, (int)SymbolInfoInteger(SYMBOL, SYMBOL_DIGITS)));
}


double ic_value_value(double Value)
{
return(Value);
}


datetime ic_value_time(int ModeTime, int TimeSource, string TimeStamp, int TimeCandleID, string TimeMarket, ENUM_TIMEFRAMES TimeCandleTimeframe, int TimeComponentYear, int TimeComponentMonth, int TimeComponentDay, int TimeComponentHour, int TimeComponentMinute, int TimeComponentSecond, int ModeTimeShift, int TimeShiftYears, int TimeShiftMonths, int TimeShiftWeeks, int TimeShiftDays, int TimeShiftHours, int TimeShiftMinutes, int TimeShiftSeconds, bool TimeSkipWeekdays)
{
static datetime retval=0, retval0=0;
	static int ModeTime0=0;
	static int smodeshift=0;
	
	if(ModeTime==0)
	{
	   if (TimeSource==0) {retval=TimeCurrent();}
		else if (TimeSource==1) {retval=TimeLocal();}
		else if (TimeSource==2) {retval=TimeGMT();}
	}
	else if(ModeTime==1) {
	      retval=StringToTime(TimeStamp);
	      retval0=retval;
	}
	else if(ModeTime==2) {
	   retval = TimeFromComponents(TimeSource, TimeComponentYear, TimeComponentMonth, TimeComponentDay, TimeComponentHour, TimeComponentMinute, TimeComponentSecond);
	}
	else if(ModeTime==3) {
	      datetime Time[];
	      ArraySetAsSeries(Time,true);
	      CopyTime(TimeMarket,TimeCandleTimeframe,TimeCandleID,1,Time);
	      retval=Time[0];
	}
	
	
	
	if (ModeTimeShift>0) {
	   int sh=1;
	   if (ModeTimeShift==1) {sh=-1;}
	   
	   static int years0=0,months0=0;
	   
	   if (
	      ModeTimeShift!=smodeshift
	      || TimeShiftYears!=years0 || TimeShiftMonths!=months0
	   )
	   {
	      years0=TimeShiftYears; months0=TimeShiftMonths;
	      
	      if (TimeShiftYears>0 || TimeShiftMonths>0) {
	         int year=0,month=0,week=0,day=0,hour=0,minute=0,second=0;
	         if (ModeTime==3) {
	            year=TimeComponentYear; month=TimeComponentYear;    day=TimeComponentDay;
	            hour=TimeComponentHour; minute=TimeComponentMinute; second=TimeComponentSecond;
	         }
	         else {
	            year=TimeYear(retval); month=TimeMonth(retval);   day=TimeDay(retval);
	            hour=TimeHour(retval); minute=TimeMinute(retval); second=TimeSeconds(retval);
	         }
	         
	         year  =year+TimeShiftYears*sh;
	         month =month+TimeShiftMonths*sh;
	         if (month<0) {month=12-month;}
	         else if (month>12) {month=month-12;}
	         retval=StringToTime(IntegerToString(year)+"."+IntegerToString(month)+"."+IntegerToString(day)+" "+IntegerToString(hour)+":"+IntegerToString(minute)+":"+IntegerToString(second));
	      }
	   }
	
	   retval=retval+TimeShiftWeeks*604800*sh+TimeShiftDays*86400*sh+TimeShiftHours*3600*sh+TimeShiftMinutes*60*sh+TimeShiftSeconds*sh;
	   
	   if (TimeSkipWeekdays==true) {
	      int weekday=TimeDayOfWeek(retval);
	      
	      if (sh>0) { // forward
	         if (weekday==0) {retval=retval+86400;}
	         else if (weekday==6) {retval=retval+172800;}
	      }
	      else if (sh<0) { // back
	         if (weekday==0) {retval=retval-172800;}
	         else if (weekday==6) {retval=retval-86400;}
	      }
	   }
	}
	smodeshift=ModeTimeShift;
	ModeTime0=ModeTime;
	
	return (datetime)retval;
}



/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                                   Functions                                                      | //
// |                                 System and Custom functions used in the program                                  | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/


double AccountBalanceAtStart()
{
   // This function MUST be run once at pogram's start
   static double memory=0;
   if (memory==0) {memory=AccountInfoDouble(ACCOUNT_BALANCE);}
   return(memory);
}

template<typename T>
int ArraySearch(T &array[], T value)
{
	static int index;    
	static int size;
	
	index = -1;
	size  = ArraySize(array);

	for (int i=0; i<size; i++)
	{
		if (array[i] == value)
		{
			index = i;
			break;
		}  
	}

   return index;
}

template<typename T>
bool ArrayStripKey(T &array[], int key)
{
	int x    = 0;
	int size = ArraySize(array);
	
	for (int i=0; i<size; i++)
	{
		if (i != key)
		{
			array[x] = array[i];
			x++;
		}
	}
		
	if (x < size)
	{
		ArrayResize(array, x);
		
		return true; // stripped
	}
	
	return false; // not stripped
}

int BuildOrdersList(order &list[])
{
   int last_error=0;
   int total=OrdersTotal();

   int temp_value=(int)MathMax(total,1);
   ArrayResize(list,temp_value);

   int orders_count=0;
   for(int i=total-1; i>=0; i--)
     {
      if(!OrderGetTicket(i))
        {
         last_error=GetLastError();
         Print("BuildOrdersList() - Error #",last_error);
         continue;
        }
      else
        {
        list[i].ticket          =OrderGetTicket(i);
        list[i].time_setup      =(datetime)OrderGetInteger(ORDER_TIME_SETUP);
        list[i].time_expiration =(datetime)OrderGetInteger(ORDER_TIME_EXPIRATION);
        list[i].time_done       =(datetime)OrderGetInteger(ORDER_TIME_DONE);
        list[i].type            =OrderGetInteger(ORDER_TYPE);
        
        list[i].state           =OrderGetInteger(ORDER_STATE);
        list[i].type_filling    =OrderGetInteger(ORDER_TYPE_FILLING);
        list[i].type_time       =OrderGetInteger(ORDER_TYPE_TIME);
        list[i].magic           =OrderGetInteger(ORDER_MAGIC);
        list[i].position_id     =OrderGetInteger(ORDER_POSITION_ID);
        
        list[i].volume_initial  =OrderGetDouble(ORDER_VOLUME_INITIAL);
        list[i].volume_current  =OrderGetDouble(ORDER_VOLUME_CURRENT);
        list[i].price_open      =OrderGetDouble(ORDER_PRICE_OPEN);
        list[i].sl              =OrderGetDouble(ORDER_SL);
        list[i].tp              =OrderGetDouble(ORDER_TP);
        list[i].price_current   =OrderGetDouble(ORDER_PRICE_CURRENT);
        list[i].price_stoplimit =OrderGetDouble(ORDER_PRICE_STOPLIMIT);
        
        list[i].symbol          =OrderGetString(ORDER_SYMBOL);
        list[i].comment         =OrderGetString(ORDER_COMMENT);
        
        orders_count++;
        }
     }

   temp_value=(int)MathMax(orders_count,1);
   ArrayResize(list,temp_value);
   return(orders_count);
}

int BuildPositionsList(position &list[])
{
   int last_error=0;
   int total=PositionsTotal();

   int temp_value=(int)MathMax(total,1);
   ArrayResize(list, temp_value);

   int positions_count=0;
   for(int i=total-1; i>=0; i--)
     {
      if(!PositionSelect(PositionGetSymbol(i)))
        {
         last_error=GetLastError();
         Print("PositionSelect() - Error #",last_error);
         continue;
        }
      else
        {
            // If the position is found, then put its info to the array
            list[i].position_id   =PositionGetInteger(POSITION_IDENTIFIER);
            list[i].type          =PositionGetInteger(POSITION_TYPE);
            list[i].time          =(datetime)PositionGetInteger(POSITION_TIME);
            list[i].magic         =PositionGetInteger(POSITION_MAGIC);
            list[i].volume        =PositionGetDouble(POSITION_VOLUME);
            list[i].price_open    =PositionGetDouble(POSITION_PRICE_OPEN);
            list[i].sl            =PositionGetDouble(POSITION_SL);
            list[i].tp            =PositionGetDouble(POSITION_TP);
            list[i].price_current =PositionGetDouble(POSITION_PRICE_CURRENT);
            list[i].comission     =PositionGetDouble(POSITION_COMMISSION);
            list[i].swap          =PositionGetDouble(POSITION_SWAP);
            list[i].profit        =PositionGetDouble(POSITION_PROFIT);
            list[i].symbol        =PositionGetString(POSITION_SYMBOL);
            list[i].comment       =PositionGetString(POSITION_COMMENT);
            positions_count++;
        }
     }

   temp_value=(int)MathMax(positions_count,1);
   ArrayResize(list,temp_value);
   return(positions_count);
}

int CheckForTradingError(int error_code=-1, string msg_prefix="")
{
   // return 0 -> no error
   // return 1 -> overcomable error
   // return 2 -> fatal error
   
   int retval=0;
   static int tryouts=0;
   
   //-- error check -----------------------------------------------------
   switch(error_code)
   {
      //-- no error
      case 0:
         retval=0;
         break;
      //-- overcomable errors
      case TRADE_RETCODE_REQUOTE:
      case TRADE_RETCODE_REJECT:
      case TRADE_RETCODE_ERROR:
      case TRADE_RETCODE_TIMEOUT:
      case TRADE_RETCODE_INVALID_VOLUME:
      case TRADE_RETCODE_INVALID_PRICE:
      case TRADE_RETCODE_INVALID_STOPS:
      case TRADE_RETCODE_INVALID_EXPIRATION:
      case TRADE_RETCODE_PRICE_CHANGED:
      case TRADE_RETCODE_PRICE_OFF:
      case TRADE_RETCODE_TOO_MANY_REQUESTS:
      case TRADE_RETCODE_NO_CHANGES:
      case TRADE_RETCODE_CONNECTION:
         retval=1;
         break;
      //-- critical errors
      default:
         retval=2;
         break;
   }
   
   if (error_code > 0)
   {
      string msg = "";
      if (retval == 1)
      {
         StringConcatenate(msg, msg_prefix,": ",ErrorMessage(error_code),". Retrying in 5 seconds..");
         Sleep(500); 
      }
      else if (retval == 2)
      {
         StringConcatenate(msg, msg_prefix,": ",ErrorMessage(error_code));
      }
      Print(msg);
   }
   
   if (retval==0)
   {
      tryouts=0;
   }
   else if (retval==1)
   {
      tryouts++;
      if (tryouts>=10)
      {
         tryouts=0;
         retval=2;
      }
      else
      {
         Print("retry #"+(string)tryouts+" of 10");
      }
   }
   
   return(retval);
}

string CurrentSymbol(string symbol="")
{
   static string memory="";
   if (symbol!="") {memory=symbol;} else
   if (memory=="") {memory=Symbol();}
   return(memory);
}

bool DeleteOrder(ulong ticket)
{
   while(true)
   {
      MqlTradeRequest request;
      MqlTradeResult result;
      MqlTradeCheckResult check_result;
      ZeroMemory(request);
      ZeroMemory(result);
      ZeroMemory(check_result);
   
      request.order=ticket;
      request.action=TRADE_ACTION_REMOVE;
      request.comment="Pending order canceled";
   
      if (!OrderCheck(request,check_result))  {
         Print("OrderCheck() failed: "+(string)check_result.comment+" ("+(string)check_result.retcode+")");
         return false;
      }
      
      bool success = OrderSend(request,result);
      
      //-- error check --------------------------------------------------
      if (!success || result.retcode!=TRADE_RETCODE_DONE)
      {
         string errmsgpfx="Delete order error";
         int erraction=CheckForTradingError(result.retcode, errmsgpfx);
         switch(erraction)
         {
            case 0: break;    // no error
            case 1: continue; // overcomable error
            case 2: break;    // fatal error
         }
         return(false);
      }
      
      //-- finish work --------------------------------------------------
      if (result.retcode==TRADE_RETCODE_DONE)
      {
         //== Wait until MT5 updates it's cache
         int w;
         for (w=0; w<5000; w++)
         {
            if (!OrderSelect(ticket)) {break;}
            Sleep(1);
         }
         if (w==5000) {
            Print("Check error: Delete order");  
         }
         if (OrderSelect(ticket)) {
            Print("Something went wrong with the order");
            return false;
         }
      }
      break;
   }
   OnTrade();
   return(true);
}

string DoubleToStr(double d, int dig){return(DoubleToString(d,dig));}

void DrawSpreadInfo()
{
   static bool allow_draw = true;
   if (allow_draw==false) {return;}
   if (MQLInfoInteger(MQL_TESTER) && !MQLInfoInteger(MQL_VISUAL_MODE)) {allow_draw=false;} // Allowed to draw only once in testing mode

   static bool passed         = false;
   static double max_spread   = 0;
   static double min_spread   = EMPTY_VALUE;
   static double avg_spread   = 0;
   static double avg_add      = 0;
   static double avg_cnt      = 0;

   double custom_point = CustomPoint(Symbol());
   double current_spread = 0;
   if (custom_point > 0) {
      current_spread = (SymbolInfoDouble(Symbol(),SYMBOL_ASK)-SymbolInfoDouble(Symbol(),SYMBOL_BID))/custom_point;
   }
   if (current_spread > max_spread) {max_spread = current_spread;}
   if (current_spread < min_spread) {min_spread = current_spread;}
   
   avg_cnt++;
   avg_add     = avg_add + current_spread;
   avg_spread  = avg_add / avg_cnt;

   int x=0; int y=0;
   string name;

   // create objects
   if (passed == false)
   {
      passed=true;
      
      name="fxd_spread_current_label";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+1);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+1);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 18);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "Spread:");
      }
      name="fxd_spread_max_label";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+17);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrOrangeRed);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "max:");
      }
      name="fxd_spread_avg_label";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+9);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "avg:");
      }
      name="fxd_spread_min_label";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+1);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrGold);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "min:");
      }
      name="fxd_spread_current";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+93);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+1);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 18);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "0");
      }
      name="fxd_spread_max";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+173);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+17);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrOrangeRed);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "0");
      }
      name="fxd_spread_avg";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+173);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+9);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "0");
      }
      name="fxd_spread_min";
      if (ObjectFind(0, name)==-1) {
         ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
         ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+173);
         ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+1);
         ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
         ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
         ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
         ObjectSetInteger(0, name, OBJPROP_COLOR, clrGold);
         ObjectSetString(0, name, OBJPROP_FONT, "Arial");
         ObjectSetString(0, name, OBJPROP_TEXT, "0");
      }
   }
   
   ObjectSetString(0, "fxd_spread_current", OBJPROP_TEXT, DoubleToStr(current_spread,2));
   ObjectSetString(0, "fxd_spread_max", OBJPROP_TEXT, DoubleToStr(max_spread,2));
   ObjectSetString(0, "fxd_spread_avg", OBJPROP_TEXT, DoubleToStr(avg_spread,2));
   ObjectSetString(0, "fxd_spread_min", OBJPROP_TEXT, DoubleToStr(min_spread,2));
}

string DrawStatus(string text="")
{
   static string memory;
   if (text=="") {
      return(memory);
   }
   
   static bool passed = false;
   int x=210; int y=0;
   string name;

   //-- draw the objects once
   if (passed == false)
   {
      passed = true;
      name="fxd_status_title";
      ObjectCreate(0,name, OBJ_LABEL, 0, 0, 0);
      ObjectSetInteger(0,name, OBJPROP_BACK, false);
      ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
      ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
      ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
      ObjectSetInteger(0,name, OBJPROP_XDISTANCE, x);
      ObjectSetInteger(0,name, OBJPROP_YDISTANCE, y+17);
      ObjectSetString(0,name, OBJPROP_TEXT, "Status");
      ObjectSetString(0,name, OBJPROP_FONT, "Arial");
      ObjectSetInteger(0,name, OBJPROP_FONTSIZE, 7);
      ObjectSetInteger(0,name, OBJPROP_COLOR, clrGray);
      
      name="fxd_status_text";
      ObjectCreate(0,name, OBJ_LABEL, 0, 0, 0);
      ObjectSetInteger(0,name, OBJPROP_BACK, false);
      ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
      ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
      ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
      ObjectSetInteger(0,name, OBJPROP_XDISTANCE, x+2);
      ObjectSetInteger(0,name, OBJPROP_YDISTANCE, y+1);
      ObjectSetString(0,name, OBJPROP_FONT, "Arial");
      ObjectSetInteger(0,name, OBJPROP_FONTSIZE, 12);
      ObjectSetInteger(0,name, OBJPROP_COLOR, clrAqua);
   }

   //-- update the text when needed
   if (text != memory) {
      memory=text;
      ObjectSetString(0,"fxd_status_text", OBJPROP_TEXT, text);
   }
   
   return(text);
}

string ErrorMessage(int error_code=-1)
{
	string e = "";
	if (error_code<0) {error_code=GetLastError();}
	

	switch(error_code)
	{
		//--- success
		case 0: return("The operation completed successfully");
		
		//--- Runtime
		case 4001: e = "Unexpected internal error"; break;
		case 4002: e = "Wrong parameter in the inner call of the client terminal function"; break;
		case 4003: e = "Wrong parameter when calling the system function"; break;
		case 4004: e = "Not enough memory to perform the system function"; break;
		case 4005: e = "The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes"; break;
		case 4006: e = "Array of a wrong type, wrong size, or a damaged object of a dynamic array"; break;
		case 4007: e = "Not enough memory for the relocation of an array, or an attempt to change the size of a static array"; break;
		case 4008: e = "Not enough memory for the relocation of string"; break;
		case 4009: e = "Not initialized string"; break;
		case 4010: e = "Invalid date and/or time"; break;
		case 4011: e = "Requested array size exceeds 2 GB"; break;
		case 4012: e = "Wrong pointer"; break;
		case 4013: e = "Wrong type of pointer"; break;
		case 4014: e = "System function is not allowed to call"; break;
		case 4015: e = "The names of the dynamic and the static resource match"; break;
		case 4016: e = "Resource with this name has not been found in EX5"; break;
		case 4017: e = "Unsupported resource type or its size exceeds 16 Mb"; break;
		case 4018: e = "The resource name exceeds 63 characters"; break;
		
		//-- Charts
		case 4101: e = "Wrong chart ID"; break;
		case 4102: e = "Chart does not respond"; break;
		case 4103: e = "Chart not found"; break;
		case 4104: e = "No Expert Advisor in the chart that could handle the event"; break;
		case 4105: e = "Chart opening error"; break;
		case 4106: e = "Failed to change chart symbol and period"; break;
		case 4107: e = "Wrong parameter for timer"; break;
		case 4108: e = "Failed to create timer"; break;
		case 4109: e = "Wrong chart property ID"; break;
		case 4110: e = "Error creating screenshots"; break;
		case 4111: e = "Error navigating through chart"; break;
		case 4112: e = "Error applying template"; break;
		case 4113: e = "Subwindow containing the indicator was not found"; break;
		case 4114: e = "Error adding an indicator to chart"; break;
		case 4115: e = "Error deleting an indicator from the chart"; break;
		case 4116: e = "Indicator not found on the specified chart"; break;

		//-- Graphical Objects
		case 4201: e = "Error working with a graphical object"; break;
		case 4202: e = "Graphical object was not found"; break;
		case 4203: e = "Wrong ID of a graphical object property"; break;
		case 4204: e = "Unable to get date corresponding to the value"; break;
		case 4205: e = "Unable to get value corresponding to the date"; break;

		//-- Market Info
		case 4301: e = "Unknown symbol"; break;
		case 4302: e = "Symbol is not selected in MarketWatch"; break;
		case 4303: e = "Wrong identifier of a symbol property"; break;
		case 4304: e = "Time of the last tick is not known (no ticks)"; break;
		case 4305: e = "Error adding or deleting a symbol in MarketWatch"; break;

		//-- History Access
		case 4401: e = "Requested history not found"; break;
		case 4402: e = "Wrong ID of the history property"; break;

		//-- Global Variables
		case 4501: e = "Global variable of the client terminal is not found"; break;
		case 4502: e = "Global variable of the client terminal with the same name already exists"; break;
		case 4510: e = "Email sending failed"; break;
		case 4511: e = "Sound playing failed"; break;
		case 4512: e = "Wrong identifier of the program property"; break;
		case 4513: e = "Wrong identifier of the terminal property"; break;
		case 4514: e = "File sending via ftp failed"; break;
		case 4515: e = "Failed to send a notification"; break;
		case 4516: e = "Invalid parameter for sending a notification - an empty string or NULL has been passed to the SendNotification() function"; break;
		case 4517: e = "Wrong settings of notifications in the terminal (ID is not specified or permission is not set)"; break;
		case 4518: e = "Too frequent sending of notifications"; break;

		//-- Custom Indicator Buffers
		case 4601: e = "Not enough memory for the distribution of indicator buffers"; break;
		case 4602: e = "Wrong indicator buffer index"; break;

		//-- Custom Indicator Properties
		case 4603: e = "Wrong ID of the custom indicator property"; break;

		//-- Account
		case 4701: e = "Wrong account property ID"; break;
		case 4751: e = "Wrong trade property ID"; break;
		case 4752: e = "Trading by Expert Advisors prohibited"; break;
		case 4753: e = "Position not found"; break;
		case 4754: e = "Order not found"; break;
		case 4755: e = "Deal not found"; break;
		case 4756: e = "Trade request sending failed"; break;

		//-- Indicators
		case 4801: e = "Unknown symbol"; break;
		case 4802: e = "Indicator cannot be created"; break;
		case 4803: e = "Not enough memory to add the indicator"; break;
		case 4804: e = "The indicator cannot be applied to another indicator"; break;
		case 4805: e = "Error applying an indicator to chart"; break;
		case 4806: e = "Requested data not found"; break;
		case 4807: e = "Wrong indicator handle"; break;
		case 4808: e = "Wrong number of parameters when creating an indicator"; break;
		case 4809: e = "No parameters when creating an indicator"; break;
		case 4810: e = "The first parameter in the array must be the name of the custom indicator"; break;
		case 4811: e = "Invalid parameter type in the array when creating an indicator"; break;
		case 4812: e = "Wrong index of the requested indicator buffer"; break;

		//-- Depth of Market
		case 4901: e = "Depth Of Market can not be added"; break;
		case 4902: e = "Depth Of Market can not be removed"; break;
		case 4903: e = "The data from Depth Of Market can not be obtained"; break;
		case 4904: e = "Error in subscribing to receive new data from Depth Of Market"; break;

		//-- File Operations
		case 5001: e = "More than 64 files cannot be opened at the same time"; break;
		case 5002: e = "Invalid file name"; break;
		case 5003: e = "Too long file name"; break;
		case 5004: e = "File opening error"; break;
		case 5005: e = "Not enough memory for cache to read"; break;
		case 5006: e = "File deleting error"; break;
		case 5007: e = "A file with this handle was closed, or was not opening at all"; break;
		case 5008: e = "Wrong file handle"; break;
		case 5009: e = "The file must be opened for writing"; break;
		case 5010: e = "The file must be opened for reading"; break;
		case 5011: e = "The file must be opened as a binary one"; break;
		case 5012: e = "The file must be opened as a text"; break;
		case 5013: e = "The file must be opened as a text or CSV"; break;
		case 5014: e = "The file must be opened as CSV"; break;
		case 5015: e = "File reading error"; break;
		case 5016: e = "String size must be specified, because the file is opened as binary"; break;
		case 5017: e = "A text file must be for string arrays, for other arrays - binary"; break;
		case 5018: e = "This is not a file, this is a directory"; break;
		case 5019: e = "File does not exist"; break;
		case 5020: e = "File can not be rewritten"; break;
		case 5021: e = "Wrong directory name"; break;
		case 5022: e = "Directory does not exist"; break;
		case 5023: e = "This is a file, not a directory"; break;
		case 5024: e = "The directory cannot be removed"; break;
		case 5025: e = "Failed to clear the directory (probably one or more files are blocked and removal operation failed)"; break;
		case 5026: e = "Failed to write a resource to a file"; break;

		//-- String Casting
		case 5030: e = "No date in the string"; break;
		case 5031: e = "Wrong date in the string"; break;
		case 5032: e = "Wrong time in the string"; break;
		case 5033: e = "Error converting string to date"; break;
		case 5034: e = "Not enough memory for the string"; break;
		case 5035: e = "The string length is less than expected"; break;
		case 5036: e = "Too large number, more than ULONG_MAX"; break;
		case 5037: e = "Invalid format string"; break;
		case 5038: e = "Amount of format specifiers more than the parameters"; break;
		case 5039: e = "Amount of parameters more than the format specifiers"; break;
		case 5040: e = "Damaged parameter of string type"; break;
		case 5041: e = "Position outside the string"; break;
		case 5042: e = "0 added to the string end, a useless operation"; break;
		case 5043: e = "Unknown data type when converting to a string"; break;
		case 5044: e = "Damaged string object"; break;

		//-- Operations with Arrays
		case 5050: e = "Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in numeric array only"; break;
		case 5051: e = "The receiving array is declared as AS_SERIES, and it is of insufficient size"; break;
		case 5052: e = "Too small array, the starting position is outside the array"; break;
		case 5053: e = "An array of zero length"; break;
		case 5054: e = "Must be a numeric array"; break;
		case 5055: e = "Must be a one-dimensional array"; break;
		case 5056: e = "Timeseries cannot be used"; break;
		case 5057: e = "Must be an array of type double"; break;
		case 5058: e = "Must be an array of type float"; break;
		case 5059: e = "Must be an array of type long"; break;
		case 5060: e = "Must be an array of type int"; break;
		case 5061: e = "Must be an array of type short"; break;
		case 5062: e = "Must be an array of type char"; break;
		
		//-- Operations with OpenCL
		case 5100: e = "OpenCL functions are not supported on this computer"; break;
		case 5101: e = "Internal error occurred when running OpenCL"; break;
		case 5102: e = "Invalid OpenCL handle"; break;
		case 5103: e = "Error creating the OpenCL context"; break;
		case 5104: e = "Failed to create a run queue in OpenCL"; break;
		case 5105: e = "Error occurred when compiling an OpenCL program"; break;
		case 5106: e = "Too long kernel name (OpenCL kernel)"; break;
		case 5107: e = "Error creating an OpenCL kernel"; break;
		case 5108: e = "Error occurred when setting parameters for the OpenCL kernel"; break;
		case 5109: e = "OpenCL program runtime error"; break;
		case 5110: e = "Invalid size of the OpenCL buffer"; break;
		case 5111: e = "Invalid offset in the OpenCL buffer"; break;
		case 5112: e = "Failed to create an OpenCL buffer"; break;
		
		//-- Operations with WebRequest
		case 5200: e = "Invalid URL"; break;
		case 5201: e = "Failed to connect to specified URL"; break;
		case 5202: e = "Timeout exceeded"; break;
		case 5203: e = "HTTP request failed"; break;

		//-- trading errors
		case 10004: e = "Requote occured"; break;
		case 10006: e = "Order is not accepted by the server"; break;
		case 10007: e = "Request canceled by trader"; break;
		case 10010: e = "Only part of the request was completed"; break;
		case 10011: e = "Request processing error"; break;
		case 10012: e = "Request canceled by timeout"; break;
		case 10013: e = "Invalid request"; break;
		case 10014: e = "Invalid volume"; break;
		case 10015: e = "Invalid price"; break;
		case 10016: e = "Invalid SL or TP"; break;
		case 10017: e = "Trading is disabled"; break;
		case 10018: e = "Market is closed"; break;
		case 10019: e = "Not enough money to trade"; break;
		case 10020: e = "Prices changed"; break;
		case 10021: e = "There are no quotes to process the request"; break;
		case 10022: e = "Invalid expiration date in the order request"; break;
		case 10023: e = "Order state changed"; break;
		case 10024: e = "Too frequent requests"; break;
		case 10025: e = "No changes in request"; break;
		case 10026: e = "Autotrading is disabled by the server"; break;
		case 10027: e = "Autotrading is disabled by the client terminal"; break;
		case 10028: e = "Request locked for processing"; break;
		case 10029: e = "Order or trade frozen"; break;
		case 10030: e = "Invalid order filling type"; break;
		case 10031: e = "No connection with the trade server"; break;
		case 10032: e = "Operation is allowed only for live accounts"; break;
		case 10033: e = "The number of pending orders has reached the limit"; break;
		case 10034: e = "The volume of orders and trades for the symbol has reached the limit"; break;
		case 10035: e = "Incorrect or prohibited order type"; break;
		case 10036: e = "Position with the specified POSITION_IDENTIFIER has already been closed"; break;
		//-- User-Defined Errors
		case 65536: e = "User defined errors"; break;
		default:	e = "Unknown error";
	}

	StringConcatenate(e, e," (",error_code,")");
	
	return e;
}

string GetSymbol(string symbol="")
{
   static string memory="";
   if (symbol=="") {
      if (memory=="") {memory=Symbol();}
   }
   else {memory=symbol;}
   return(memory);
}

int IndicatorMoreShift(bool set=false, int shift=0)
{
   static int mem;
   if (set==true) {mem=shift;}
   else {
      int return_val=mem; mem=0; // reset
      return(return_val);
   }
   return(mem);
}

bool LoadOrder(string symbol)
{
	// THIS FUNCTION NOW PROBABLY DOESNT WORK
   bool success = PositionSelect(symbol);
	
   if (success) {
		LoadedType(1);
		OrderTicket((long)PositionGetInteger(POSITION_IDENTIFIER));
	}
	
   return success;
}
bool LoadOrder(ulong ticket)
{
   bool success = OrderSelect(ticket);
	
   if (success) {
		LoadedType(2);
		OrderTicket(ticket);
	}
	
   return success;
}

int LoadedType(int type=0)
{
   // 1 - position
   // 2 - pending order
   // 3 - history position
   // 4 - history pending order
	static int memory;
   if (type>0) {memory=type;}
   return(memory);
}

int OCODriver()
{
   static ulong last_known_ticket = 0;
   static ulong orders1[];
   static ulong orders2[];
   int i, size;
   
   int total = OrdersTotal();
   
   for (int pos=total-1; pos>=0; pos--)
   {
      if (LoadOrder(OrderGetTicket(pos)))
      {
         ulong ticket = OrderTicket();
         
         //-- end here if we reach the last known ticket
         if (ticket == last_known_ticket) {break;}
         
         //-- set the last known ticket, only if this is the first iteration
         if (pos == total-1) {
            last_known_ticket = ticket;
         }
         
         //-- we are searching for pending orders, skip trades
         if (OrderType() <= ORDER_TYPE_SELL) {continue;}
         
         //--
         if (StringSubstr(OrderComment(), 0, 5) == "[oco:")
         {
            int ticket_oco = StrToInteger(StringSubstr(OrderComment(), 5, StringLen(OrderComment())-1)); 
            
            bool found = false;
            size = ArraySize(orders2);
            for (i=0; i<size; i++)
            {
               if (orders2[i] == ticket_oco) {
                  found = true;
                  break;
               }
            }
            
            if (found == false) {
               ArrayResize(orders1, size+1);
               ArrayResize(orders2, size+1);
               orders1[size] = ticket_oco;
               orders2[size] = ticket;
            }
         }
      }
   }
   
   size = ArraySize(orders1);
   int dbremove = false;
   for (i=0; i<size; i++)
   {
      if (LoadOrder(orders1[i]) == false || OrderType() <= ORDER_TYPE_SELL)
      {
         if (LoadOrder(orders2[i])) {
            if (DeleteOrder(orders2[i]))
            {
               dbremove = true;
            }
         }
         else {
            dbremove = true;
         }
         
         if (dbremove == true)
         {
            ArrayStripKey(orders1, i);
            ArrayStripKey(orders2, i);
         }
      }
   }
   
   size = ArraySize(orders2);
   dbremove = false;
   for (i=0; i<size; i++)
   {
      if (LoadOrder(orders2[i]) == false || OrderType() <= ORDER_TYPE_SELL)
      {
         if (LoadOrder(orders1[i])) {
            if (DeleteOrder(orders1[i]))
            {
               dbremove = true;
            }
         }
         else {
            dbremove = true;
         }
         
         if (dbremove == true)
         {
            ArrayStripKey(orders1, i);
            ArrayStripKey(orders2, i);
         }
      }
   }
   
   return true;
}

bool OnTimerSet(double seconds)
{
   if (seconds<=0) {
      EventKillTimer();
   }
   else if (seconds < 1) {
      return (EventSetMillisecondTimer((int)(seconds*1000)));  
   }
   else {
      return (EventSetTimer((int)seconds));
   }
   
   return true;
}

bool OnTradeDetector() {

   static int lastOrdersTotal    =OrdersTotal();      // Number of orders at the time of previous OnTrade() call
   static int lastPositionsTotal =PositionsTotal();   // Number of positions at the time of previous OnTrade() call
   
   int i=0;
   ulong ticket=0;
   int last_error=0;
   long state=0;
   bool event=false;
   int positions_count  =BuildPositionsList(EGV_PositionsList);
   int orders_count     =BuildOrdersList(EGV_OrderList);
   HistorySelect(0, TimeCurrent());

   if (lastOrdersTotal < OrdersTotal())
   {
      ticket=OrderGetTicket(OrdersTotal()-1); // Select the last order
      bool success = OrderSelect(ticket);
      state = OrderGetInteger(ORDER_STATE);
      
      if (state == ORDER_STATE_STARTED) {
         //Print("Order #",ticket," has arrived for processing");
      }
      else if (state == ORDER_STATE_PLACED) {
         // Event: New order created
         Print("Pending order type ",(int)OrderGetInteger(ORDER_TYPE)," #", ticket," accepted!");
         UpdateEventValues(EGV_OrderList[OrdersTotal()-1],"new","");
         event=true;
      }
   }
   else if(lastOrdersTotal > OrdersTotal())
   {
      // Select the order that is missing in the new list
      int size=ArraySize(EGV_OrderList);
      int size0=ArraySize(EGV_OrderList0);
      for (i=size0-1; i>=0; i--) {
         ticket=EGV_OrderList0[i].ticket;
         bool found=false;
         for (int j=size-1; j>=0; j--) {
            if (ticket==EGV_OrderList[j].ticket) {found=true;break;}
         }
         if (found==false) {
            break;
         }
      }
      if (i<0) {i=0;}
      
      // Now load that order
      HistoryOrderSelect(ticket);
      state = HistoryOrderGetInteger(ticket,ORDER_STATE);
      if (state==0 && GetLastError()==ERR_TRADE_ORDER_NOT_FOUND) {state=2;}
      
      //Print("Last order ticket = ",ticket, "| state = ",state, "| GetLastError= ",GetLastError());
      
      // If order is not found, generate an error
      ResetLastError();
      last_error=GetLastError();
      if (last_error>0){Print("Error #",last_error," Order ",ticket," was not found!");}
      ResetLastError();
   
      if (state == ORDER_STATE_CANCELED)
      {
         Print("Order #",ticket," has been cancelled.");
         UpdateEventValues(EGV_OrderList0[i],"close","");
         event=true;
      }
      else if (state == ORDER_STATE_EXPIRED)
      {
         Print("Order #",ticket," expired.");
         UpdateEventValues(EGV_OrderList0[i],"expire","");
         event=true;
      }
      else
      // If order is fully executed, analyze the last deal
      if (state == ORDER_STATE_FILLED)
      {
         ulong deal_ticket=HistoryDealGetTicket(HistoryDealsTotal()-1);
         long deal_type=HistoryDealGetInteger(deal_ticket,DEAL_TYPE); // 0 - BUY, 1 - SELL
         string text="";
         
         switch((int)HistoryDealGetInteger(deal_ticket,DEAL_ENTRY))
         {
            // Entering the market
            case DEAL_ENTRY_IN:
               
               if (deal_type==DEAL_TYPE_BUY) {text="Buy";}
               else if (deal_type==DEAL_TYPE_SELL) {text="Sell";}
               
               Print(" Order #",HistoryDealGetInteger(deal_ticket,DEAL_ORDER)," invoked deal #",deal_ticket);
               if (PositionSelect(HistoryDealGetString(deal_ticket,DEAL_SYMBOL))) { 
                  // Position has just been opened
                  if (PositionGetDouble(POSITION_VOLUME) == HistoryDealGetDouble(deal_ticket,DEAL_VOLUME))
                  {
                     Print(text," position has been opened on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL));
                     UpdateEventValues(deal_ticket,"new","fromorder");
                     event=true;
                  }
                  else
                  // Position has been incremented
                  if (PositionGetDouble(POSITION_VOLUME) > HistoryDealGetDouble(deal_ticket,DEAL_VOLUME))
                  {
                     Print(text," position has incremented on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL));
                     UpdateEventValues(deal_ticket,"increment","fromorder");
                     event=true;
                  }
                  else
                  // Position has been decremented
                  if (PositionGetDouble(POSITION_VOLUME) < HistoryDealGetDouble(deal_ticket,DEAL_VOLUME))
                  {
                     Print(text," position has decremented on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL));
                     UpdateEventValues(deal_ticket,"decrement","fromorder");
                     event=true;
                  }
               }
            break;
            
            // Exiting the market
            case DEAL_ENTRY_OUT:
            
               if (deal_type==DEAL_TYPE_BUY) {text="Sell";}
               else if (deal_type==DEAL_TYPE_SELL) {text="Buy";}
               
               Print(HistoryDealGetInteger(deal_ticket,DEAL_ORDER)," order invoked deal #",deal_ticket);
               
               // If position, we tried to close, is still present, then we have closed only part of it
               if (PositionSelect(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)) == true)
               {
                  Print("Part of ",text," position has been closed on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL)," with profit = ",HistoryDealGetDouble(deal_ticket,DEAL_PROFIT));
                  UpdateEventValues(deal_ticket,"closepart","fromorder");
                  event=true;
               }
               else
               // If position is not found, then it is fully closed
               {
                  Print(text," position has been closed on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL)," with profit = ",HistoryDealGetDouble(deal_ticket,DEAL_PROFIT));
                  UpdateEventValues(deal_ticket,"close","fromorder");
                  event=true;
               }
            break;
            
            // Reverse
            case DEAL_ENTRY_INOUT:
            
               Print(HistoryDealGetInteger(deal_ticket,DEAL_ORDER)," order invoked deal #",deal_ticket);
               
               switch((int)deal_type)
               {
                  case 0:
                     Print("Sell is reversed to Buy on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL)," resulting profit = ",HistoryDealGetDouble(deal_ticket,DEAL_PROFIT)); 
                  break;
                  
                  case 1:
                     Print("Buy is reversed to Sell on pair ",HistoryDealGetString(deal_ticket,DEAL_SYMBOL)," resulting profit = ",HistoryDealGetDouble(deal_ticket,DEAL_PROFIT)); 
                  break;
                  
                  default:
                     Print("Unprocessed code of type: ",deal_type);
                  break;
               }
               UpdateEventValues(deal_ticket,"reverse","fromorder");
               event=true;
            break;
            
            // Indicates the state record
            case DEAL_ENTRY_STATE:
               //Print("Unprocessed code of direction: ",HistoryDealGetInteger(deal_ticket,DEAL_TYPE));
            break;
         }
      }
   }
   else if (lastPositionsTotal<PositionsTotal()) {
      ulong deal_ticket=HistoryDealGetTicket(HistoryDealsTotal()-1);
      // New position opened
      UpdateEventValues(deal_ticket,"new","");
      event=true;
   }
   else if (lastPositionsTotal>PositionsTotal()) {
      ulong deal_ticket=HistoryDealGetTicket(HistoryDealsTotal()-1);
      // Position closed
      UpdateEventValues(deal_ticket,"close","");
      e_attrMagicNumber(true, EGV_PositionsList0[i].magic); // for some reason magic number can be get only once in the normal way
      event=true;
   }
   
   if ((lastPositionsTotal == PositionsTotal()) && (lastOrdersTotal == OrdersTotal()))
   {  
      for (i=0; i<positions_count; i++)
      {
         // Position reverse
         if (EGV_PositionsList0[i].type != EGV_PositionsList[i].type)
         {
            Print(EGV_PositionsList[i].symbol+" volume reversed from "+ (string)EGV_PositionsList0[i].type +" to "+ (string)EGV_PositionsList[i].type);
            UpdateEventValues(EGV_PositionsList[i],"reverse","");
            event=true;
         }
         // Position modified SL and/or TP
         if ((EGV_PositionsList0[i].sl != EGV_PositionsList[i].sl) && (EGV_PositionsList0[i].tp != EGV_PositionsList[i].tp)) {
            Print(EGV_PositionsList[i].symbol+" Stop Loss changed from "+ (string)EGV_PositionsList0[i].sl +" to "+ (string)EGV_PositionsList[i].sl);
            Print(EGV_PositionsList[i].symbol+" Take Profit changed from "+ (string)EGV_PositionsList0[i].tp +" to "+ (string)EGV_PositionsList[i].tp);
            UpdateEventValues(EGV_PositionsList[i],"modify","sltp");
            event=true;
         } else {
            if (EGV_PositionsList0[i].sl != EGV_PositionsList[i].sl)
            {
               Print(EGV_PositionsList[i].symbol+" Stop Loss changed from "+ (string)EGV_PositionsList0[i].sl +" to "+ (string)EGV_PositionsList[i].sl);
               UpdateEventValues(EGV_PositionsList[i],"modify","sl");
               event=true;
            }
            if (EGV_PositionsList0[i].tp != EGV_PositionsList[i].tp)
            {
               Print(EGV_PositionsList[i].symbol+" Take Profit changed from "+ (string)EGV_PositionsList0[i].tp +" to "+ (string)EGV_PositionsList[i].tp);
               UpdateEventValues(EGV_PositionsList[i],"modify","tp");
               event=true;
            }
         }
         // Check position increment/decrement
         if (EGV_PositionsList0[i].volume < EGV_PositionsList[i].volume)
         {
            Print(EGV_PositionsList[i].symbol+" volume incremented from "+ (string)EGV_PositionsList0[i].volume +" to "+ (string)EGV_PositionsList[i].volume);
            UpdateEventValues(EGV_PositionsList[i],"increment","");
            event=true;
         }
         else if (EGV_PositionsList0[i].volume > EGV_PositionsList[i].volume)
         {
            Print(EGV_PositionsList[i].symbol+" volume decremented from "+ (string)EGV_PositionsList0[i].volume +" to "+ (string)EGV_PositionsList[i].volume);
            UpdateEventValues(EGV_PositionsList[i],"decrement","");
            event=true;
         }
      }
      
      for (i=0; i<orders_count; i++)
      {
         if ((EGV_OrderList0[i].sl != EGV_OrderList[i].sl) && (EGV_OrderList0[i].tp != EGV_OrderList[i].tp)) {
            Print("Order "+(string)EGV_OrderList[i].ticket+" has changed Stop Loss from "+ (string)EGV_OrderList0[i].sl +" to "+ (string)EGV_OrderList[i].sl);
            Print("Order "+(string)EGV_OrderList[i].ticket+" has changed Take Profit from "+ (string)EGV_OrderList0[i].tp +" to "+ (string)EGV_OrderList[i].tp);
            UpdateEventValues(EGV_OrderList[i],"modify","sltp");
            event=true;
         } else {
            if (EGV_OrderList0[i].sl != EGV_OrderList[i].sl)
            {
               Print("Order "+(string)EGV_OrderList[i].ticket+" has changed Stop Loss from "+ (string)EGV_OrderList0[i].sl +" to "+ (string)EGV_OrderList[i].sl);
               UpdateEventValues(EGV_OrderList[i],"modify","sl");
               event=true;
            }
            if (EGV_OrderList0[i].tp != EGV_OrderList[i].tp)
            {
               Print("Order "+(string)EGV_OrderList[i].ticket+" has changed Take Profit from "+ (string)EGV_OrderList0[i].tp +" to "+ (string)EGV_OrderList[i].tp);
               UpdateEventValues(EGV_OrderList[i],"modify","tp");
               event=true;
            }
         }
         if (EGV_OrderList0[i].price_open != EGV_OrderList[i].price_open)
         {
            Print("Order "+(string)EGV_OrderList[i].ticket+" has changed Open Price from "+ (string)EGV_OrderList0[i].price_open +" to "+ (string)EGV_OrderList[i].price_open);
            UpdateEventValues(EGV_OrderList[i],"modify","price");
            event=true;
         }
         if (EGV_OrderList0[i].time_expiration != EGV_OrderList[i].time_expiration)
         {
            Print("Order "+(string)EGV_OrderList[i].time_expiration+" has changed Expiration from "+ (string)EGV_OrderList0[i].time_expiration +" to "+ (string)EGV_OrderList[i].time_expiration);
            UpdateEventValues(EGV_OrderList[i],"modify","expiration");
            event=true;
         }
      }
   }
   
   
   
   BuildPositionsList(EGV_PositionsList0);
   BuildOrdersList(EGV_OrderList0);
   lastOrdersTotal     =OrdersTotal();
   lastPositionsTotal  =PositionsTotal();
   
   if (event==true) {return(true);} else {return(false);}
}

int OnTradeQueue(int queue=0)
{
	static int mem=0;
   mem=mem+queue;
   return(mem);
}

string OrderComment()
{
   if (LoadedType()==1){return(PositionGetString(POSITION_COMMENT));}
   if (LoadedType()==3){return(HistoryDealGetString(OrderTicket(),DEAL_COMMENT));}
   if (LoadedType()==4){return(HistoryOrderGetString(OrderTicket(),ORDER_COMMENT));}
   return(OrderGetString(ORDER_COMMENT));
}

ulong OrderTicket(ulong Ticket=0)
{
   static ulong memory;             // Ticket memory
   if (Ticket>0) {memory=Ticket;}   // Set Ticket
   return(memory);                  // Get Ticket
}

int OrderType() {
   if (LoadedType()==1){return((int)PositionGetInteger(POSITION_TYPE));}
   if (LoadedType()==3){
      int OT=(int)HistoryDealGetInteger(OrderTicket(),DEAL_TYPE);
      if(OT==1){return(0);}
      if(OT==0){return(1);}
      return(OT);
   }
   if (LoadedType()==4){return((int)HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE));}
   return((int)OrderGetInteger(ORDER_TYPE));
}

double PipValue(string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(CustomPoint(symbol)/SymbolInfoDouble(symbol,SYMBOL_POINT));
   /*
   if (symbol=="") {symbol=GetSymbol();}
   int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
   if ((digits==2 || digits==4)) {return((int)(POINT_FORMAT/0.0001));}
   if ((digits==3 || digits==5)) {return((int)(POINT_FORMAT/0.00001));}
   if ((digits==6))              {return((int)(POINT_FORMAT/0.000001));}
   return(1);
   */
}

int StrToInteger(string value){return((int)StringToInteger(value));}

void StringExplode(string sDelimiter, string sExplode, string &sReturn[]){
   int ilBegin = -1,ilEnd = 0;
   int ilElement=0;
   while (ilEnd != -1){
      ilEnd = StringFind(sExplode, sDelimiter, ilBegin+1);
      ArrayResize(sReturn,ilElement+1);
      sReturn[ilElement] = "";     
      if (ilEnd == -1){
         if (ilBegin+1 != StringLen(sExplode)){
            sReturn[ilElement] = StringSubstr(sExplode, ilBegin+1, StringLen(sExplode));
         }
      } else { 
         if (ilBegin+1 != ilEnd){
            sReturn[ilElement] = StringSubstr(sExplode, ilBegin+1, ilEnd-ilBegin-1);
         }
      }      
      ilBegin = StringFind(sExplode, sDelimiter,ilEnd);  
      ilElement++;    
   }
}

void StringExplode(string sDelimiter, string sExplode, int &sReturn[]){
   int ilBegin = -1,ilEnd = 0;
   int ilElement=0;
   while (ilEnd != -1){
      ilEnd = StringFind(sExplode, sDelimiter, ilBegin+1);
      ArrayResize(sReturn,ilElement+1);
      sReturn[ilElement] = 0;     
      if (ilEnd == -1){
         if (ilBegin+1 != StringLen(sExplode)){
            sReturn[ilElement] = (int)StringToInteger(StringSubstr(sExplode, ilBegin+1, StringLen(sExplode)));
         }
      } else { 
         if (ilBegin+1 != ilEnd){
            sReturn[ilElement] = (int)StringToInteger(StringSubstr(sExplode, ilBegin+1, ilEnd-ilBegin-1));
         }
      }      
      ilBegin = StringFind(sExplode, sDelimiter,ilEnd);  
      ilElement++;    
   }
}

void StringExplode(string sDelimiter, string sExplode, double &sReturn[]){
   int ilBegin = -1,ilEnd = 0;
   int ilElement=0;
   while (ilEnd != -1){
      ilEnd = StringFind(sExplode, sDelimiter, ilBegin+1);
      ArrayResize(sReturn,ilElement+1);
      sReturn[ilElement] = 0;     
      if (ilEnd == -1){
         if (ilBegin+1 != StringLen(sExplode)){
            sReturn[ilElement] = (double)StringToDouble(StringSubstr(sExplode, ilBegin+1, StringLen(sExplode)));
         }
      } else { 
         if (ilBegin+1 != ilEnd){
            sReturn[ilElement] = (double)StringToDouble(StringSubstr(sExplode, ilBegin+1, ilEnd-ilBegin-1));
         }
      }      
      ilBegin = StringFind(sExplode, sDelimiter,ilEnd);  
      ilElement++;    
   }
}

datetime StringToTimeEx(string str, string mode="server")
{
	// mode: server, local, gmt
	if (StringFind(str, " ") != -1) {
	   return StringToTime(str);
	}
	
	datetime now = 0;
	datetime retval = 0;
	
	if (mode == "server") {now = TimeCurrent();}
	else if (mode == "local") {now = TimeLocal();}
	else if (mode == "gmt") {now = TimeGMT();}
	
	return StringToTime(TimeYear(now)+"."+TimeMonth(now)+"."+TimeDay(now)+" "+str);
}

ENUM_TIMEFRAMES TFMigrate(int tf)
{
 switch(tf)
   {
    case 0: return(PERIOD_CURRENT);
    case 1: return(PERIOD_M1);
    case 5: return(PERIOD_M5);
    case 15: return(PERIOD_M15);
    case 30: return(PERIOD_M30);
    case 60: return(PERIOD_H1);
    case 240: return(PERIOD_H4);
    case 1440: return(PERIOD_D1);
    case 10080: return(PERIOD_W1);
    case 43200: return(PERIOD_MN1);
    
    case 2: return(PERIOD_M2);
    case 3: return(PERIOD_M3);
    case 4: return(PERIOD_M4);      
    case 6: return(PERIOD_M6);
    case 10: return(PERIOD_M10);
    case 12: return(PERIOD_M12);
    case 16385: return(PERIOD_H1);
    case 16386: return(PERIOD_H2);
    case 16387: return(PERIOD_H3);
    case 16388: return(PERIOD_H4);
    case 16390: return(PERIOD_H6);
    case 16392: return(PERIOD_H8);
    case 16396: return(PERIOD_H12);
    case 16408: return(PERIOD_D1);
    case 32769: return(PERIOD_W1);
    case 49153: return(PERIOD_MN1);
    default: return(PERIOD_CURRENT);
   }
}

double TicksData(string symbol="", int type=0, int shift=0)
{
   
   //return(MarketInfo(symbol,type));
   static bool collecting_ticks=false;
   //static string feeded_symbols[];
   static string symbols[];
   static int zero_sid[];
   static double memoryASK[][100];
   static double memoryBID[][100];
   int sid=0, size=0, i=0, id=0;
   double ask=0, bid=0, retval=0;
   bool exists=false;
   
   if (ArraySize(symbols)==0)
   {
      ArrayResize(symbols,1);
      ArrayResize(zero_sid,1);
      ArrayResize(memoryASK,1);
      ArrayResize(memoryBID,1);
      
      symbols[0] = _Symbol;
   }
   
   if (type>0 && shift>0) {collecting_ticks=true;}
   if (collecting_ticks==false) {
      if (type>0 && shift==0) {
         // going to get ticks
      } else {return(0);}
   }
	
	if (symbol=="") {symbol=_Symbol;}
   
	if (type==0)
	{
      //StringExplode(",",symbol,feeded_symbols);
	   //for (s=0; s<ArraySize(feeded_symbols); s++)
	   //{
	      //symbol=feeded_symbols[s];
         //if (symbol=="") {symbol=Symbol();}
	      exists=false;
         size=ArraySize(symbols);
         if (size==0) {ArrayResize(symbols, 1);}
	      for (i=0; i<size; i++) {
	         if (symbols[i]==symbol) {exists=true; sid=i; break;}
	      }
         if (exists==false) {
            int newsize=ArraySize(symbols)+1;
            
            
            ArrayResize(symbols,newsize); symbols[newsize-1]=symbol;
            ArrayResize(zero_sid,newsize);
            ArrayResize(memoryASK,newsize);
            ArrayResize(memoryBID,newsize);
            sid=newsize;
         }
         if (sid>=0) {
            ask=SymbolInfoDouble(symbol,SYMBOL_ASK);
            bid=SymbolInfoDouble(symbol,SYMBOL_BID);
            if (bid==0 && MQLInfoInteger(MQL_TESTER)) {
               Print("Ticks data collector error: "+symbol+" cannot be backtested. Only the current symbol can be backtested. The EA will be terminated.");
               ExpertRemove();
            }
            if (symbol==_Symbol || ask!=memoryASK[sid][0] || bid!=memoryBID[sid][0])
            {
               memoryASK[sid][zero_sid[sid]]=ask;
               memoryBID[sid][zero_sid[sid]]=bid;
               zero_sid[sid]=zero_sid[sid]+1;
               if (zero_sid[sid]==100) {zero_sid[sid]=0;}
	         }
   	   }
      //}
   }
   else {
      if (shift<=0) {
         if (type==SYMBOL_ASK) {
            return(SymbolInfoDouble(symbol,SYMBOL_ASK));
         }
         else if (type==SYMBOL_BID) {
            return(SymbolInfoDouble(symbol,SYMBOL_BID)); 
         }
         else {
            double mid=((SymbolInfoDouble(symbol,SYMBOL_ASK)+SymbolInfoDouble(symbol,SYMBOL_BID))/2);
            return(mid);
         }
      }
      else {
         size=ArraySize(symbols);
         for (i=0; i<size; i++) {
            if (symbols[i]==symbol) {sid=i;}
         }
         if (shift<100) {
            id=zero_sid[sid]-shift-1; if(id<0) {id=id+100;}
            
            if (type==SYMBOL_ASK) {
               retval=(memoryASK[sid][id]);
               if (retval==0) {retval=SymbolInfoDouble(symbol,SYMBOL_ASK);}
            }
            else if (type==SYMBOL_BID) {
               retval=(memoryBID[sid][id]);
               if (retval==0) {retval=SymbolInfoDouble(symbol,SYMBOL_BID);}
            }
            //Print(shift+" "+id+" "+retval);
         }
      }
   }
   return(retval);
}

int TicksPerSecond(bool get_max = false, bool set = false)
{
   static datetime time0 = 0;
   datetime time1 = TimeLocal();
   static int ticks, tps, tpsmax;
   
   if (set == true)
   {
      if (time1 > time0)
      {
         if (time1-time0 > 1)
         {
            tps = 0;
         }
         else
         {
            tps = ticks;
         }
         time0 = time1;
         ticks = 0;
      }
      
      ticks++;
      
      if (tps > tpsmax) {tpsmax = tps;}
   }
   
   if (get_max)
   {
      return tpsmax;
   }
   
   return tps;
}

datetime TimeAtStart(string cmd="server")
{
   static datetime local=0;
   static datetime server=0;
   
   if (cmd=="local") {return(local);}
   else if (cmd=="server") {return(server);}
   else if (cmd=="set") {
      local=TimeLocal();
      server=TimeCurrent();
   }
   return(0);
}

int TimeDay(datetime time)
{
	MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.day);
}

int TimeDayOfWeek(datetime time)
{
   MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.day_of_week);
}

datetime TimeFromComponents(int time_src=0, int y=0, int m=0, int d=0, int h=0, int i=0, int s=0)
{
   MqlDateTime tm;
   if (time_src == 0) {TimeCurrent(tm);}
	else if (time_src == 1) {TimeLocal(tm);}
	else if (time_src == 2) {TimeGMT(tm);}

   if (y>0) {
      if (y<100) {y=2000+y;}
      tm.year = y;
   }
   if (m>0) {tm.mon = m;}
   if (d>0) {tm.day = d;}

   tm.hour  = h;
   tm.min   = i;
   tm.sec   = s;
   
   return StructToTime(tm);
}

int TimeHour(datetime time)
{
	MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.hour);
}

int TimeMinute(datetime time)
{
	MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.min);
}

int TimeMonth(datetime time)
{
	MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.mon);
}

int TimeSeconds(datetime time)
{
	MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.sec);
}

int TimeYear(datetime time)
{
   MqlDateTime tm;
   TimeToStruct(time,tm);
   return(tm.year);
}

void UpdateEventValues(ulong deal_ticket, string e_reason="", string e_detail="")
{
   e_Reason(true, e_reason);
   e_ReasonDetail(true, e_detail);
   e_attrClosePrice (true,HistoryDealGetDouble(deal_ticket,DEAL_PRICE));
   e_attrCloseTime  (true,0);
   e_attrComment    (true,HistoryDealGetString(deal_ticket,DEAL_COMMENT));
   e_attrCommission (true,HistoryDealGetDouble(deal_ticket,DEAL_COMMISSION));
   e_attrExpiration (true,0);
   e_attrLots       (true,HistoryDealGetDouble(deal_ticket,DEAL_VOLUME));
   e_attrMagicNumber(true,HistoryOrderGetInteger(HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID),ORDER_MAGIC));
   e_attrOpenPrice  (true,HistoryDealGetDouble(deal_ticket,DEAL_PRICE));
   e_attrOpenTime   (true,HistoryDealGetInteger(deal_ticket,DEAL_TIME));
   e_attrProfit     (true,HistoryDealGetDouble(deal_ticket,DEAL_PROFIT));
   e_attrStopLoss   (true,HistoryOrderGetDouble(HistoryDealGetInteger(deal_ticket,DEAL_ORDER),ORDER_SL));
   e_attrSymbol     (true,HistoryDealGetString(deal_ticket,DEAL_SYMBOL));
   e_attrSwap       (true,HistoryDealGetDouble(deal_ticket,DEAL_SWAP));
   e_attrTakeProfit (true,HistoryOrderGetDouble(HistoryDealGetInteger(deal_ticket,DEAL_ORDER),ORDER_TP));
   e_attrTicket     (true,deal_ticket);
   int type=(int)HistoryDealGetInteger(deal_ticket,DEAL_TYPE);
   if (e_reason=="close") {
      if (type==0) {type=1;}
      else if (type==1) {type=0;}
   }
   e_attrType(true,type);
}
void UpdateEventValues(position &data, string e_reason="", string e_detail="")
{
   e_Reason         (true,e_reason);
   e_ReasonDetail   (true,e_detail);
   e_attrClosePrice (true,data.price_current);
   e_attrCloseTime  (true,0);
   e_attrComment    (true,data.comment);
   e_attrCommission (true,data.comission);
   e_attrExpiration (true,0);
   e_attrLots       (true,data.volume);
   e_attrMagicNumber(true,data.magic);
   e_attrOpenPrice  (true,data.price_open);
   e_attrOpenTime   (true,data.time);
   e_attrProfit     (true,data.profit);
   e_attrStopLoss   (true,data.sl);
   e_attrSymbol     (true,data.symbol);
   e_attrSwap       (true,data.swap);
   e_attrTakeProfit (true,data.tp);
   e_attrTicket     (true,data.position_id);

   if (e_reason=="close") {
      if (data.type==0) {data.type=1;}
      else if (data.type==1) {data.type=0;}
   }
   
   e_attrType       (true,(int)data.type);
}
void UpdateEventValues(order &data, string e_reason="", string e_detail="")
{
   e_Reason(true, e_reason);
   e_ReasonDetail(true, e_detail);
   e_attrClosePrice (true,data.price_current);
   e_attrCloseTime  (true,data.time_done);
   e_attrComment    (true,data.comment);
   e_attrCommission (true,0);
   e_attrExpiration (true,data.time_expiration);
   e_attrLots       (true,data.volume_current);
   e_attrMagicNumber(true,data.magic);
   e_attrOpenPrice  (true,data.price_open);
   e_attrOpenTime   (true,data.time_setup);
   e_attrProfit     (true,0);
   e_attrStopLoss   (true,data.sl);
   e_attrSymbol     (true,data.symbol);
   e_attrSwap       (true,0);
   e_attrTakeProfit (true,data.tp);
   e_attrTicket     (true,data.ticket);
   e_attrType       (true,(int)data.type);
}

int WindowFindVisible(long chart_id, string term)
{
   //-- the search term can be chart name, such as Force(13), or subwindow index
   if (term == "" || term == "0") {return 0;}
   
   int subwindow = (int)StringToInteger(term);
   
   if (subwindow == 0 && StringLen(term) > 1)
   {
      subwindow = ChartWindowFind(chart_id, term);
   }
   
   if (subwindow > 0 && !ChartGetInteger(chart_id, CHART_WINDOW_IS_VISIBLE, subwindow))
   {
      return -1;  
   }
   
   return subwindow;
}

string e_Reason(bool set=false, string inp="") {
   static string mem[250];
   int queue=OnTradeQueue()-1;
   if(set==true){
      mem[queue]=inp;
   }
   return(mem[queue]);
}

string e_ReasonDetail(bool set=false, string inp="") {static string mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrClosePrice(bool set=false, double inp=-1) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

datetime e_attrCloseTime(bool set=false, datetime inp=-1) {static datetime mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

string e_attrComment(bool set=false, string inp="") {static string mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrCommission(bool set=false, double inp=0) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

datetime e_attrExpiration(bool set=false, datetime inp=0) {static datetime mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrLots(bool set=false, double inp=-1) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

ulong e_attrMagicNumber(bool set=false, ulong inp=-1) {static ulong mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrOpenPrice(bool set=false, double inp=-1) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

datetime e_attrOpenTime(bool set=false,datetime inp=-1) {static datetime mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrProfit(bool set=false, double inp=0) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrStopLoss(bool set=false, double inp=-1) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrSwap(bool set=false, double inp=0) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

string e_attrSymbol(bool set=false, string inp="") {static string mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

double e_attrTakeProfit(bool set=false, double inp=-1) {static double mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

ulong e_attrTicket(bool set=false, ulong inp=-1) {static ulong mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

int e_attrType(bool set=false, int inp=-1) {static int mem[250];int queue=OnTradeQueue()-1;if(set==true){mem[queue]=inp;}return(mem[queue]);}

int iCandleID(string SYMBOL, int TIMEFRAME, datetime time_stamp)
{
   bool TimeStampPrevDayShift = true;
   int CandleID = 0;
   //== calculate candle ID
   //-- get the time resolution of the desired period, in minutes
   int mins_tf = TIMEFRAME;
   int mins_tf0 = 0;
   if (TIMEFRAME == PERIOD_CURRENT)
   {
      mins_tf = (int)PeriodSeconds(PERIOD_CURRENT) / 60;
   }
   
   //-- get the difference between now and the time we want, in minutes
   //int time_stamp = StrToTime(TimeStamp);
   int days_adjust = 0;
   if (TimeStampPrevDayShift)
   {
      //-- automatically shift to the previous day
      if (time_stamp > TimeCurrent())
      {
         time_stamp = time_stamp - 86400;
      }
      //-- also shift weekdays
      while (true)
      {
         int dow = TimeDayOfWeek(time_stamp);
         
         if (dow > 0 && dow < 6) {break;}
         time_stamp = time_stamp - 86400;
         days_adjust++;
      }
   }
   
   int mins_diff = (int)(TimeCurrent() - time_stamp);
   mins_diff = mins_diff - days_adjust*86400;
   mins_diff = mins_diff / 60;
   
   //-- the difference is negative => quit here
   if (mins_diff < 0) {return (int)EMPTY_VALUE;}
   
   //-- now calculate the candle ID, it is relative to the current time
   if (mins_diff > 0) {
      CandleID = (int)MathCeil((double)mins_diff/(double)mins_tf);
   }
   //Print(TimeToStr(TimeCurrent())+" "+TimeToStr(time_stamp) +" ::: " + mins_tf + " " + days_adjust + " " + (days_adjust*1440/mins_tf) + " " + CandleID);
   
   
   //-- now, after all the shifting and in case of missing candles, the calculated candle id can be few candles early
   // so we will search for the right candle
   while(true)
   {
      if (iTime(SYMBOL, TIMEFRAME, CandleID) >= time_stamp) {break;}
      
      CandleID--;
		
		if (CandleID <= 0) {CandleID = 0; break;}
   }
   
   return CandleID;
}

double iClose(string symbol,int timeframe,int shift)
{
   if(shift < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES tf=TFMigrate(timeframe);
   if(CopyClose(symbol,tf, shift, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}

double iOpen(string symbol,int timeframe,int shift)
{   
   if(shift < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES tf=TFMigrate(timeframe);
   if(CopyOpen(symbol,tf, shift, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}

datetime iTime(string symbol,int timeframe,int shift)
{
   if(shift < 0) return(-1);
   ENUM_TIMEFRAMES tf=TFMigrate(timeframe);
   datetime Arr[];
   if(CopyTime(symbol, tf, shift, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}

double toDigits(double pips,string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(
      NormalizeDouble(
         pips*PipValue(symbol)*SymbolInfoDouble(symbol,SYMBOL_POINT),
         (int)SymbolInfoInteger(symbol,SYMBOL_DIGITS)
      )
   );
}

double toDigs(double pips,string symbol="")
{
   return(toDigits(pips,symbol));
}

double toPips(double digits,string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(digits/(PipValue(symbol)*SymbolInfoDouble(symbol,SYMBOL_POINT)));
}




int CustomDigits(string symbol="")
{
    if (symbol == "") {symbol = GetSymbol();}
    double point = CustomPoint(symbol);
    if (point==0) {return(0);}
    int digits=0;

    while(true)
    {
        if (point>=1) {break;}
        point = point*10;
        digits++;
    }

    return(digits);
}

double CustomPoint(string symbol="")
{
    static string symbols[];
    static double points[];
    static string last_symbol = "-";
    static double last_point  = 0;
    static int last_i         = 0;
    static int size           = 0;

    //-- variant A) use the cache for the last used symbol
    if (symbol == "") {symbol = GetSymbol();}
    if (symbol == last_symbol)
    {
        return(last_point);
    }

    //-- variant B) search in the array cache
    int i			= last_i;
    int start_i	= i;
    bool found	= false;

    if (size>0)
    {
        while(true)
        {
            if (symbols[i] == symbol)
            {
                last_symbol	= symbol;
                last_point	= points[i];
                last_i		= i;

                return(last_point);
            }

            i++;
            if (i >= size)
            {
                i=0;
            }
            if (i == start_i) {break;}
        }
    }

    //-- variant C) add this symbol to the cache
    i		= size;
    size	= size+1;

    ArrayResize(symbols, size);
    ArrayResize(points, size);

    symbols[i]	= symbol;
    points[i]	= 0;
    last_symbol	= symbol;
    last_i		= i;

    //-- unserialize rules from FXD_POINT_FORMAT_RULES
    string rules[];
    StringExplode(",", POINT_FORMAT_RULES, rules);

    int rules_count = ArraySize(rules);

    if (rules_count > 0)
    {
        string rule[];
        for (int r=0; r < rules_count; r++)
        {
            StringExplode("=", rules[r], rule);

            //-- a single rule must contain 2 parts, [0] from and [1] to
            if (ArraySize(rule) != 2) {continue;}
            double from = StringToDouble(rule[0]);
            double to	= StringToDouble(rule[1]);

            //-- "to" must be a positive number, different than 0
            if (to <= 0) {continue;}

            //-- "from" can be a number or a string
            // a) string
            if (from == 0 && StringLen(rule[0]) > 0)
            {
                string s_from = rule[0];
                int pos = StringFind(s_from, "?");

                if (pos < 0) // ? not found
                {
                    if (StringFind(symbol, s_from) == 0) {points[i] = to;}
                }
                else if (pos == 0) // ? is the first symbol => match the second symbol
                {
                    if (StringFind(symbol, StringSubstr(s_from, 1), 3) == 3) {points[i] = to;}
                }
                else if (pos > 0) // ? is the second symbol => match the first symbol
                {
                    if (StringFind(symbol, StringSubstr(s_from, 0, pos)) == 0) {points[i] = to;}
                }
            }

            // b) number
            if (from == 0) {continue;}

            if (SymbolInfoDouble(symbol, SYMBOL_POINT) == from)
            {
                points[i] = to;
            }
        }
    }

    if (points[i] == 0) {points[i] = SymbolInfoDouble(symbol, SYMBOL_POINT);}
    last_point=points[i];

    return(last_point);
}


// Blocks Lookup Functions
string fxdBlocksLookupTable[57] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","22","23","24","25","26","27","28","32","33","34","35","36","37","38","39","40","41","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","82","83","84","90"};

int fxdBlocksLookupTableTranslateID(string id)
{
    return ArraySearch(fxdBlocksLookupTable, id);
}
string fxdBlocksLookupTableTranslateID(int id)
{
    return fxdBlocksLookupTable[id];
}

int fxdBlockToggle(int id)
{
    disabled[id] = !disabled[id];
    return disabled[id];
}

void fxdBlockTurnOn(int id)
{
    disabled[id] = false;
}
void fxdBlockTurnOff(int id)
{
    disabled[id] = true;
}

bool fxdBlockRun(int id=0)
{

    switch(id)
    {

        case 0: block0(); break;


        case 1: block1(); break;


        case 2: block2(); break;


        case 3: block3(); break;


        case 4: block4(); break;


        case 5: block5(); break;


        case 6: block6(); break;


        case 7: block7(); break;


        case 8: block8(); break;


        case 9: block9(); break;


        case 10: block10(); break;


        case 11: block11(); break;


        case 12: block12(); break;


        case 13: block13(); break;


        case 14: block14(); break;


        case 15: block15(); break;


        case 16: block16(); break;


        case 17: block17(); break;


        case 18: block18(); break;


        case 19: block19(); break;


        case 20: block20(); break;


        case 21: block21(); break;


        case 22: block22(); break;


        case 23: block23(); break;


        case 24: block24(); break;


        case 25: block25(); break;


        case 26: block26(); break;


        case 27: block27(); break;


        case 28: block28(); break;


        case 29: block29(); break;


        case 30: block30(); break;


        case 31: block31(); break;


        case 32: block32(); break;


        case 33: block33(); break;


        case 34: block34(); break;


        case 35: block35(); break;


        case 36: block36(); break;


        case 37: block37(); break;


        case 38: block38(); break;


        case 39: block39(); break;


        case 40: block40(); break;


        case 41: block41(); break;


        case 42: block42(); break;


        case 43: block43(); break;


        case 44: block44(); break;


        case 45: block45(); break;


        case 46: block46(); break;


        case 47: block47(); break;


        case 48: block48(); break;


        case 49: block49(); break;


        case 50: block50(); break;


        case 51: block51(); break;


        case 52: block52(); break;


        case 53: block53(); break;


        case 54: block54(); break;


        case 55: block55(); break;


        case 56: block56(); break;


        default: return false;
    }


    return true;
}


void fxdBlockGetNextBlocks(int id, int &list[])
{
    switch(id)
    {
		case 0: ArrayResize(list, 1); list[0]=5; break;
		case 1: ArrayResize(list, 1); list[0]=0; break;
		case 2: ArrayResize(list, 1); list[0]=1; break;
		case 3: ArrayResize(list, 1); list[0]=2; break;
		case 4: ArrayResize(list, 1); list[0]=2; break;
		case 6: ArrayResize(list, 1); list[0]=11; break;
		case 7: ArrayResize(list, 1); list[0]=6; break;
		case 8: ArrayResize(list, 1); list[0]=7; break;
		case 9: ArrayResize(list, 1); list[0]=8; break;
		case 10: ArrayResize(list, 1); list[0]=8; break;
		case 13: ArrayResize(list, 1); list[0]=12; break;
		case 14: ArrayResize(list, 1); list[0]=13; break;
		case 15: ArrayResize(list, 1); list[0]=14; break;
		case 16: ArrayResize(list, 1); list[0]=14; break;
		case 17: ArrayResize(list, 1); list[0]=32; break;
		case 18: ArrayResize(list, 1); list[0]=48; break;
		case 19: ArrayResize(list, 1); list[0]=18; break;
		case 20: ArrayResize(list, 1); list[0]=19; break;
		case 21: ArrayResize(list, 1); list[0]=20; break;
		case 23: ArrayResize(list, 1); list[0]=21; break;
		case 24: ArrayResize(list, 1); list[0]=21; break;
		case 25: ArrayResize(list, 1); list[0]=52; break;
		case 26: ArrayResize(list, 1); list[0]=25; break;
		case 27: ArrayResize(list, 1); list[0]=26; break;
		case 28: ArrayResize(list, 1); list[0]=27; break;
		case 30: ArrayResize(list, 1); list[0]=28; break;
		case 31: ArrayResize(list, 1); list[0]=28; break;
		case 33: ArrayResize(list, 1); list[0]=17; break;
		case 34: ArrayResize(list, 1); list[0]=17; break;
		case 36: ArrayResize(list, 1); list[0]=38; break;
		case 37: ArrayResize(list, 1); list[0]=38; break;
		case 38: ArrayResize(list, 1); list[0]=35; break;
		case 40: ArrayResize(list, 1); list[0]=39; break;
		case 41: ArrayResize(list, 1); list[0]=40; break;
		case 42: ArrayResize(list, 1); list[0]=41; break;
		case 43: ArrayResize(list, 1); list[0]=42; break;
		case 44: ArrayResize(list, 1); list[0]=42; break;
		case 45: ArrayResize(list, 1); list[0]=53; break;
		case 46: ArrayResize(list, 1); list[0]=45; break;
		case 47: ArrayResize(list, 1); list[0]=46; break;
		case 48: ArrayResize(list, 1); list[0]=47; break;
		case 49: ArrayResize(list, 1); list[0]=54; break;
		case 50: ArrayResize(list, 1); list[0]=49; break;
		case 51: ArrayResize(list, 1); list[0]=50; break;
		case 52: ArrayResize(list, 1); list[0]=51; break;
		case 53: ArrayResize(list, 1); list[0]=55; break;
		case 54: ArrayResize(list, 1); list[0]=56; break;
		case 55: ArrayResize(list, 1); list[0]=22; break;
		case 56: ArrayResize(list, 1); list[0]=29; break;

        default: ArrayResize(list, 0);
    }
}

void fxdBlockGetNextBlocks(string id, int &list[])
{
    fxdBlockGetNextBlocks(fxdBlocksLookupTableTranslateID(id), list);
}


class FxdWaiting
{
    private:
        int beginning_id;
        ushort bank  [][2][20]; // 2 banks, 20 possible parallel waiting blocks per chain of blocks
        ushort state [][2];     // second dimention values: 0 - count of the blocks put on hold, 1 - current bank id

    public:
        void Initialize(int count)
        {
            ArrayResize(bank, count);
            ArrayResize(state, count);
        }

        bool Run(int id = 0)
        {
            beginning_id = id;

            int range = ArrayRange(state, 0);
			if (range < id+1) {
				ArrayResize(bank, id+1);
				ArrayResize(state, id+1);

				// set values to 0, otherwise they have random values
				for (int ii=range; ii<id+1; ii++)
				{
				   state[ii][0] = 0;
				   state[ii][1] = 0;
				}
			}

            // are there blocks put on hold?
            int count = state[id][0];
            int bank_id = state[id][1];
            // if no block are put on hold -> escape
            if (count == 0) {return false;}
            else
            {
                state[id][0] = 0; // null the count
                state[id][1] = (bank_id) ? 0 : 1; // switch to the other bank
            }

            //== now we will run the blocks put on hold



            for (int i = 0; i < count; i++)
            {
                int block_to_run = bank[id][bank_id][i];
                //Print(count + " " + block_to_run);
                fxdBlockRun(block_to_run);
            }

            //state[id][0] = 0;


            return true;
        }

        void Accumulate(int block_id = 0)
        {
            int count   = ++state[beginning_id][0];
            int bank_id = state[beginning_id][1];

            bank[beginning_id][bank_id][count-1] = (ushort)block_id;
        }
};
FxdWaiting fxdWait;



//+------------------------------------------------------------------+
//| END                                                              |
//| Created with fxDreema EA Builder           https://fxdreema.com/ |
//+------------------------------------------------------------------+

/*<fxdreema:eNrtXW1v2zgS/p5fIeRwRXvbbEVSr05bIElTpIek7iXZLXYPB0O2FUdbWTIkOWmul/9+fJMsyXITybITSeyHXUckR+RwZjgcPhxZPaP3I+wB0Nsd+Z5njyLH98LdfaunmL0fTk/GvxCpofZ2rxzbHe/uhz29t/vh+OPBb6eX5C+ttxv682Bkkz8wHcAfRlYwsSP+EO7u3zs9UJ4aLKKGKDVYnhoqoqZQaqgmaiqlppSnphVRA5SaWp6aXkTNoNS08tSMImompaaXp2YuUYN4pDIlZ9RFjnHOLEmOtCwUOZ0JsFyBHirsH5M6ACoQVAoJMsEDsAJBtZCgxgii2ghyHirlCUJYRBAyOwDUCgQLJwXySdEqECycFMgnRa9AsJCHkPPQqI0gswmggqKgwklB3DhX0BRUOCmITQqsoCmocFIQmxRYQVNQIQ8RmxSIaiPIJgVW0BRUbA05wQqaAowiggqz1lCrjSCz17CCpmiFYqMx8wUraIqmFRLkclhBUzS9kCCbFFRBU7RCHmpsRUYVNEUrFBudzTKqoCmkaQFBNssI1UaQOZZIqW2WmXFAFTRFL5RDnbuXFTRFLzRfOu9hBU3RC62NzjQFVdAUvZCHkE9KBU3RCzVFZ5qiVNAUvVBTdKYpSgVN0Qs1xWCaolTQFKNQsBHjoVJBU4zCdVln67JSQVOMYsFmq55SxfsqFBuDaYpSQVNQIUGTT0oFTTELJ8XgPKygKUahLpOpur+nz4euP/pGd96qTnbeRDQhIC8x6N48CnyXFtMX4wYXf5wd9k8JIbm3S/5n9nYvP50dfzw/ODvmf385Pv/U/zA4oS8H+IVfrDA8s75fOlM7TG0xaWXyEsvx7IAUKJiYM/pGfuL3j53QGro2HuewJ7Ox2t8jO2ChArn3454OxxmnYwCYpBMORvMw8qdxQyMeKGMB4dJdGNlT/p6pP7bdASeDh9X3RvYXOzi0aJ8Afu3MCqypjV+NKft+MA5TDMDUZo7nLbqJpyccWa7NCz0/mFpuTDu0Ca3ID1JjIP2JrGhOH0E+w77nX13t7juUJObL2Iqs5K33tErkROwtQGWdlmZ2IA2tQDqJ5x3ToIPmdDEd176KCFmEvagQT+tu5M/I3wB7BPe0xq3lRCmW+/NoNo/CNA0HPyM1AOuazf+kBDDFUbgQGUCEzBp9mwT+3BvvjXzXD7jc/m0o25BpuUrkgJfgifwb/T/+cYWFY+/WdibXUXrsQFkI5wCLRGAtmInn/8YKHCI4KRYTKRziibODvTC6Y1xj1FhEZ7XM44anfjL4hbiRLlveGL9lwP/PpSlNQeeT6fRPTo/4QJ3+zPYoCcyaMyx6R7T5R8cbH95xDWXvwMRY2acP6bgU0TisSReRNZ1xmrLck2PbUV5Dcb2j/vn58dHlp/7nBWfu6SyN/CmW2Djq8Z538Lw+luAuO0euH9qN4MnD0lejQYM1GDTc/Mj3xg4JsTbEnEHcRaIk/4b/eTGJ9qlw4N9vh8H7Q5sZ5QdMm5w1bfrWTdvHjx+ODswKpu2x5utzHD3epuU6wb1tquV6+/wsF2iv5ULdtFwIlxMlIZbLjS0XYJZr7rrSsTeZu1elDRjEvlorDZiyyoBBOhwyTweuHUSXiaeLh5TipONN4u7QeqfW0HapWiFS7zhT+Lvlzm1Qq0EkmtsI5c/zCKaIZhkECxgEyJzisgH9bwFzYl35PS7HLeRSHUIrO4SepkPKyg4pT9MhdWWH1KfpkLayQ9rTdEhf2SH9aTpkrOyQ8TQdMld2yNxah2DGVsvpHsGMpZa31SVIl5nQv7C98Wc/cq6ckRU7HSTWZrnExavdR1Jq8JFgvEKe2WFoTeyD8Y3ljezxpv0lPBE0WhgvZSSKEvOa7EsWv5XUbzX1W0v91lO/jdRvM/UbyOk/QDqKuH78DHEuSlPGxgc9NGhmo2fQKL/FlH/qocGHPLQr/E/Vij20mmJkn2MYUKGPBqhLRFr1h3/Z
o2gRMsWvjgKufknxbzM8BXauWKeln61pXICdtkESh6XtLu9mNteU/uE/Bwfn5/2vKcoHQeDfHmGV4F4fYDAQgxYS56rI45NjMxJxBy5vReLxEqcucfL4toa0pl5bGg4kP+TOke6SwiI3MKZ4ZgXf7ChtEc10I/LrKuC8WnL9dF4V73p9z/aiP3ioJCZl5MrP8Hiv0xW0XIUP1l26OE//BA8/A15KOpu8wfHmUdYI56tc2Jjt40wVtOD6xbVzFWUKFc5hUkAGmLZnxI9PCunoMqXppl9t+1umEKUK8bhXNiSDDguYxt5Jx7uymI21sPibMyNdGvM3pxYdpq1YlL8EzqjG3QuxQ6f+bUM2L4wFB97omls5sux9Pjrpnw8u+18W+n6UmEFi/dzgg23PLr7dHS58BVzpIj4AIN7ExeUfp8eDi/4pGxur8dUZM9WIVZ6ZqUOLrfWL6WGSQ2jaLjZVxKAuVQCpCmxhThezkZ0447HtFZf9SU1yRgtYd46urSC6mA+/4hljM5nag9fop6h1HKvhLtD+fgisW2qyN+2hKCscFJByUEDKQanLlcAPyRilZJClIj2oQqRHXi/Sc3WlX6nyk5/CaavcjE2EJ7UaRBpz63g6i+6acqiisnP4OBbphNfZIFqp0+Ltu7sj+m/z7q7eZASELhAQj0dAKHrumFDpKgLCEAiIJp8jthgBYQgEhJtDQOC1+2HTpuXAXUZLERDmFi3XeltmAd3qFADC7CgAAhGVu80gt0CC3Hos/iFvviBqKf6B3uwsD4BYsPLnAAhbACAEAEIAIAQAQgAgBADimQEgePIFgYBoKAJCQTkfzWwtAgKA7UIgbAGBEBAIAYHYNARizRstT46BQAkG4rB/edk/K4JBgAQG8cXxvgkMRGVXBQgQxMZAEPlwD0JdBUEAuDUURLJmdRgGgVfPcjCI/JGxobUVBgHQViURdU8SY1gIkcQP/l/Og8KXg5yb7ZU9pbEYnCRRogDhPA6EY+QOqtWuYnCAumUQzqE/vmvI1qccCKd8iJTETH5Vn8nhcZLJtIOnxzDVZ+qhYRn9N6AYGDxB0syZhWUtCpRbCn0BWtmzYzyk2NEoODAuKhUnxuLEWJwYixNjcWIsToyfxYmxJk6MG3tinAf1ae09MNa3d2CsMrdt3RNjQ5wYixNjcWLchhNjTOUXxLbKVc+NTXps3A8sb1L54jwUh8a6ODTe2KGxmbs4D+SunhmvvL2px2GgC2fiWW7sEyhkXkaxK3Hu3144/818+Ix0HZtlEnyLi/D72VBZizPuOmQkqYr1wpy7OPn08XKT5zF13CEk+sa4SO7fhZ+8gy0oYl1H3gbLmRlKjidZEu44Ca1C6bukyo+KqOpK7qK0ttXrOAoJqR49vaLBBiWKRy28Jt2om+NbPS+CXU0UD/k1aUSPiPiNaWLdHrZp2WCErrb0hiFEIrdDg40WaLHRQh03WnBhtEAlo2XIoKVGS9mi0Vo3iQESGWk65WspHTVbJA5F8zmgpZw0pQ2X0lZvS22Q4RKptLrlb6ldN1zLH+UpbbiMthoubZvXPWAX868ai+sel9eBbUtfr53Ili58d+zYQWlcqwJbe/8D6mWRrQTSs4qpxbmRLr9eCKSrQLoKpKtAugqkq0C6PjukK9QF0rWxSFc1e15uIq2tSFdobDU1EvbaRGokAXQVQFcBdF03NZJOIa6nCw0XWZHKOymGALhuDOCai/eYOugowBUJ3N2TZvkXuLtV9g8J3F1Z3B259dcJ4B0SwLsmW60WHwQjAbwrC7zLW63WIu+QQN41+5NKbfa2BPKuPPJuyXK1FXqHBPROfAzuuVouAb0rD71bslxtxd6hrWLvUMe/fc5gYocunnLpKPBvHwbewVzS7xYj71Bp5B09+Cti6QrY3eGRgN0J2J2A3QnYnYDdCdjds4PdIQG7ay7sDuY+Sdhi3B3aMu7u8Ejg7gTuTuDuNoy7I4bolAOgGgi7kxPY3WX/S9HnCGEq
r+S5PRbIu8p+ikDebQ55lw/4dBh6Z241NGl2LzSJzEVoEkpJmkYspq8l2xpdSy8m0f5j8zTKuY9pAbmtgUpFLh2oxK9OMficG7vlKCWmF936tKIIVYpQpQhVilClCFWKUOWzC1UqsghVNjZUqaPsFgMqrf0YjgK2F6o0F76biFeKeKWIV4p7wuveE9ZoyFIEK9fxVIAIVm4sWEku0GU8CUPraLBSQ9sMVmqo88FKsnJWDlaaQO5KsFJTKgYrYwY/GKyMfRgRrBTBShGsFMFKEawUwcpnFazUFBGsbGyw0szhKlscrNTU7QUr876biFWKWKWIVQpsZTVsJctneLjwFESgsryXoopA5eY+2K2JQCUPVGrii90/VcM6rqinvthNVs3mfbE7Dv5V+WK3qeSQoHonv9it6Vs9EdC7dyJgwsWJgMW349LU8uaW695JV3i9drwJKWQMkWY23kB4ESvGXR3NXbxNGkukyrU1ndrBa+na8ia41WvJjkYPSrpi5JIzqK1NzqCtvvMnk4cmiQQxYoD37abXi3MgajxOBLqZYTHDHsh7hNmTZCyK+QM7mhApwyC0kJ8Y3hHzB3UYPBKzR+HkMXtOE8935XlJR7arMXPU7ApV76kNeCipV81Lei3X7FQ6fc7V3e8LW7/Z1V0tvyNMB6xrwQrAeNRSMmyyyge2NZb6r49en7w+ffhDOiDrx6pw63tGFf/TliLPpGRI/23XoV15Hy8J3/7rVB3xvZ6B2MtZzjjipr2jEZf9nZ2xP8dvlZg9IlvG/fjRkO8hkwfcZTvMP586Y2Z03r0kVvwXbKxevYH7O44Xcbpk+/pO3pfevBnOXVdyQgm8loZ4XyPtgZ2dxbvfkfZ7uD1ufPWSuBRv6br5SvqRdOcdfbJHCvfT5MG+dL9j40FJvOn75abk8R59nGm6t2ibqizv53p/v7Pz5s0ssG8wE6SrADuxHhnN2LlxiHNLupwayjuZvDr1QP5Vxv8Ap3Pt30rT+eha+jthR/xSRnbRaCfH83cv45pvFpVe/QPI8j4hSrnr40ESmtbQv4knlszRa8kPGNPjGkPbJYAdXIN2QApJD/BzLIWhFGHvGzvw30+oM0468IX1hdaf+oHNqzjechXCC+nly5cLBr6XX714weYlkZdXr/73v3Sdt0mdt6k6r6QXL6SXOUa8LepZYc33RR3ERH9k9YGczOwnQlCkK9L9JiIcddx0pcsgbRwfBjVgw6glnZaIqZKIrWLLwsifeEQS2TaQSzApunWia8m/9aTRIob1kw2hmVsy9K0vGT/bEG5xsdDlny4W+XyiuObuy6wGUPV4tQH51+u6u5SMwHKxm4vrYS1vCpgSprpPQyTLvH+Eg5QNf2gVjubXTpJ6qGhLsb4U8CYn7Cnu1i/yoCzSEveGLRMrAJbF5QJeKeCVAl4p4JUCXinglc8BXqkDAa9sLLwyv2PR5dbCK3W4PXilHntu694ENwS6UqArBbqyDYd5mMoviCFoqiWwlCnK8gybdY8tAQJoWclfga0FWspPDrRUYf4Tq3JHgZb6tr/BuoYFfPKPGb7dzDdY12BJi79lqHf4G6xEIvinDOnPR37J0JTXPtdpxOfAdKU5RgsKo9WhzxjqSseNFlwYLVDJaGmwpd+N1rf59dX1oJFtdLTW40ib/ayufnlVJhp3y90s8qual6VpbfWytMYYLCgMVod8LK3bBgsmBquah0W+gdFOg6WLWNZTft5exLJWmixdxLIm5WJZUNc6EswyRDCrwVarzY6WIYJZk3LBrLzVam80yxTRrCc0WiKatcpmmZ2PZk1KRbOWLFZbw1mGLMJZjbVYLfayDLnz4axJqXBW3mK1Np5lwJJJ8Cj2EldzvLk/Dwtz4aHVufBAQ3PhGbDeXHjk02iNyoVHbFXy1V6aC+9BHSJ5EdbNGtKC7HcGEhr2GA1DHc82STUsk23y4VXKEBpGNOznUL1KbhtPqHhmfSfuYLhJwVdqSkLS90b24r5W
EyReZZ0muY2koRVIJ8oj0hdn80waW0+0MJRtyIzVkwq9KTdZ6E1ZCP3jhT6/G+mq1N9TEcBMwr7RhN1XNeKOW6PIubEHq2SUEJ0FPrl5OvD4XUvS649kxsmONgT5ahH3xzQiy3i2ovhWGEmANHAtbzLn94oVlvAtpknuxA5Ggc2vxkLyFTkZ6Hsy2APwEncWmPjhr6Zu/plpMqV5+h7bZGpNnNEAC2NAZcSAisLTB904oYNZOnCdYWAFdwMyn7MlZSKXNuOaVONW1SNy55ALvGF809HpaTLvxcx3vGgQzPkMInI1S06JH0mpFsdRfpVlwPU/8jnf8ENA7RkoaKSzRvlmGn/MGsKChkbc8Cct75m5mIf24MYJSC5kzEyfZfWGxBTsJuxMldKrxVSHmLYTLhISNmbQxPZGdwVESJ1c+SCw3fwN2nwVa5y9QYt/0Ox3IRGU5NJ1LN9mUjq6G+EpxQLr+GO6D1uYbywtXso8kPBIUYI2fskubbJX1mTmHxu8lLqw1ISJbNvhKHBmcdiIm2KV39XmQ9SpsaCvKcgtt6JDhTXr6BB+DZKTy6kZG6VyUWMpl/PdSgpqYoscrx88g3H+fYuSWl+osMPJwvHF59g1vg7RKN3y2+Lntb6MWfBUjq/l9xZUWeqCQhYp3318B7K3v/FfFl4h0sveIxaxR5ns+/8DL3s/WQ==
:fxdreema>*/