//+------------------------------------------------------------------------------+//
//)   ____  _  _  ____  ____  ____  ____  __  __    __      ___  _____  __  __   (//
//)  ( ___)( \/ )(  _ \(  _ \( ___)( ___)(  \/  )  /__\    / __)(  _  )(  \/  )  (//
//)   )__)  )  (  )(_) ))   / )__)  )__)  )    (  /(__)\  ( (__  )(_)(  )    (   (//
//)  (__)  (_/\_)(____/(_)\_)(____)(____)(_/\/\_)(__)(__)()\___)(_____)(_/\/\_)  (//
//)   http://fxdreema.com                              Copyright 2018, fxDreema  (//
//+------------------------------------------------------------------------------+//
#property copyright ""
#property link      "https://fxdreema.com"

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                       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-4466"
//--
#define ENABLE_EVENT_TIMER 0 // "Timer" event: 1 - enable, 0 - disable
#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

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// Project global variables, includes, imports //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//

// fxDreema Constants
input double startBlc = 0; // startBlc
input int startAn = 5; // startAn
input int atrPeriod = 72; // atrPeriod
input int fast = 144; // fast
input int slow = 610; // slow
input int sig = 9; // sig
input int goodRise = 13; // goodRise
input double atrMulti0 = 2.5; // atrMulti0
input double tpFactor = 0.2; // tpFactor
input double atrDPower = 1.2; // atrDPower
input double breakLineF = 1.3; // breakLineF
input double lots1 = 0.01; // lots1
input int MomenH1 = 5; // MomenH1
input double MomenH1Factor = 1.3; // MomenH1Factor
input double updateFactor = 1.3; // updateFactor
input int breakHorizon = 21; // breakHorizon
input int critTrades = 3; // critTrades
input int atrD = 5; // atrD
input int TrailPbars = 13; // TrailPbars
input int TrailBlc = 3; // TrailBlc
input int TrailPerc = 30; // TrailPerc
input int outsideMax = 15; // outsideMax
input int regMa = 1; // regMa
input int minP = 5; // minP
input int minSetupA = 1; // minSetupA
input int kk = 5; // kk
input int dd = 3; // dd
input int ss = 3; // ss
input double step = 0.02; // step
input double stop = 0.2; // stop
input int stLevel = 60; // stLevel
input double MIN_ACCURACY = 2.1; // MIN_ACCURACY
input double DECF = 0.6; // DECF
input int REinterval = 13; // REinterval
input int failsRow = 2; // failsRow

// fxDreema Variables
double currentH = 0; // currentH
int currentHAGE = 0; // currentHAGE
double currentL = 0; // currentL
int currentLAGE = 0; // currentLAGE
int confirmedHAGE = 0; // confirmedHAGE
int confirmedLAGE = 0; // confirmedLAGE
int anchorH = 0; // anchorH
int anchorL = 0; // anchorL
int risingBars = 0; // risingBars
int fallingBars = 0; // fallingBars
int outsideBOTH = 0; // outsideBOTH
int actualFall = 0; // actualFall
int actualRise = 0; // actualRise
int trUp = 0; // trUp
int trDn = 0; // trDn
int blc = 0; // blc
int lastTrade = 0; // lastTrade
int onlyDir = 0; // onlyDir
int breakAge = 0; // breakAge
int breakType = 0; // breakType
double dnL = 0; // dnL
double upL = 0; // upL
int breakTrade = 0; // breakTrade
double aFa = 0; // aFa
int profitBars = 0; // profitBars
int startP = 0; // startP
double FendP = 0; // FendP
int FendiD = 0; // FendiD
double RendP = 0; // RendP
int RendiD = 0; // RendiD
int loopId = 0; // loopId
double sumPrice = 0; // sumPrice
double meanPrice = 0; // meanPrice
double xSum = 0; // xSum
double sqSum = 0; // sqSum
double slope = 0; // slope
int reGper = 0; // reGper
int dayDrawn = 0; // dayDrawn
int drawInterval = 0; // drawInterval
int setupAge = 0; // setupAge
int buyBank = 0; // buyBank
int sellBank = 0; // sellBank
int closeType = 0; // closeType
double errorSum = 0; // errorSum
double errorFall = 0; // errorFall
double errorRise = 0; // errorRise
int onlyThis = 0; // onlyThis
int FailedDraws = 0; // FailedDraws
// Global variables used as Formula Results or coming out of some blocks
double atr2;
double a11;
double Result354;
double mRel;
double sp;
double Yerr;
double xs;
double asd23;
double dev1;
double stdDEV;
double RelDev;
input int MagicStart=4466; // Magic Start (MagicNumber=MagicStart+Group#)

//VVVVVVVVVVVVVVVVVVVVVVVVV//
// System global variables //
//^^^^^^^^^^^^^^^^^^^^^^^^^//
int FXD_CURRENT_FUNCTION_ID=0;
double FXD_MILS_INIT_END=0;
bool FXD_FIRST_TICK_PASSED=false;
bool FXD_BREAK=false;
bool FXD_CONTINUE=false;

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// Global variables used as On-Off property for fxDreema blocks //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
bool block106=true; // (106) Pass
bool block107=true; // (107) Modify Variables
bool block1=true; // (1) Once per bar
bool block2=true; // (2) RISINGMACD
bool block3=true; // (3) Modify Variables
bool block4=true; // (4) Condition
bool block5=true; // (5) Condition
bool block6=true; // (6) NewHigh
bool block7=true; // (7) Modify Variables
bool block8=true; // (8) Condition
bool block9=true; // (9) Condition
bool block10=true; // (10) NewLow
bool block11=true; // (11) PASS THESE FIRST
bool block12=true; // (12) CROSSED
bool block13=true; // (13) PASS THESE FIRST
bool block14=true; // (14) Condition
bool block15=true; // (15) Modify Variables
bool block16=true; // (16) RESET
bool block17=true; // (17) PASS THESE FIRST
bool block18=true; // (18) CROSSED
bool block19=true; // (19) PASS THESE FIRST
bool block20=true; // (20) Condition
bool block21=true; // (21) Modify Variables
bool block22=true; // (22) RESET
bool block23=true; // (23) PASS THESE FIRST
bool block24=true; // (24) Draw Line
bool block25=true; // (25) Draw Line
bool block26=true; // (26) AGEAGEAGE
bool block27=true; // (27) PASS THESE FIRST
bool block28=true; // (28) Modify Variables
bool block29=true; // (29) Once per DAY
bool block33=true; // (33) Formula&nbsp;
bool block34=true; // (34) Draw Line&nbsp;
bool block35=true; // (35) PASS THESE FIRST
bool block37=true; // (37) Draw Line&nbsp;
bool block41=true; // (41) Custom MQL5 code
bool block43=true; // (43) PASS THESE FIRST
bool block51=true; // (51) PASS THESE FIRST
bool block52=true; // (52) Draw Line&nbsp;
bool block53=true; // (53) Draw Line&nbsp;
bool block54=true; // (54) Condition&nbsp;
bool block55=true; // (55) Condition&nbsp;
bool block56=true; // (56) PASS THESE FIRST
bool block57=true; // (57) TRADE
bool block59=true; // (59) PASS THESE FIRST
bool block69=true; // (69) GA &nbsp; &nbsp;TE
bool block70=true; // (70) Buy now
bool block75=true; // (75) Sell now
bool block76=true; // (76) Draw Line&nbsp;
bool block77=true; // (77) Draw Line&nbsp;
bool block86=true; // (86) Draw Line&nbsp;
bool block87=true; // (87) Draw Line&nbsp;
bool block88=true; // (88) BuyRun
bool block89=true; // (89) INC &nbsp;BLC
bool block90=true; // (90) DEC &nbsp;BLC
bool block91=true; // (91) Condition
bool block92=true; // (92) SellRun
bool block93=true; // (93) PASS THESE FIRST
bool block94=true; // (94) REAL RISE
bool block95=true; // (95) REAL FALL
bool block96=true; // (96) RISINGMACD
bool block97=true; // (97) RISINGMACD
bool block98=true; // (98) RISINGMACD
bool block99=true; // (99) Pass
bool block102=true; // (102) AND
bool block103=true; // (103) AND
bool block104=true; // (104) AND&nbsp;
bool block108=true; // (108) MAIN TRADE
bool block109=true; // (109) CHECK LINE
bool block110=true; // (110) CHECK LINE
bool block111=true; // (111) PASS THESE FIRST
bool block112=true; // (112) AGE CHECK
bool block113=true; // (113) AGE CHECK
bool block114=true; // (114) CHECK DNLEVEL
bool block115=true; // (115) Modify Variables
bool block116=true; // (116) CHECK UPLEVEL
bool block117=true; // (117) Modify Variables
bool block118=true; // (118) RESET LVLS
bool block119=true; // (119) BuyRun
bool block120=true; // (120) INC &nbsp;BLC
bool block121=true; // (121) DEC &nbsp;BLC
bool block122=true; // (122) Condition
bool block123=true; // (123) SellRun
bool block124=true; // (124) Buy now
bool block125=true; // (125) Sell now
bool block126=true; // (126) CHECK LINE
bool block127=true; // (127) Condition
bool block128=true; // (128) Condition
bool block129=true; // (129) CHECK LINE
bool block130=true; // (130) Draw Line
bool block131=true; // (131) Draw Line
bool block132=true; // (132) Delete objects&nbsp;
bool block133=true; // (133) Loop (pass "n" times)
bool block134=true; // (134) Loop (pass "n" times)
bool block135=true; // (135) BuyRun
bool block136=true; // (136) SellRun
bool block147=true; // (147) Formula
bool block148=true; // (148) Formula
bool block150=true; // (150) Pass
bool block151=true; // (151) If position is running
bool block154=true; // (154) Pass
bool block155=true; // (155) check profit
bool block156=true; // (156) Modify Variables
bool block157=true; // (157) Condition
bool block158=true; // (158) Condition
bool block159=true; // (159) Trailing stop&nbsp;
bool block160=true; // (160) Formula
bool block161=true; // (161) Condition
bool block173=true; // (173) REAL RISE
bool block174=true; // (174) REAL FALL
bool block175=true; // (175) PASS THESE FIRST
bool block186=true; // (186) BuyRun
bool block189=true; // (189) Condition
bool block190=true; // (190) Condition
bool block191=true; // (191) Condition
bool block192=true; // (192) Condition
bool block193=true; // (193) Modify Variables
bool block194=true; // (194) WITHIN
bool block195=true; // (195) Pass
bool block196=true; // (196) Condition
bool block197=true; // (197) No position is running
bool block199=true; // (199) NOT DRAWN
bool block201=true; // (201) Pass
bool block207=true; // (207) REAL RISE
bool block208=true; // (208) REAL FALL
bool block210=true; // (210) WITHIN
bool block211=true; // (211) Once per bar
bool block230=true; // (230) Loop (pass "n" times)
bool block231=true; // (231) Formula
bool block232=true; // (232) Loop (pass "n" times)
bool block233=true; // (233) Formula
bool block234=true; // (234) SUMsterr
bool block237=true; // (237) Formula
bool block238=true; // (238) SET REG TYPE FALL
bool block239=true; // (239) Draw Line
bool block240=true; // (240) Condition
bool block241=true; // (241) PASS THESE FIRST
bool block242=true; // (242) PASS THESE FIRST
bool block243=true; // (243) SET REG TYPE RISE
bool block244=true; // (244) Draw Line
bool block245=true; // (245) Custom MQL5 code
bool block246=true; // (246) Pass
bool block247=true; // (247) NOT DRAWN
bool block248=true; // (248) Condition
bool block249=true; // (249) Comment
bool block250=true; // (250) Condition&nbsp;
bool block251=true; // (251) Condition
bool block252=true; // (252) check profit
bool block253=true; // (253) Condition
bool block254=true; // (254) Condition
bool block255=true; // (255) Condition
bool block256=true; // (256) Condition&nbsp;
bool block257=false; // (257) Pass
bool block258=true; // (258) Condition&nbsp;
bool block259=true; // (259) Condition&nbsp;
bool block260=true; // (260) GA &nbsp; &nbsp;TE
bool block261=true; // (261) REAL RISE
bool block262=true; // (262) REAL FALL
bool block263=true; // (263) PASS THESE FIRST
bool block264=true; // (264) Pass
bool block265=true; // (265) Pass
bool block266=true; // (266) Condition
bool block267=true; // (267) Condition
bool block272=true; // (272) Condition
bool block273=true; // (273) BuyRun
bool block277=true; // (277) SellRun
bool block278=true; // (278) Condition
bool block282=true; // (282) PASS THESE FIRST
bool block283=true; // (283) Condition
bool block284=true; // (284) Condition
bool block285=true; // (285) Close positions
bool block286=true; // (286) Condition
bool block287=true; // (287) Condition
bool block288=true; // (288) Close positions
bool block289=true; // (289) Pass
bool block291=true; // (291) SWEETSP&nbsp;
bool block292=true; // (292) SWEETSP
bool block293=true; // (293) SWEETSP&nbsp;
bool block294=true; // (294) SWEETSP
bool block295=true; // (295) Condition
bool block296=true; // (296) Condition
bool block297=true; // (297) Condition
bool block298=true; // (298) Condition
bool block299=true; // (299) Pass&nbsp;
bool block300=true; // (300) Loop (pass "n" times)
bool block301=true; // (301) Formula&nbsp;
bool block302=true; // (302) Custom MQL5 code
bool block303=true; // (303) Formula
bool block304=true; // (304) Formula
bool block305=true; // (305) PASS THESE FIRST
bool block306=true; // (306) ERROR FALL
bool block307=true; // (307) ERROR RISE&nbsp;
bool block308=true; // (308) Condition
bool block309=true; // (309) Condition
bool block311=true; // (311) Once per bar
bool block313=true; // (313) Condition
bool block315=true; // (315) PTF
bool block316=true; // (316) Condition
bool block317=true; // (317) Condition
bool block318=true; // (318) BuyRun
bool block322=true; // (322) SellRun
bool block323=true; // (323) Condition
bool block324=true; // (324) Condition
bool block327=true; // (327) Condition
bool block328=true; // (328) Condition
bool block329=true; // (329) Condition&nbsp;

//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[];

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                                 EVENT FUNCTIONS                                                  | //
// |                           These are the main functions that controls the whole project                           | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed once when the program starts //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
int OnInit()
{
	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);

	TimeAtStart("set"); // Set local and server time at start
	AccountBalanceAtStart(); // Set balance at start

	DrawSpreadInfo();
	DrawStatus("Starting...");

	if (ENABLE_EVENT_TIMER) {
		OnTimerSet(ON_TIMER_PERIOD);
	}


	block106();

	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()
{
	if (FXD_FIRST_TICK_PASSED==false) {DrawStatus("Working"); FXD_FIRST_TICK_PASSED=true;}
	DrawSpreadInfo();
	TicksData(""); // Collect ticks (if needed)
	// Main beginning on the graph
	block1();

	// Needed by the system
	TicksFromStart(true);
}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed on trade events - open, close, modify //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnTrade()
{
	OnTradeQueue(1);
	OnTradeQueue(-1);
}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// This function is executed once when the program ends //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
void OnDeinit(const int reason)
{
	//-- if Timer was set, kill it here
	EventKillTimer();

	if (MQL5InfoInteger(MQL5_TESTING)) {
		Print("Backtested in "+DoubleToString((GetTickCount()-FXD_MILS_INIT_END)/1000, 2)+" seconds");
		Print("Average ticks per second: "+DoubleToString(TicksFromStart()/(GetTickCount()-FXD_MILS_INIT_END),0));
	}

	DrawStatus("Stopped");
	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;
		}
	}
}

/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                   FUNCTIONS THAT REPRESENTS BLOCKS IN FXDREEMA                                   | //
// |                                    Each block is represented as function here                                    | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #106 (Pass) //
void block106(int _parent_=0)
{
	if (block106==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=106;

	block107(106);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #107 (Modify Variables) //
void block107(int _parent_=0)
{
	if (block107==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=107;

	anchorH=_value(startAn);
	anchorL=_value(startAn);
	blc=_value(startBlc);
	startP=_value(0);
	reGper=_value(minP);
	
	/* Orange output */
}
double _value(double Value) {
	return(Value);
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #1 (Once per bar) //
void block1(int _parent_=0)
{
	if (block1==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=1;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string SYMBOL=CurrentSymbol(); // Market
	ENUM_TIMEFRAMES TIMEFRAME=CurrentTimeframe(); // Timeframe
	int PassMaxTimes=1; // Max. times to pass
	
	///////////////
	// Main code //
	///////////////
	
	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;
	   }
	   block151(1); block160(1);
	}
	else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #2 (RISINGMACD) //
void block2(int _parent_=0)
{
	if (block2==false || FXD_BREAK==true) {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=_iMACD(fast, slow, sig, PRICE_CLOSE, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_iMACD(fast, slow, sig, PRICE_CLOSE, 1, CurrentSymbol(), CurrentTimeframe(), 2);
	   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);} else if (o2==true) {block7(2);}
}
double _iMACD(int FastEMAperiod, int SlowEMAperiod, int SignalPeriod, int AppliedPrice, int Mode, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iMACD(SYMBOL,TIMEFRAME,FastEMAperiod,SlowEMAperiod,SignalPeriod,AppliedPrice),Mode,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #3 (Modify Variables) //
void block3(int _parent_=0)
{
	if (block3==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=3;

	risingBars=(_value(risingBars)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block11(3);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #4 (Condition) //
void block4(int _parent_=0)
{
	if (block4==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=4;

	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=_value(currentH);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {
	
		// (adjust) Variables
		currentHAGE=0;
		// (finish)
	
	block6(4);} else if (o2==true) {block5(4);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #5 (Condition) //
void block5(int _parent_=0)
{
	if (block5==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=5;

	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=_candles("iHigh", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(currentH);
	   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) {block6(5);} else if (o2==true) {/* Yellow output */}
}
double _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, StrToTime(TimeStamp));
	}
	
	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];
	}
	else if (iOHLC=="iRealVolume") {
		CopyRealVolume(SYMBOL,TIMEFRAME,CandleID,1,cRealVolume);
		retval=(double)cRealVolume[0];
	}
	else if (iOHLC=="iTime") {
		CopyTime(SYMBOL,TIMEFRAME,CandleID,1,cTime);
		retval=(double)cTime[0];
	}
	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=="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(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #6 (NewHigh) //
void block6(int _parent_=0)
{
	if (block6==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=6;

	currentH=_candles("iHigh", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	currentHAGE=_value(0);
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #7 (Modify Variables) //
void block7(int _parent_=0)
{
	if (block7==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=7;

	fallingBars=(_value(fallingBars)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block17(7);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #8 (Condition) //
void block8(int _parent_=0)
{
	if (block8==false || FXD_BREAK==true) {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=_value(currentL);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {
	
		// (adjust) Variables
		currentLAGE=0;
		// (finish)
	
	block10(8);} else if (o2==true) {block9(8);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #9 (Condition) //
void block9(int _parent_=0)
{
	if (block9==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=9;

	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=_candles("iLow", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(currentL);
	   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) {block10(9);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #10 (NewLow) //
void block10(int _parent_=0)
{
	if (block10==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=10;

	currentL=_candles("iLow", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	currentLAGE=_value(0);
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #11 (PASS THESE FIRST) //
void block11(int _parent_=0)
{
	if (block11==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=11;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block4(11);}
	block13(11);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #12 (CROSSED) //
void block12(int _parent_=0)
{
	if (block12==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=12;

	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=_value(risingBars);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block14(12);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #13 (PASS THESE FIRST) //
void block13(int _parent_=0)
{
	if (block13==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=13;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block12(13);}
	block16(13);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #14 (Condition) //
void block14(int _parent_=0)
{
	if (block14==false || FXD_BREAK==true) {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=_value(fallingBars);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(goodRise);
	   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);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #15 (Modify Variables) //
void block15(int _parent_=0)
{
	if (block15==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=15;

	confirmedLAGE=_value(currentLAGE);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #16 (RESET) //
void block16(int _parent_=0)
{
	if (block16==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=16;

	currentL=_value(0);
	currentLAGE=_value(0);
	fallingBars=_value(0);
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #17 (PASS THESE FIRST) //
void block17(int _parent_=0)
{
	if (block17==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=17;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block8(17);}
	block19(17);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #18 (CROSSED) //
void block18(int _parent_=0)
{
	if (block18==false || FXD_BREAK==true) {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=_value(fallingBars);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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(18);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #19 (PASS THESE FIRST) //
void block19(int _parent_=0)
{
	if (block19==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=19;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block18(19);}
	block22(19);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #20 (Condition) //
void block20(int _parent_=0)
{
	if (block20==false || FXD_BREAK==true) {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=_value(risingBars);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(goodRise);
	   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 */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #21 (Modify Variables) //
void block21(int _parent_=0)
{
	if (block21==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=21;

	confirmedHAGE=_value(currentHAGE);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #22 (RESET) //
void block22(int _parent_=0)
{
	if (block22==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=22;

	currentH=_value(0);
	currentHAGE=_value(0);
	risingBars=_value(0);
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #23 (PASS THESE FIRST) //
void block23(int _parent_=0)
{
	if (block23==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=23;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block199(23);}
	block253(23);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #24 (Draw Line) //
void block24(int _parent_=0)
{
	if (block24==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=24;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="CONH"; // Object name/prefix (optional)
	int ObjectType=OBJ_VLINE; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=false; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=3; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","24","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", confirmedHAGE, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 10, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_candles("iClose", "id", 0, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_candles("iClose", "id", 10, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block25(24);
}
datetime _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==1) {retval=TimeLocal();} else {retval=TimeCurrent();}
	}
	else if(ModeTime==1) {
	      retval=StringToTime(TimeStamp);
	      retval0=retval;
	}
	else if(ModeTime==2) {
	   retval = TimeFromComponents(TimeSource == 1, 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(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #25 (Draw Line) //
void block25(int _parent_=0)
{
	if (block25==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=25;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="CONL"; // Object name/prefix (optional)
	int ObjectType=OBJ_VLINE; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=false; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=3; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","25","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", confirmedLAGE, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 10, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_candles("iClose", "id", 0, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_candles("iClose", "id", 10, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #26 (AGEAGEAGE) //
void block26(int _parent_=0)
{
	if (block26==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=26;

	currentHAGE=(_value(currentHAGE)+1);
	currentLAGE=(_value(currentLAGE)+1);
	confirmedHAGE=(_value(confirmedHAGE)+1);
	confirmedLAGE=(_value(confirmedLAGE)+1);
	setupAge=(_value(setupAge)+1);
	
	block24(26); block28(26);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #27 (PASS THESE FIRST) //
void block27(int _parent_=0)
{
	if (block27==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=27;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block26(27);}
	block29(27);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #28 (Modify Variables) //
void block28(int _parent_=0)
{
	if (block28==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=28;

	anchorH=(_value(anchorH)+1);
	anchorL=(_value(anchorL)+1);
	lastTrade=(_value(lastTrade)+1);
	breakAge=(_value(breakAge)+1);
	drawInterval=(_value(drawInterval)+1);
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #29 (Once per DAY) //
void block29(int _parent_=0)
{
	if (block29==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=29;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string SYMBOL=CurrentSymbol(); // Market
	ENUM_TIMEFRAMES TIMEFRAME=PERIOD_D1; // Timeframe
	int PassMaxTimes=1; // Max. times to pass
	
	///////////////
	// Main code //
	///////////////
	
	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;
	   }
	   
	
		// (adjust) Variables
		dayDrawn=0;
		onlyThis=0;
		FailedDraws=0;
		// (finish)
	
	/* Orange output */
	}
	else {block318(29); block322(29);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #33 (Formula&nbsp;) //
void block33(int _parent_=0)
{
	if (block33==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=33;

	double Lo=_iATR(atrPeriod, CurrentSymbol(), PERIOD_H1, 1);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(aFa);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	atr2=(Lo * Ro);
	
	block241(33);
}
double _iATR(int ATRperiod, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iATR(SYMBOL,TIMEFRAME,ATRperiod),0,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #34 (Draw Line&nbsp;) //
void block34(int _parent_=0)
{
	if (block34==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=34;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="FALL1"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","34","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorH, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorH)+atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)+atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block37(34);
}
double _OBJECT(string ObjSource, string Name, int Property, int FiboLevelID, double TLpriceLevel, int SHIFT) {
	if (ObjSource=="objloop") {Name=LoadedObjectName();}
	if (ObjectFind(0,Name)<0) {return(EMPTY_VALUE);}
	double retval=0;
	int modifier=0;
	
	double Fibo100=0;
	double Fibo0=0;
	double FiboDiff=0;
	
	if (Property==OBJPROP_TIME1)        {retval=(int)ObjectGetInteger(0,Name,OBJPROP_TIME,0);}
	else if (Property==OBJPROP_TIME2)   {retval=(int)ObjectGetInteger(0,Name,OBJPROP_TIME,1);}
	else if (Property==OBJPROP_TIME3)   {retval=(int)ObjectGetInteger(0,Name,OBJPROP_TIME,2);}
	
	else if (Property==OBJPROP_PRICE1)  {retval=ObjectGetDouble(0,Name,OBJPROP_PRICE,0);}
	else if (Property==OBJPROP_PRICE2)  {retval=ObjectGetDouble(0,Name,OBJPROP_PRICE,1);}
	else if (Property==OBJPROP_PRICE3)  {retval=ObjectGetDouble(0,Name,OBJPROP_PRICE,2);}
	
	else if (Property==OBJPROP_BARSHIFT1) {retval=iBarShift(Symbol(), Period(), (int)ObjectGetInteger(0,Name,OBJPROP_TIME,0), true); if (retval==-1) {SkipThePass(true);}}
	else if (Property==OBJPROP_BARSHIFT2) {retval=iBarShift(Symbol(), Period(), (int)ObjectGetInteger(0,Name,OBJPROP_TIME,1), true); if (retval==-1) {SkipThePass(true);}}
	else if (Property==OBJPROP_BARSHIFT3) {retval=iBarShift(Symbol(), Period(), (int)ObjectGetInteger(0,Name,OBJPROP_TIME,2), true); if (retval==-1) {SkipThePass(true);}}
	
	else if (Property==OBJPROP_COLOR)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_COLOR);}
	else if (Property==OBJPROP_STYLE)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_STYLE);}
	else if (Property==OBJPROP_WIDTH)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_WIDTH);}
	else if (Property==OBJPROP_BACK)       {retval=(int)ObjectGetInteger(0,Name,OBJPROP_BACK);}
	else if (Property==OBJPROP_RAY_LEFT)   {retval=(int)ObjectGetInteger(0,Name,OBJPROP_RAY_LEFT);}
	else if (Property==OBJPROP_RAY_RIGHT)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_RAY_RIGHT);}
	else if (Property==OBJPROP_RAY)        {retval=(int)ObjectGetInteger(0,Name,OBJPROP_RAY);}
	else if (Property==OBJPROP_ELLIPSE)    {retval=(int)ObjectGetInteger(0,Name,OBJPROP_ELLIPSE);}
	else if (Property==OBJPROP_ARROWCODE)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_ARROWCODE);}
	else if (Property==OBJPROP_FONTSIZE)   {retval=(int)ObjectGetInteger(0,Name,OBJPROP_FONTSIZE);}
	else if (Property==OBJPROP_CORNER)     {retval=(int)ObjectGetInteger(0,Name,OBJPROP_CORNER);}
	else if (Property==OBJPROP_XDISTANCE)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_XDISTANCE);}
	else if (Property==OBJPROP_YDISTANCE)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_YDISTANCE);}
	else if (Property==OBJPROP_LEVELCOLOR) {retval=(int)ObjectGetInteger(0,Name,OBJPROP_LEVELCOLOR);}
	else if (Property==OBJPROP_LEVELSTYLE) {retval=(int)ObjectGetInteger(0,Name,OBJPROP_LEVELSTYLE);}
	else if (Property==OBJPROP_LEVELWIDTH) {retval=(int)ObjectGetInteger(0,Name,OBJPROP_LEVELWIDTH);}
	else if (Property==OBJPROP_ANCHOR)     {retval=(int)ObjectGetInteger(0,Name,OBJPROP_ANCHOR);}
	else if (Property==OBJPROP_DIRECTION)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_DIRECTION);}
	else if (Property==OBJPROP_DEGREE)     {retval=(int)ObjectGetInteger(0,Name,OBJPROP_DEGREE);}
	else if (Property==OBJPROP_DRAWLINES)  {retval=(int)ObjectGetInteger(0,Name,OBJPROP_DRAWLINES);}
	else if (Property==OBJPROP_STATE)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_STATE);}
	else if (Property==OBJPROP_XSIZE)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_XSIZE);}
	else if (Property==OBJPROP_YSIZE)      {retval=(int)ObjectGetInteger(0,Name,OBJPROP_YSIZE);}
	else if (Property==OBJPROP_PERIOD)     {retval=(int)ObjectGetInteger(0,Name,OBJPROP_PERIOD);}
	else if (Property==OBJPROP_LEVELS)     {retval=(int)ObjectGetInteger(0,Name,OBJPROP_LEVELS);}
	
	else if (Property==OBJPROP_ANGLE)      {retval=ObjectGetDouble(0,Name,OBJPROP_ANGLE);}
	else if (Property==OBJPROP_SCALE)      {retval=ObjectGetDouble(0,Name,OBJPROP_SCALE);}
	else if (Property==OBJPROP_DEVIATION)  {retval=ObjectGetDouble(0,Name,OBJPROP_DEVIATION);}
	
	else if (Property==OBJPROP_FIRSTLEVEL) {retval=ObjectGetDouble(0,Name,OBJPROP_LEVELVALUE,FiboLevelID);}
	else if (Property==OBJPROP_TL_PRICE_BY_SHIFT) {SHIFT=SHIFT+IndicatorMoreShift();retval=ObjectGetValueByShift(Name,SHIFT);}
	else if (Property==OBJPROP_TL_SHIFT_BY_PRICE) {retval=ObjectGetShiftByValue(Name,TLpriceLevel);}
	
	else if (Property==OBJPROP_FIBOVALUE) {
		Fibo100  =ObjectGetDouble(0,Name,OBJPROP_PRICE,0);
		Fibo0    =ObjectGetDouble(0,Name,OBJPROP_PRICE,1);
		FiboDiff =Fibo100-Fibo0;
		retval=0;
		if (FiboDiff!=0) {retval=(SymbolInfoDouble(Symbol(),SYMBOL_BID)-Fibo0)/(FiboDiff);}
	}
	else if (Property==OBJPROP_FIBOPRICEVALUE) {
		Fibo100  =ObjectGetDouble(0,Name,OBJPROP_PRICE,0);
		Fibo0    =ObjectGetDouble(0,Name,OBJPROP_PRICE,1);
		FiboDiff =Fibo100-Fibo0;
		retval=(ObjectGetDouble(0,Name,OBJPROP_LEVELVALUE,FiboLevelID)*(FiboDiff))+Fibo0;
	}
	
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #35 (PASS THESE FIRST) //
void block35(int _parent_=0)
{
	if (block35==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=35;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block247(35);}
	block250(35);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #37 (Draw Line&nbsp;) //
void block37(int _parent_=0)
{
	if (block37==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=37;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="RISE3"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","37","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorL, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorL)-atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)-atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block52(37);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #41 (Custom MQL5 code) //
void block41(int _parent_=0)
{
	if (block41==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=41;

	ChartRedraw( );
	block54(41); block55(41);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #43 (PASS THESE FIRST) //
void block43(int _parent_=0)
{
	if (block43==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=43;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block2(43);}
	block23(43);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #51 (PASS THESE FIRST) //
void block51(int _parent_=0)
{
	if (block51==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=51;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block43(51);}
	block56(51);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #52 (Draw Line&nbsp;) //
void block52(int _parent_=0)
{
	if (block52==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=52;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="FALL3"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","52","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorH, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorH)-atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)-atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block53(52);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #53 (Draw Line&nbsp;) //
void block53(int _parent_=0)
{
	if (block53==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=53;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="RISE1"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","53","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorL, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorL)+atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)+atr2); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block76(53);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #54 (Condition&nbsp;) //
void block54(int _parent_=0)
{
	if (block54==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=54;

	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=_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 3);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 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) {
	
		// (adjust) Variables
		actualRise=1;
		// (finish)
	
	block102(54);} else if (o2==true) {
	
		// (adjust) Variables
		actualRise=0;
		// (finish)
	
	block103(54);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #55 (Condition&nbsp;) //
void block55(int _parent_=0)
{
	if (block55==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=55;

	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=_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 3);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 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) {
	
		// (adjust) Variables
		actualFall=1;
		// (finish)
	
	block103(55);} else if (o2==true) {
	
		// (adjust) Variables
		actualFall=0;
		// (finish)
	
	block102(55);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #56 (PASS THESE FIRST) //
void block56(int _parent_=0)
{
	if (block56==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=56;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block41(56);}
	block57(56);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #57 (TRADE) //
void block57(int _parent_=0)
{
	if (block57==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=57;

	block59(57);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #59 (PASS THESE FIRST) //
void block59(int _parent_=0)
{
	if (block59==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=59;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block96(59);}
	block93(59);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #69 (GA &nbsp; &nbsp;TE) //
void block69(int _parent_=0)
{
	if (block69==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=69;

	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=_value(trUp);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {
	
		// (adjust) Variables
		trUp=0;
		buyBank=buyBank+1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #70 (Buy now) //
void block70(int _parent_=0)
{
	if (block70==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=70;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersGroup=""; // Group # (empty=Default)
	string SYMBOL=CurrentSymbol(); // Market
	string VolumeMode="fixed"; // Money management
	double VolumeSize=lots1; // Lot size
	double VolumeSizeRisk=50; // Amount of money to risk
	double VolumeRisk=2.5; // Risk percent
	double VolumePercent=100; // Volume size
	double VolumeBlockPercent=3; // Block % of Balance
	double FixedRatioUnitSize=0.01; // Fixed Ratio: Unit size
	double FixedRatioDelta=20; // Fixed Ratio: Delta parameter
	double mmMgInitialLots=0.1; // Initial volume
	double mmMgMultiplyOnLoss=2; // Multiply on loss
	double mmMgMultiplyOnProfit=1; // Multiply on profit
	double mmMgAddLotsOnLoss=0; // Add lots on loss
	double mmMgAddLotsOnProfit=0; // Add lots on profit
	int mmMgResetOnLoss=0; // Reset after how many losses?
	int mmMgResetOnProfit=1; // Reset after how many profits?
	double mm1326InitialLots=0.1; // Initial volume
	bool mm1326Reverse=false; // Reverse 1-3-2-6?
	double mmFiboInitialLots=0.1; // Initial volume
	double mmDalembertInitialLots=0.1; // Initial volume
	bool mmDalembertReverse=false; // Reverse D'Alembert
	double mmLabouchereInitialLots=0.1; // Initial volume
	string mmLabouchereList="1,2,3,4,5,6"; // List of numbers
	bool mmLabouchereReverse=false; // Reverse Labouchere
	double mmSeqBaseLots=0.1; // Base volume
	string mmSeqOnLoss="3,2,6"; // Sequence on loss
	string mmSeqOnProfit="1"; // Sequence on profit
	double mmSeqReverse=false; // Reverse system?
	double VolumeUpperLimit=0; // Volume upper limit
	string StopLossMode="none"; // Stop-Loss mode
	double StopLossPips=100; // in pips...
	double StopLossPercentTP=100; // % of Take-Profit
	string TakeProfitMode="none"; // Take-Profit mode
	double TakeProfitPips=100; // in pips...
	double TakeProfitPercentSL=100; // % of Stop-Loss
	double Slippage=4; // Slippage
	string MyComment="Long position"; // Comment
	
	///////////////
	// Main code //
	///////////////
	
	SetSymbol(SYMBOL);
	
	//-- stops ------------------------------------------------------------------
	double sll=0, slp=0, tpl=0, tpp=0;
	
	     if (StopLossMode=="fixed")        {slp=StopLossPips;}
	else if (StopLossMode=="dynamicPips")  {slp=_value(100);}
	else if (StopLossMode=="dynamicDigits"){slp=toPips(_value(0.0100),SYMBOL);}
	else if (StopLossMode=="dynamicLevel") {sll=_value(1);}
	
	     if (TakeProfitMode=="fixed")         {tpp=TakeProfitPips;}
	else if (TakeProfitMode=="dynamicPips")   {tpp=_value(100);}
	else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_value(0.0100),SYMBOL);}
	else if (TakeProfitMode=="dynamicLevel")  {tpl=_value(1);}
	
	if (StopLossMode == "percentTP") {
	   if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
	   if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
	}
	if (TakeProfitMode == "percentSL") {
	   if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
	   if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
	}
	
	//-- lots -------------------------------------------------------------------
	double lots=0;
	double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolAsk(SYMBOL);}
	double pre_sl_pips=toPips(SymbolAsk(SYMBOL)-(pre_sll-toDigits(slp,SYMBOL)));
	
	     if (VolumeMode=="fixed")             {lots=DynamicLots(VolumeMode, VolumeSize);}
	else if (VolumeMode=="block-equity")      {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-balance")     {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-freemargin")  {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="equity")            {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="balance")           {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="freemargin")        {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="equityRisk")        {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="balanceRisk")       {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="freemarginRisk")    {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRisk")         {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRatio")        {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
	else if (VolumeMode=="dynamic")           {lots=AlignLots(_value(0.1));}
	else if (VolumeMode=="1326")              {lots=Bet1326(OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
	else if (VolumeMode=="fibonacci")         {lots=BetFibonacci(OrdersGroup, SYMBOL, mmFiboInitialLots);}
	else if (VolumeMode=="dalembert")         {lots=BetDalembert(OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
	else if (VolumeMode=="labouchere")        {lots=BetLabouchere(OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
	else if (VolumeMode=="martingale")        {lots=BetMartingale(OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
	else if (VolumeMode=="sequence")          {lots=BetSequence(OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
	
	lots = AlignLots(lots, 0, VolumeUpperLimit);
	
	//-- send -------------------------------------------------------------------
	bool success=BuyNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment);
	
	if (success>0) {block88(70); block99(70);} else {/* Gray output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #75 (Sell now) //
void block75(int _parent_=0)
{
	if (block75==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=75;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersGroup=""; // Group # (empty=Default)
	string SYMBOL=CurrentSymbol(); // Market
	string VolumeMode="fixed"; // Money management
	double VolumeSize=lots1; // Lot size
	double VolumeSizeRisk=50; // Amount of money to risk
	double VolumeRisk=2.5; // Risk percent
	double VolumePercent=100; // Volume size
	double VolumeBlockPercent=3; // Block % of Balance
	double FixedRatioUnitSize=0.01; // Fixed Ratio: Unit size
	double FixedRatioDelta=20; // Fixed Ratio: Delta parameter
	double mmMgInitialLots=0.1; // Initial volume
	double mmMgMultiplyOnLoss=2; // Multiply on loss
	double mmMgMultiplyOnProfit=1; // Multiply on profit
	double mmMgAddLotsOnLoss=0; // Add lots on loss
	double mmMgAddLotsOnProfit=0; // Add lots on profit
	int mmMgResetOnLoss=0; // Reset after how many losses?
	int mmMgResetOnProfit=1; // Reset after how many profits?
	double mm1326InitialLots=0.1; // Initial volume
	bool mm1326Reverse=false; // Reverse 1-3-2-6?
	double mmFiboInitialLots=0.1; // Initial volume
	double mmDalembertInitialLots=0.1; // Initial volume
	bool mmDalembertReverse=false; // Reverse D'Alembert
	double mmLabouchereInitialLots=0.1; // Initial volume
	string mmLabouchereList="1,2,3,4,5,6"; // List of numbers
	bool mmLabouchereReverse=false; // Reverse Labouchere
	double mmSeqBaseLots=0.1; // Base volume
	string mmSeqOnLoss="3,2,6"; // Sequence on loss
	string mmSeqOnProfit="1"; // Sequence on profit
	bool mmSeqReverse=false; // Reverse system?
	double VolumeUpperLimit=0; // Volume upper limit
	string StopLossMode="none"; // Stop-Loss mode
	double StopLossPips=100; // in pips...
	double StopLossPercentTP=100; // % of Take-Profit
	string TakeProfitMode="none"; // Take-Profit mode
	double TakeProfitPips=100; // in pips...
	double TakeProfitPercentSL=100; // % of Stop-Loss
	double Slippage=4; // Slippage
	string MyComment="Short position"; // Comment
	
	///////////////
	// Main code //
	///////////////
	
	SetSymbol(SYMBOL);
	
	//-- stops ------------------------------------------------------------------
	double sll=0, slp=0, tpl=0, tpp=0;
	
	     if (StopLossMode=="fixed")        {slp=StopLossPips;}
	else if (StopLossMode=="dynamicPips")  {slp=_value(100);}
	else if (StopLossMode=="dynamicDigits"){slp=toPips(_value(0.0100),SYMBOL);}
	else if (StopLossMode=="dynamicLevel") {sll=_value(1);}
	
	     if (TakeProfitMode=="fixed")         {tpp=TakeProfitPips;}
	else if (TakeProfitMode=="dynamicPips")   {tpp=_value(100);}
	else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_value(0.0100),SYMBOL);}
	else if (TakeProfitMode=="dynamicLevel")  {tpl=_value(1);}
	
	if (StopLossMode == "percentTP") {
	   if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
	   if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
	}
	if (TakeProfitMode == "percentSL") {
	   if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
	   if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
	}
	
	//-- lots -------------------------------------------------------------------
	double lots=0;
	double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolBid(SYMBOL);}
	double pre_sl_pips=toPips((pre_sll+toDigits(slp,SYMBOL))-SymbolBid(SYMBOL));
	
	     if (VolumeMode=="fixed")             {lots=DynamicLots(VolumeMode, VolumeSize);}
	else if (VolumeMode=="block-equity")      {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-balance")     {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-freemargin")  {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="equity")            {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="balance")           {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="freemargin")        {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="equityRisk")        {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="balanceRisk")       {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="freemarginRisk")    {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRisk")         {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRatio")        {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
	else if (VolumeMode=="dynamic")           {lots=AlignLots(_value(0.1));}
	else if (VolumeMode=="1326")              {lots=Bet1326(OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
	else if (VolumeMode=="fibonacci")         {lots=BetFibonacci(OrdersGroup, SYMBOL, mmFiboInitialLots);}
	else if (VolumeMode=="dalembert")         {lots=BetDalembert(OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
	else if (VolumeMode=="labouchere")        {lots=BetLabouchere(OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
	else if (VolumeMode=="martingale")        {lots=BetMartingale(OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
	else if (VolumeMode=="sequence")          {lots=BetSequence(OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
	
	lots = AlignLots(lots, 0, VolumeUpperLimit);
	
	//-- send -------------------------------------------------------------------
	bool success=SellNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment);
	
	if (success>0) {block92(75); block99(75);} else {/* Gray output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #76 (Draw Line&nbsp;) //
void block76(int _parent_=0)
{
	if (block76==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=76;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="FALLtgt"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_DOT; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","76","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorH, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorH)-(atr2*0.5)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)-(atr2*tpFactor)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block77(76);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #77 (Draw Line&nbsp;) //
void block77(int _parent_=0)
{
	if (block77==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=77;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="RISEtgt"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_DOT; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","77","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorL, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorL)+(atr2*tpFactor)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)+(atr2*0.5)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block86(77);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #86 (Draw Line&nbsp;) //
void block86(int _parent_=0)
{
	if (block86==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=86;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="FALLbrk"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_DASHDOTDOT; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","86","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorH, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorH)+(atr2*breakLineF)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)+(atr2*breakLineF)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block87(86);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #87 (Draw Line&nbsp;) //
void block87(int _parent_=0)
{
	if (block87==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=87;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="RISEbrk"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_DASHDOTDOT; // Line style
	int ObjWidth=1; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=false; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","87","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", anchorL, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 5, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, anchorL)-(atr2*breakLineF)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=(_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 5)-(atr2*breakLineF)); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	
	
		// (adjust) Variables
		startP=1;
		// (finish)
	
	block201(87);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #88 (BuyRun) //
void block88(int _parent_=0)
{
	if (block88==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=88;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block89(88);} else {block90(88);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #89 (INC &nbsp;BLC) //
void block89(int _parent_=0)
{
	if (block89==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=89;

	blc=(_value(blc)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #90 (DEC &nbsp;BLC) //
void block90(int _parent_=0)
{
	if (block90==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=90;

	blc=(_value(blc)-1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block91(90);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #91 (Condition) //
void block91(int _parent_=0)
{
	if (block91==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=91;

	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=_value(blc);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {
	
		// (adjust) Variables
		blc=0;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #92 (SellRun) //
void block92(int _parent_=0)
{
	if (block92==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=92;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block89(92);} else {block90(92);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #93 (PASS THESE FIRST) //
void block93(int _parent_=0)
{
	if (block93==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=93;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block108(93);}
	block111(93);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #94 (REAL RISE) //
void block94(int _parent_=0)
{
	if (block94==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=94;

	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=_value(actualRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {
	
		// (adjust) Variables
		actualRise=0;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #95 (REAL FALL) //
void block95(int _parent_=0)
{
	if (block95==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=95;

	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=_value(actualFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {
	
		// (adjust) Variables
		actualFall=0;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #96 (RISINGMACD) //
void block96(int _parent_=0)
{
	if (block96==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=96;

	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=_iMACD(fast, slow, sig, PRICE_CLOSE, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_iMACD(fast, slow, sig, PRICE_CLOSE, 1, CurrentSymbol(), CurrentTimeframe(), 2);
	   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) {block97(96);} else if (o2==true) {block98(96);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #97 (RISINGMACD) //
void block97(int _parent_=0)
{
	if (block97==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=97;

	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=_iMACD(fast, slow, sig, PRICE_CLOSE, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block95(97);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #98 (RISINGMACD) //
void block98(int _parent_=0)
{
	if (block98==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=98;

	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=_iMACD(fast, slow, sig, PRICE_CLOSE, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {/* Orange output */} else if (o2==true) {block94(98);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #99 (Pass) //
void block99(int _parent_=0)
{
	if (block99==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=99;

	
	
		// (adjust) Variables
		lastTrade=0;
		breakTrade=0;
		closeType=0;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #102 (AND) //
void block102(int _parent_=0)
{
	if (block102==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=102;

	static bool passed=false;
	static string list[];
	static string check[];
	static int old_tick=-1;
	bool go_to_next=false;
	static int list_size;
	
	if (!passed) {passed=true;
	   StringExplode(",",fxD_BlocksLookupTable(3,"102"),list);
	   list_size=ArraySize(list);
	}
	if (list_size==0) {
	   // This block is at the very top => pass everytime
	   go_to_next=true;
	}
	else {
	   // This block is child
	   int ticks=TicksFromStart();
	   if (old_tick!=ticks) {old_tick=ticks;
	      ArrayResize(check,0); // reset
	   }
	   if (ArraySearch(list,_parent_)>-1 && ArraySearch(check,_parent_)==-1) {
	      ArrayValue(check,_parent_); // add current parent
	      if (list_size==ArraySize(check)) {go_to_next=true;}
	   }
	   
	}
	if (go_to_next==true) {
	
		// (adjust) Variables
		onlyDir=1;
		// (finish)
	
	/* Orange output */} else {block104(102);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #103 (AND) //
void block103(int _parent_=0)
{
	if (block103==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=103;

	static bool passed=false;
	static string list[];
	static string check[];
	static int old_tick=-1;
	bool go_to_next=false;
	static int list_size;
	
	if (!passed) {passed=true;
	   StringExplode(",",fxD_BlocksLookupTable(3,"103"),list);
	   list_size=ArraySize(list);
	}
	if (list_size==0) {
	   // This block is at the very top => pass everytime
	   go_to_next=true;
	}
	else {
	   // This block is child
	   int ticks=TicksFromStart();
	   if (old_tick!=ticks) {old_tick=ticks;
	      ArrayResize(check,0); // reset
	   }
	   if (ArraySearch(list,_parent_)>-1 && ArraySearch(check,_parent_)==-1) {
	      ArrayValue(check,_parent_); // add current parent
	      if (list_size==ArraySize(check)) {go_to_next=true;}
	   }
	   
	}
	if (go_to_next==true) {
	
		// (adjust) Variables
		onlyDir=-1;
		// (finish)
	
	/* Orange output */} else {block104(103);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #104 (AND&nbsp;) //
void block104(int _parent_=0)
{
	if (block104==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=104;

	static bool passed=false;
	static string list[];
	static string check[];
	static int old_tick=-1;
	bool go_to_next=false;
	static int list_size;
	
	if (!passed) {passed=true;
	   StringExplode(",",fxD_BlocksLookupTable(3,"104"),list);
	   list_size=ArraySize(list);
	}
	if (list_size==0) {
	   // This block is at the very top => pass everytime
	   go_to_next=true;
	}
	else {
	   // This block is child
	   int ticks=TicksFromStart();
	   if (old_tick!=ticks) {old_tick=ticks;
	      ArrayResize(check,0); // reset
	   }
	   if (ArraySearch(list,_parent_)>-1 && ArraySearch(check,_parent_)==-1) {
	      ArrayValue(check,_parent_); // add current parent
	      if (list_size==ArraySize(check)) {go_to_next=true;}
	   }
	   
	}
	if (go_to_next==true) {
	
		// (adjust) Variables
		onlyDir=0;
		// (finish)
	
	/* Orange output */} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #108 (MAIN TRADE) //
void block108(int _parent_=0)
{
	if (block108==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=108;

	block282(108);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #109 (CHECK LINE) //
void block109(int _parent_=0)
{
	if (block109==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=109;

	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=_candles("iTypical", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISEbrk", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {
	
		// (adjust) Variables
		breakAge=0;
		breakType=-1;
		// (finish)
	
	block115(109);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #110 (CHECK LINE) //
void block110(int _parent_=0)
{
	if (block110==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=110;

	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=_candles("iTypical", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALLbrk", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {
	
		// (adjust) Variables
		breakAge=0;
		breakType=1;
		// (finish)
	
	block117(110);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #111 (PASS THESE FIRST) //
void block111(int _parent_=0)
{
	if (block111==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=111;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block114(111); block116(111);}
	block112(111);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #112 (AGE CHECK) //
void block112(int _parent_=0)
{
	if (block112==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=112;

	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=_value(breakAge);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block113(112);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #113 (AGE CHECK) //
void block113(int _parent_=0)
{
	if (block113==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=113;

	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=_value(breakAge);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(breakHorizon);
	   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) {block161(113);} else if (o2==true) {block118(113);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #114 (CHECK DNLEVEL) //
void block114(int _parent_=0)
{
	if (block114==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=114;

	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=_value(dnL);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block109(114);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #115 (Modify Variables) //
void block115(int _parent_=0)
{
	if (block115==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=115;

	dnL=_candles("iLow", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #116 (CHECK UPLEVEL) //
void block116(int _parent_=0)
{
	if (block116==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=116;

	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=_value(upL);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block110(116);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #117 (Modify Variables) //
void block117(int _parent_=0)
{
	if (block117==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=117;

	upL=_candles("iHigh", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #118 (RESET LVLS) //
void block118(int _parent_=0)
{
	if (block118==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=118;

	dnL=_value(0);
	upL=_value(0);
	breakType=_value(0);
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #119 (BuyRun) //
void block119(int _parent_=0)
{
	if (block119==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=119;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block120(119);} else {block121(119);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #120 (INC &nbsp;BLC) //
void block120(int _parent_=0)
{
	if (block120==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=120;

	blc=(_value(blc)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #121 (DEC &nbsp;BLC) //
void block121(int _parent_=0)
{
	if (block121==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=121;

	blc=(_value(blc)-1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block122(121);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #122 (Condition) //
void block122(int _parent_=0)
{
	if (block122==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=122;

	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=_value(blc);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {
	
		// (adjust) Variables
		blc=0;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #123 (SellRun) //
void block123(int _parent_=0)
{
	if (block123==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=123;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block120(123);} else {block121(123);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #124 (Buy now) //
void block124(int _parent_=0)
{
	if (block124==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=124;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersGroup=""; // Group # (empty=Default)
	string SYMBOL=CurrentSymbol(); // Market
	string VolumeMode="fixed"; // Money management
	double VolumeSize=lots1; // Lot size
	double VolumeSizeRisk=50; // Amount of money to risk
	double VolumeRisk=2.5; // Risk percent
	double VolumePercent=100; // Volume size
	double VolumeBlockPercent=3; // Block % of Balance
	double FixedRatioUnitSize=0.01; // Fixed Ratio: Unit size
	double FixedRatioDelta=20; // Fixed Ratio: Delta parameter
	double mmMgInitialLots=0.1; // Initial volume
	double mmMgMultiplyOnLoss=2; // Multiply on loss
	double mmMgMultiplyOnProfit=1; // Multiply on profit
	double mmMgAddLotsOnLoss=0; // Add lots on loss
	double mmMgAddLotsOnProfit=0; // Add lots on profit
	int mmMgResetOnLoss=0; // Reset after how many losses?
	int mmMgResetOnProfit=1; // Reset after how many profits?
	double mm1326InitialLots=0.1; // Initial volume
	bool mm1326Reverse=false; // Reverse 1-3-2-6?
	double mmFiboInitialLots=0.1; // Initial volume
	double mmDalembertInitialLots=0.1; // Initial volume
	bool mmDalembertReverse=false; // Reverse D'Alembert
	double mmLabouchereInitialLots=0.1; // Initial volume
	string mmLabouchereList="1,2,3,4,5,6"; // List of numbers
	bool mmLabouchereReverse=false; // Reverse Labouchere
	double mmSeqBaseLots=0.1; // Base volume
	string mmSeqOnLoss="3,2,6"; // Sequence on loss
	string mmSeqOnProfit="1"; // Sequence on profit
	double mmSeqReverse=false; // Reverse system?
	double VolumeUpperLimit=0; // Volume upper limit
	string StopLossMode="none"; // Stop-Loss mode
	double StopLossPips=100; // in pips...
	double StopLossPercentTP=100; // % of Take-Profit
	string TakeProfitMode="none"; // Take-Profit mode
	double TakeProfitPips=100; // in pips...
	double TakeProfitPercentSL=100; // % of Stop-Loss
	double Slippage=4; // Slippage
	string MyComment="Long position"; // Comment
	
	///////////////
	// Main code //
	///////////////
	
	SetSymbol(SYMBOL);
	
	//-- stops ------------------------------------------------------------------
	double sll=0, slp=0, tpl=0, tpp=0;
	
	     if (StopLossMode=="fixed")        {slp=StopLossPips;}
	else if (StopLossMode=="dynamicPips")  {slp=_value(100);}
	else if (StopLossMode=="dynamicDigits"){slp=toPips(_value(0.0100),SYMBOL);}
	else if (StopLossMode=="dynamicLevel") {sll=_value(1);}
	
	     if (TakeProfitMode=="fixed")         {tpp=TakeProfitPips;}
	else if (TakeProfitMode=="dynamicPips")   {tpp=_value(100);}
	else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_value(0.0100),SYMBOL);}
	else if (TakeProfitMode=="dynamicLevel")  {tpl=_value(1);}
	
	if (StopLossMode == "percentTP") {
	   if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
	   if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
	}
	if (TakeProfitMode == "percentSL") {
	   if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
	   if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
	}
	
	//-- lots -------------------------------------------------------------------
	double lots=0;
	double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolAsk(SYMBOL);}
	double pre_sl_pips=toPips(SymbolAsk(SYMBOL)-(pre_sll-toDigits(slp,SYMBOL)));
	
	     if (VolumeMode=="fixed")             {lots=DynamicLots(VolumeMode, VolumeSize);}
	else if (VolumeMode=="block-equity")      {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-balance")     {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-freemargin")  {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="equity")            {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="balance")           {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="freemargin")        {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="equityRisk")        {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="balanceRisk")       {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="freemarginRisk")    {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRisk")         {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRatio")        {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
	else if (VolumeMode=="dynamic")           {lots=AlignLots(_value(0.1));}
	else if (VolumeMode=="1326")              {lots=Bet1326(OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
	else if (VolumeMode=="fibonacci")         {lots=BetFibonacci(OrdersGroup, SYMBOL, mmFiboInitialLots);}
	else if (VolumeMode=="dalembert")         {lots=BetDalembert(OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
	else if (VolumeMode=="labouchere")        {lots=BetLabouchere(OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
	else if (VolumeMode=="martingale")        {lots=BetMartingale(OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
	else if (VolumeMode=="sequence")          {lots=BetSequence(OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
	
	lots = AlignLots(lots, 0, VolumeUpperLimit);
	
	//-- send -------------------------------------------------------------------
	bool success=BuyNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment);
	
	if (success>0) {block119(124);} else {/* Gray output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #125 (Sell now) //
void block125(int _parent_=0)
{
	if (block125==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=125;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersGroup=""; // Group # (empty=Default)
	string SYMBOL=CurrentSymbol(); // Market
	string VolumeMode="fixed"; // Money management
	double VolumeSize=lots1; // Lot size
	double VolumeSizeRisk=50; // Amount of money to risk
	double VolumeRisk=2.5; // Risk percent
	double VolumePercent=100; // Volume size
	double VolumeBlockPercent=3; // Block % of Balance
	double FixedRatioUnitSize=0.01; // Fixed Ratio: Unit size
	double FixedRatioDelta=20; // Fixed Ratio: Delta parameter
	double mmMgInitialLots=0.1; // Initial volume
	double mmMgMultiplyOnLoss=2; // Multiply on loss
	double mmMgMultiplyOnProfit=1; // Multiply on profit
	double mmMgAddLotsOnLoss=0; // Add lots on loss
	double mmMgAddLotsOnProfit=0; // Add lots on profit
	int mmMgResetOnLoss=0; // Reset after how many losses?
	int mmMgResetOnProfit=1; // Reset after how many profits?
	double mm1326InitialLots=0.1; // Initial volume
	bool mm1326Reverse=false; // Reverse 1-3-2-6?
	double mmFiboInitialLots=0.1; // Initial volume
	double mmDalembertInitialLots=0.1; // Initial volume
	bool mmDalembertReverse=false; // Reverse D'Alembert
	double mmLabouchereInitialLots=0.1; // Initial volume
	string mmLabouchereList="1,2,3,4,5,6"; // List of numbers
	bool mmLabouchereReverse=false; // Reverse Labouchere
	double mmSeqBaseLots=0.1; // Base volume
	string mmSeqOnLoss="3,2,6"; // Sequence on loss
	string mmSeqOnProfit="1"; // Sequence on profit
	bool mmSeqReverse=false; // Reverse system?
	double VolumeUpperLimit=0; // Volume upper limit
	string StopLossMode="none"; // Stop-Loss mode
	double StopLossPips=100; // in pips...
	double StopLossPercentTP=100; // % of Take-Profit
	string TakeProfitMode="none"; // Take-Profit mode
	double TakeProfitPips=100; // in pips...
	double TakeProfitPercentSL=100; // % of Stop-Loss
	double Slippage=4; // Slippage
	string MyComment="Short position"; // Comment
	
	///////////////
	// Main code //
	///////////////
	
	SetSymbol(SYMBOL);
	
	//-- stops ------------------------------------------------------------------
	double sll=0, slp=0, tpl=0, tpp=0;
	
	     if (StopLossMode=="fixed")        {slp=StopLossPips;}
	else if (StopLossMode=="dynamicPips")  {slp=_value(100);}
	else if (StopLossMode=="dynamicDigits"){slp=toPips(_value(0.0100),SYMBOL);}
	else if (StopLossMode=="dynamicLevel") {sll=_value(1);}
	
	     if (TakeProfitMode=="fixed")         {tpp=TakeProfitPips;}
	else if (TakeProfitMode=="dynamicPips")   {tpp=_value(100);}
	else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_value(0.0100),SYMBOL);}
	else if (TakeProfitMode=="dynamicLevel")  {tpl=_value(1);}
	
	if (StopLossMode == "percentTP") {
	   if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
	   if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
	}
	if (TakeProfitMode == "percentSL") {
	   if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
	   if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
	}
	
	//-- lots -------------------------------------------------------------------
	double lots=0;
	double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolBid(SYMBOL);}
	double pre_sl_pips=toPips((pre_sll+toDigits(slp,SYMBOL))-SymbolBid(SYMBOL));
	
	     if (VolumeMode=="fixed")             {lots=DynamicLots(VolumeMode, VolumeSize);}
	else if (VolumeMode=="block-equity")      {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-balance")     {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="block-freemargin")  {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
	else if (VolumeMode=="equity")            {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="balance")           {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="freemargin")        {lots=DynamicLots(VolumeMode, VolumePercent);}
	else if (VolumeMode=="equityRisk")        {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="balanceRisk")       {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="freemarginRisk")    {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRisk")         {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
	else if (VolumeMode=="fixedRatio")        {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
	else if (VolumeMode=="dynamic")           {lots=AlignLots(_value(0.1));}
	else if (VolumeMode=="1326")              {lots=Bet1326(OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
	else if (VolumeMode=="fibonacci")         {lots=BetFibonacci(OrdersGroup, SYMBOL, mmFiboInitialLots);}
	else if (VolumeMode=="dalembert")         {lots=BetDalembert(OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
	else if (VolumeMode=="labouchere")        {lots=BetLabouchere(OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
	else if (VolumeMode=="martingale")        {lots=BetMartingale(OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
	else if (VolumeMode=="sequence")          {lots=BetSequence(OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
	
	lots = AlignLots(lots, 0, VolumeUpperLimit);
	
	//-- send -------------------------------------------------------------------
	bool success=SellNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment);
	
	if (success>0) {block123(125);} else {/* Gray output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #126 (CHECK LINE) //
void block126(int _parent_=0)
{
	if (block126==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=126;

	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=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(upL);
	   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) {block136(126);} else if (o2==true) {block130(126);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #127 (Condition) //
void block127(int _parent_=0)
{
	if (block127==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=127;

	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=_value(breakType);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block126(127);} else if (o2==true) {block128(127);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #128 (Condition) //
void block128(int _parent_=0)
{
	if (block128==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=128;

	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=_value(breakType);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(-1);
	   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) {block129(128);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #129 (CHECK LINE) //
void block129(int _parent_=0)
{
	if (block129==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=129;

	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=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(dnL);
	   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) {block135(129);} else if (o2==true) {block131(129);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #130 (Draw Line) //
void block130(int _parent_=0)
{
	if (block130==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=130;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="orderTgt"; // Object name/prefix (optional)
	int ObjectType=OBJ_HLINE; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=false; // Ray right
	color ObjColor=clrWhite; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=2; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","130","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", 0, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 10, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_value(dnL); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_candles("iClose", "id", 10, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #131 (Draw Line) //
void block131(int _parent_=0)
{
	if (block131==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=131;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="orderTgt"; // Object name/prefix (optional)
	int ObjectType=OBJ_HLINE; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=false; // Ray left
	bool ObjRayRight=false; // Ray right
	color ObjColor=clrWhite; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=2; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","131","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", 0, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 10, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_value(upL); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_candles("iClose", "id", 10, "00:00", CurrentSymbol(), CurrentTimeframe()); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #132 (Delete objects&nbsp;) //
void block132(int _parent_=0)
{
	if (block132==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=132;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string NameStartsWith="orderTgt"; // Name starts with
	string NameContains=""; // Name contains
	color ObjColor=clrWhite; // Color
	string SortMode="z-a"; // Sort objects
	int MaxObjects=0; // Max objects to clear
	int SkipObjects=0; // Skip "n" objects
	
	///////////////
	// Main code //
	///////////////
	
	int index=0;
	int total=ObjectsTotal(0);
	int deleted_count=0;
	int skipped_count=0;
	string name="";
	int length=0;
	bool deleted=false;
	if (SortMode=="a-z")
	{
	   for (index=0; index<total; index++) {
	      name=ObjectName(0,index);
	      if (name!="") {
	         if (MaxObjects>0 && deleted_count>=MaxObjects) {break;}
	         deleted=false;
	         if (ObjColor!=EMPTY_VALUE && ObjectGetInteger(0, name, OBJPROP_COLOR) != ObjColor) {continue;}
	         if (NameStartsWith=="" && NameContains=="") {
	            if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	            if (ObjectDelete(0,name)) {deleted_count++;}
	         }
	         else {
	            if (NameStartsWith!="") {
	               length=StringLen(NameStartsWith);
	               if (StringSubstr(name,0,length)==NameStartsWith) {
	                  if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	                  if (ObjectDelete(0,name)) {deleted_count++;}
	               }
	            }
	            if (deleted==false && NameContains!="") {
	               if (StringFind(name,NameContains,0)>-1) {
	                  if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	                  if (ObjectDelete(0,name)) {deleted_count++;}
	               }
	            }
	         }
	      }
	   }
	}
	else if (SortMode=="z-a")
	{
	   for (index=total-1; index>=0; index--) {
	      name=ObjectName(0,index);
	      if (name!="") {
	         if (MaxObjects>0 && deleted_count>=MaxObjects) {break;}
	         deleted=false;
	         if (ObjColor!=EMPTY_VALUE && ObjectGetInteger(0, name, OBJPROP_COLOR) != ObjColor) {continue;}
	         if (NameStartsWith=="" && NameContains=="") {
	            if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	            if (ObjectDelete(0,name)) {deleted_count++;}
	         }
	         else {
	            if (NameStartsWith!="") {
	               length=StringLen(NameStartsWith);
	               if (StringSubstr(name,0,length)==NameStartsWith) {
	                  if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	                  if (ObjectDelete(0,name)) {deleted_count++;}
	               }
	            }
	            if (deleted==false && NameContains!="") {
	               if (StringFind(name,NameContains,0)>-1) {
	                  if (SkipObjects>0 && skipped_count<SkipObjects) {skipped_count++; continue;}
	                   
	                  if (ObjectDelete(0,name)) {deleted_count++;}
	               }
	            }
	         }
	      }
	   }
	}
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #133 (Loop (pass "n" times)) //
void block133(int _parent_=0)
{
	if (block133==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=133;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=blc *2; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block124(133);}
	block132(133); block150(133);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #134 (Loop (pass "n" times)) //
void block134(int _parent_=0)
{
	if (block134==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=134;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=blc *2; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block125(134);}
	block132(134); block150(134);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #135 (BuyRun) //
void block135(int _parent_=0)
{
	if (block135==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=135;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block134(135);} else {block118(135);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #136 (SellRun) //
void block136(int _parent_=0)
{
	if (block136==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=136;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block133(136);} else {block118(136);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #147 (Formula) //
void block147(int _parent_=0)
{
	if (block147==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=147;

	double Lo=_iATR(atrD, CurrentSymbol(), PERIOD_D1, 0);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_iATR(fast, CurrentSymbol(), PERIOD_D1, 0);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	a11=(Lo / Ro);
	
	block148(147);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #148 (Formula) //
void block148(int _parent_=0)
{
	if (block148==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=148;

	double Lo=_value(atrMulti0);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(MathPow( a11, atrDPower));
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	Result354=(Lo * Ro);
	
	
	
		// (adjust) Variables
		aFa=Result354;
		// (finish)
	
	block33(148);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #150 (Pass) //
void block150(int _parent_=0)
{
	if (block150==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=150;

	
	
		// (adjust) Variables
		breakTrade=1;
		dayDrawn=1;
		closeType=0;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #151 (If position is running) //
void block151(int _parent_=0)
{
	if (block151==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=151;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="both"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block154(151);} else {
	
		// (adjust) Variables
		blc=0;
		breakType=0;
		breakTrade=0;
		profitBars=0;
		onlyThis=0;
		FailedDraws=0;
		// (finish)
	
	/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #154 (Pass) //
void block154(int _parent_=0)
{
	if (block154==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=154;

	block186(154);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #155 (check profit) //
void block155(int _parent_=0)
{
	if (block155==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=155;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string ProfitCheckMode="currency"; // Check mode
	double CurrencyAmount=0; // Amount in deposit currency
	double PercentAccountProfit=50; // % of account profit
	double PercentEquity=5; // % of current Equity
	double PercentBalance=5; // % of current Balance
	double PercentFreeMargin=5; // % of current Free margin
	
	///////////////
	// Main code //
	///////////////
	
	if (FXD_BREAK==true) {return;}
	LoopedResume();
	
	double profit=attrProfit()+attrSwap()+attrCommission();
	double amount=0;
	
	     if (ProfitCheckMode=="currency")     {amount=CurrencyAmount;}
	else if (ProfitCheckMode=="accountprofit"){amount=AccountProfit()*PercentAccountProfit/100;}
	else if (ProfitCheckMode=="equity")       {amount=AccountEquity()*PercentEquity/100;}
	else if (ProfitCheckMode=="balance")      {amount=AccountBalance()*PercentBalance/100;}
	else if (ProfitCheckMode=="freemargin")   {amount=AccountFreeMargin()*PercentFreeMargin/100;}
	
	if (profit>amount) {block158(155);} else {
	
		// (adjust) Variables
		profitBars=0;
		// (finish)
	
	/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #156 (Modify Variables) //
void block156(int _parent_=0)
{
	if (block156==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=156;

	profitBars=(_value(profitBars)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block157(156);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #157 (Condition) //
void block157(int _parent_=0)
{
	if (block157==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=157;

	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=_value(profitBars);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(TrailPbars);
	   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) {block159(157);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #158 (Condition) //
void block158(int _parent_=0)
{
	if (block158==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=158;

	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=_value(blc);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(TrailBlc);
	   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) {block156(158);} else if (o2==true) {
	
		// (adjust) Variables
		profitBars=0;
		// (finish)
	
	/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #159 (Trailing stop&nbsp;) //
void block159(int _parent_=0)
{
	if (block159==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=159;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="both"; // Filter by type
	int TrailWhat=1; // Trail what?
	int TrailingReferencePrice=0; // Reference price
	string TrailingStopMode="percentProfit"; // Trailing Stop is...
	double tStopPips=40; // Pips
	double tStopMoney=10; // Money
	double tStopPercentTP=100; // % of the opposite stop
	double tStopPercentProfit=TrailPerc; // % of profit
	string TrailingStepMode="fixed"; // Trailing Step is...
	double tStepPips=1; // Pips
	double tStepPercentTS=10; // % of Trailing Stop
	string TrailingStartMode="none"; // Trailing Start is...
	double tStartPips=10; // Pips (offset)
	double tStartPercentTS=100; // % of Trailing Stop
	double tStartPercentSL=10; // % of the stop
	double tStartPercentTP=10; // % of the opposite stop
	string TrailingTPmode="none"; // Opposite stop mode
	double tTPpips=20; // Pips
	double tTPpercentTS=200; // % of Trailing Stop
	
	///////////////
	// Main code //
	///////////////
	
	for (int pos=0; pos<PositionsTotal(); pos++) {
	   if (LoadOrder(GetOrderSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         
	         SetSymbol(attrSymbol());
	         string polarity="buy";
	         double askbid=0;
	         double bidask=0;
	         double sltp=0;
	         double tpsl=0;
	         if (TrailWhat>0) {
	            sltp=attrStopLoss();
	            tpsl=attrTakeProfit();
	         }
	         else {
	            sltp=attrTakeProfit();
	            tpsl=attrStopLoss();
	         }
	         if (attrType()==POSITION_TYPE_BUY) {
	            polarity="buy";
	            askbid=SymbolAsk();
	            bidask=SymbolBid();
	            if (TrailingReferencePrice == 1) {
	               askbid=SymbolBid();
	               bidask=SymbolAsk();
	            }
	         }
	         else if (attrType()==POSITION_TYPE_SELL) {
	            polarity="sell";
	            askbid=SymbolBid();
	            bidask=SymbolAsk();
	            if (TrailingReferencePrice == 1) {
	               askbid=SymbolAsk();
	               bidask=SymbolBid();
	            }
	         }
	         if (TrailingReferencePrice == 2) {
	            askbid = (SymbolAsk() + SymbolBid()) / 2;
	            bidask = askbid;
	         }
	         
	         // Trailing Stop Size
	         double t_stop=0;
	         if (TrailingStopMode=="fixed")               {t_stop = tStopPips;} 
	         else if (TrailingStopMode=="percentTP")      {t_stop = (MathAbs(toPips(attrOpenPrice()-tpsl)))*(tStopPercentTP/100);}
	         else if (TrailingStopMode=="percentProfit")  {t_stop = (MathAbs(toPips(askbid-attrOpenPrice())))*(tStopPercentProfit/100);}
	         else if (TrailingStopMode=="function")
	         {
	            t_stop=_iAO(CurrentSymbol(), CurrentTimeframe(), 0);
	         }
	         else if (TrailingStopMode=="money") {
	            t_stop=10;
	            double lotsize = SymbolInfoDouble(attrSymbol(),SYMBOL_TRADE_CONTRACT_SIZE);
	            double tickvalue = (SymbolInfoDouble(attrSymbol(),SYMBOL_TRADE_TICK_VALUE)/SymbolInfoDouble(attrSymbol(),SYMBOL_TRADE_TICK_SIZE))*SymbolInfoDouble(attrSymbol(),SYMBOL_POINT);
	            t_stop = t_stop /  (attrLots() * PipValue());
	            t_stop = t_stop / tickvalue;
	         }
	         
	         // Trailing Start Level
	         double t_start=0;
	         if (TrailingStartMode=="none")           {t_start = -EMPTY_VALUE;}
	         else if (TrailingStartMode=="zero")      {t_start = 0;}
	         else if (TrailingStartMode=="fixed")     {t_start = tStartPips;}
	         else if (TrailingStartMode=="percentTS") {t_start = t_stop*(tStartPercentTS/100);}
	         else if (TrailingStartMode=="percentTP") {t_start = (MathAbs(toPips(attrOpenPrice()-tpsl)))*(tStartPercentTP/100);}
	         else if (TrailingStartMode=="percentSL") {t_start = (MathAbs(toPips(attrOpenPrice()-sltp)))*(tStartPercentSL/100);}
	         else if (TrailingStartMode=="function")  {t_start  =_value(0);}
	         
	         // Trailing Step Size
	         double t_step=0;
	         if (TrailingStepMode=="fixed")           {t_step = tStepPips;}
	         else if (TrailingStepMode=="percentTS")  {t_step = t_stop*(tStepPercentTS/100);}
	         
	         // Trailing Take Profit
	         double t_opp=0;
	         if (TrailingTPmode=="none")            {t_opp = tpsl;}
	         else if (TrailingTPmode=="clear")      {t_opp = 0;}
	         else if (TrailingTPmode=="fixed")      {t_opp = TrailWhat*(attrOpenPrice()-toDigits(tTPpips));/*t_opp=TakeProfit(polarity,tTPpips,attrOpenPrice());*/}
	         else if (TrailingTPmode=="percentTS")  {t_opp = TrailWhat*(attrOpenPrice()-toDigits(t_stop*(tTPpercentTS/100)));/*t_opp=TakeProfit(polarity,t_stop*(tTPpercentTS/100),attrOpenPrice());*/}
	         else if (TrailingTPmode=="function")   {t_opp = _value(0);}
	         
	         double stopslevel=(double)SymbolInfoInteger(attrSymbol(),SYMBOL_TRADE_STOPS_LEVEL);
	         stopslevel=toDigits(stopslevel/PipValue(),attrSymbol());
	         double fsl=0;
	         double limit=0;
	         
	         if (t_stop==0) {return;}
	
	         if (attrType()==POSITION_TYPE_BUY && TrailWhat*(askbid-attrOpenPrice())>toDigits(t_start))
	         {
	            if ((TrailWhat*(askbid-sltp)>=toDigits(t_stop+t_step)) || sltp==0)
	            {
	               fsl=MathAbs(askbid-toDigits(t_stop));
	               limit=bidask-stopslevel*TrailWhat;
	               if (fsl>limit) {fsl=limit;}
	               if (TrailWhat==1) {
	                  if (sltp==0 || sltp<fsl) {
	                     ModifyOrder(attrSymbol(),askbid-toDigits(t_stop),t_opp,0,0);
	                  }
	               }
	               else {
	                  if (sltp==0 || sltp>fsl) {
	                     ModifyOrder(attrSymbol(),t_opp,askbid+toDigits(t_stop),0,0);
	                  }
	               }
	            }
	         }
	         else if (attrType()==POSITION_TYPE_SELL && TrailWhat*(attrOpenPrice()-askbid)>toDigits(t_start))
	         {
	            if ((TrailWhat*(sltp-askbid)>=toDigits(t_stop+t_step)) || sltp==0)
	            {
	               fsl=MathAbs(askbid+toDigits(t_stop));
	               limit=bidask+stopslevel*TrailWhat;
	               if (fsl<limit) {fsl=limit;}
	               if (TrailWhat==1) {
	                  if (sltp==0 || sltp>fsl) {
	                     ModifyOrder(attrSymbol(),askbid+toDigits(t_stop),t_opp,0,0);
	                  }
	               }
	               else {
	                  if (sltp==0 || sltp<fsl) {
	                     ModifyOrder(attrSymbol(),t_opp,askbid-toDigits(t_stop),0,0);
	                  }
	               }
	            }
	         }
	      }
	   }
	}
	
	/* Orange output */
}
double _iAO(string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iAO(SYMBOL,TIMEFRAME),0,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #160 (Formula) //
void block160(int _parent_=0)
{
	if (block160==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=160;

	double Lo=_iStdDev(MomenH1, 0, MODE_SMA, PRICE_CLOSE, CurrentSymbol(), PERIOD_H1, 1);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_iATR(atrPeriod, CurrentSymbol(), PERIOD_H1, 1);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	mRel=(Lo / Ro);
	
	block175(160);
}
double _iStdDev(int MAperiod, int MAshift, ENUM_MA_METHOD MAmethod, int AppliedPrice, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iStdDev(SYMBOL,TIMEFRAME,MAperiod,MAshift,MAmethod,AppliedPrice),0,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #161 (Condition) //
void block161(int _parent_=0)
{
	if (block161==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=161;

	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=_fResults(mRel);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MomenH1Factor);
	   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) {block127(161);} else if (o2==true) {/* Yellow output */}
}
double _fResults(double fResult) {
	return((double)fResult);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #173 (REAL RISE) //
void block173(int _parent_=0)
{
	if (block173==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=173;

	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=_value(actualRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block155(173);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #174 (REAL FALL) //
void block174(int _parent_=0)
{
	if (block174==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=174;

	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=_value(actualFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block155(174);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #175 (PASS THESE FIRST) //
void block175(int _parent_=0)
{
	if (block175==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=175;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block51(175);}
	block27(175); block249(175); block251(175); block254(175);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #186 (BuyRun) //
void block186(int _parent_=0)
{
	if (block186==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=186;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block174(186);} else {block173(186);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #189 (Condition) //
void block189(int _parent_=0)
{
	if (block189==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=189;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISE3", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block194(189);} else if (o2==true) {block211(189);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #190 (Condition) //
void block190(int _parent_=0)
{
	if (block190==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=190;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALL3", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block194(190);} else if (o2==true) {block211(190);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #191 (Condition) //
void block191(int _parent_=0)
{
	if (block191==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=191;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALL1", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block210(191);} else if (o2==true) {block211(191);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #192 (Condition) //
void block192(int _parent_=0)
{
	if (block192==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=192;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISE1", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block210(192);} else if (o2==true) {block211(192);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #193 (Modify Variables) //
void block193(int _parent_=0)
{
	if (block193==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=193;

	outsideBOTH=(_value(outsideBOTH)+1);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block196(193);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #194 (WITHIN) //
void block194(int _parent_=0)
{
	if (block194==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=194;

	static bool passed=false;
	static string list[];
	static string check[];
	static int old_tick=-1;
	bool go_to_next=false;
	static int list_size;
	
	if (!passed) {passed=true;
	   StringExplode(",",fxD_BlocksLookupTable(3,"194"),list);
	   list_size=ArraySize(list);
	}
	if (list_size==0) {
	   // This block is at the very top => pass everytime
	   go_to_next=true;
	}
	else {
	   // This block is child
	   int ticks=TicksFromStart();
	   if (old_tick!=ticks) {old_tick=ticks;
	      ArrayResize(check,0); // reset
	   }
	   if (ArraySearch(list,_parent_)>-1 && ArraySearch(check,_parent_)==-1) {
	      ArrayValue(check,_parent_); // add current parent
	      if (list_size==ArraySize(check)) {go_to_next=true;}
	   }
	   
	}
	if (go_to_next==true) {
	
		// (adjust) Variables
		outsideBOTH=0;
		// (finish)
	
	/* Orange output */} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #195 (Pass) //
void block195(int _parent_=0)
{
	if (block195==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=195;

	block207(195); block208(195);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #196 (Condition) //
void block196(int _parent_=0)
{
	if (block196==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=196;

	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=_value(outsideBOTH);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(outsideMax);
	   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) {block197(196);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #197 (No position is running) //
void block197(int _parent_=0)
{
	if (block197==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=197;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="both"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==false) {
	
		// (adjust) Variables
		dayDrawn=0;
		// (finish)
	
	block299(197);} else {block252(197);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #199 (NOT DRAWN) //
void block199(int _parent_=0)
{
	if (block199==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=199;

	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=_value(dayDrawn);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(2);
	   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) {block35(199);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #201 (Pass) //
void block201(int _parent_=0)
{
	if (block201==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=201;

	
	
		// (adjust) Variables
		dayDrawn=2;
		// (finish)
	
	block245(201);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #207 (REAL RISE) //
void block207(int _parent_=0)
{
	if (block207==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=207;

	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=_value(actualRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block189(207); block190(207);} else if (o2==true) {block210(207);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #208 (REAL FALL) //
void block208(int _parent_=0)
{
	if (block208==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=208;

	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=_value(actualFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block191(208); block192(208);} else if (o2==true) {block194(208);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #210 (WITHIN) //
void block210(int _parent_=0)
{
	if (block210==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=210;

	static bool passed=false;
	static string list[];
	static string check[];
	static int old_tick=-1;
	bool go_to_next=false;
	static int list_size;
	
	if (!passed) {passed=true;
	   StringExplode(",",fxD_BlocksLookupTable(3,"210"),list);
	   list_size=ArraySize(list);
	}
	if (list_size==0) {
	   // This block is at the very top => pass everytime
	   go_to_next=true;
	}
	else {
	   // This block is child
	   int ticks=TicksFromStart();
	   if (old_tick!=ticks) {old_tick=ticks;
	      ArrayResize(check,0); // reset
	   }
	   if (ArraySearch(list,_parent_)>-1 && ArraySearch(check,_parent_)==-1) {
	      ArrayValue(check,_parent_); // add current parent
	      if (list_size==ArraySize(check)) {go_to_next=true;}
	   }
	   
	}
	if (go_to_next==true) {
	
		// (adjust) Variables
		outsideBOTH=0;
		// (finish)
	
	/* Orange output */} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #211 (Once per bar) //
void block211(int _parent_=0)
{
	if (block211==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=211;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string SYMBOL=CurrentSymbol(); // Market
	ENUM_TIMEFRAMES TIMEFRAME=CurrentTimeframe(); // Timeframe
	int PassMaxTimes=1; // Max. times to pass
	
	///////////////
	// Main code //
	///////////////
	
	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;
	   }
	   block193(211);
	}
	else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #230 (Loop (pass "n" times)) //
void block230(int _parent_=0)
{
	if (block230==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=230;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=reGper; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	// (adjust) Variables
	loopId=reGper;
	sumPrice=0;
	// (finish)
	
	for (int i=1; i<=Cycles; i++) {block231(230);}
	
	
		// (adjust) Variables
		meanPrice=sumPrice/reGper;
		// (finish)
	
	block232(230);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #231 (Formula) //
void block231(int _parent_=0)
{
	if (block231==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=231;

	double Lo=_iMA(regMa, 0, MODE_LWMA, PRICE_CLOSE, CurrentSymbol(), CurrentTimeframe(), loopId);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(sumPrice);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	sp=(Lo + Ro);
	
	
	
		// (adjust) Variables
		loopId=loopId-1;
		sumPrice=sp;
		// (finish)
	
	/* Orange output */
}
double _iMA(int MAperiod, int MAshift, ENUM_MA_METHOD MAmethod, int AppliedPrice, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iMA(SYMBOL,TIMEFRAME,MAperiod,MAshift,MAmethod,AppliedPrice),0,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #232 (Loop (pass "n" times)) //
void block232(int _parent_=0)
{
	if (block232==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=232;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=reGper; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	// (adjust) Variables
	loopId=reGper;
	xSum=0;
	sqSum=0;
	slope=0;
	// (finish)
	
	for (int i=1; i<=Cycles; i++) {block233(232);}
	
	
		// (adjust) Variables
		slope=xSum/sqSum;
		// (finish)
	
	/* Yellow output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #233 (Formula) //
void block233(int _parent_=0)
{
	if (block233==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=233;

	double Lo=_iMA(regMa, 0, MODE_LWMA, PRICE_CLOSE, CurrentSymbol(), CurrentTimeframe(), loopId);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(meanPrice);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	Yerr=(Lo - Ro);
	
	block234(233);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #234 (SUMsterr) //
void block234(int _parent_=0)
{
	if (block234==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=234;

	double Lo=_fResults(Yerr);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(loopId - anchorH/2);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	xs=(Lo * Ro);
	
	
	
		// (adjust) Variables
		xSum=xSum + xs;
		// (finish)
	
	block237(234);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #237 (Formula) //
void block237(int _parent_=0)
{
	if (block237==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=237;

	double Lo=_value(MathPow(loopId - anchorH/2, 2));
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(sqSum);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	asd23=(Lo + Ro);
	
	
	
		// (adjust) Variables
		loopId=loopId-1;
		sqSum=asd23;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #238 (SET REG TYPE FALL) //
void block238(int _parent_=0)
{
	if (block238==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=238;

	reGper=_value(anchorH);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block240(238);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #239 (Draw Line) //
void block239(int _parent_=0)
{
	if (block239==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=239;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="FALL2"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=true; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrRed; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=2; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","239","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", MathFloor(reGper/2), "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 1, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_value(meanPrice); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_value(meanPrice + meanPrice* slope * (1-MathFloor(reGper/2))); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block305(239);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #240 (Condition) //
void block240(int _parent_=0)
{
	if (block240==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=240;

	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=_value(reGper);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(minP);
	   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) {block230(240);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #241 (PASS THESE FIRST) //
void block241(int _parent_=0)
{
	if (block241==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=241;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block238(241);}
	block327(241);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #242 (PASS THESE FIRST) //
void block242(int _parent_=0)
{
	if (block242==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=242;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block243(242);}
	block328(242);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #243 (SET REG TYPE RISE) //
void block243(int _parent_=0)
{
	if (block243==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=243;

	reGper=_value(anchorL);
	// Variable2 is not selected =;
	// Variable3 is not selected =;
	// Variable4 is not selected =;
	// Variable5 is not selected =;
	
	block240(243);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #244 (Draw Line) //
void block244(int _parent_=0)
{
	if (block244==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=244;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	bool ObjectPerBar=false; // This block can create 1 object per bar
	bool ObjectUpdate=true; // Redraw the current object
	string ObjName="RISE2"; // Object name/prefix (optional)
	int ObjectType=OBJ_TREND; // Object type
	double ObjAngle=45; // Angle
	bool ObjRay=true; // Ray
	bool ObjRayLeft=true; // Ray left
	bool ObjRayRight=true; // Ray right
	color ObjColor=clrDeepSkyBlue; // Color
	ENUM_LINE_STYLE ObjStyle=STYLE_SOLID; // Line style
	int ObjWidth=2; // Width
	bool ObjBack=false; // In the background
	bool ObjSelectable=true; // Selectable
	bool ObjSelected=false; // Selected
	bool ObjHidden=false; // Visibility
	int ObjZorder=0; // Z-order
	string ObjChartSubWindow=""; // Chart Sub-Window
	
	///////////////
	// Main code //
	///////////////
	
	long ObjChartID = 0;
	int subwindow_id = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	if (subwindow_id >= 0)
	{
	   double p1=0, p2=0;
	   datetime t1=0, t2=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_line_","244","_");}
	      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,t1,p1,t2,p2))
	      {
	         Print(__FUNCTION__,": failed to create line object! Error code = ",GetLastError());
	      }
	   
	      switch(ObjectType)
	      {
	         case OBJ_VLINE: {t1=1; break;}
	         case OBJ_HLINE: {p1=1; break;}
	         case OBJ_TREND: {t1=1; p1=1; t2=1; p2=1; break;}
	         case OBJ_TRENDBYANGLE: {t1=1; p1=1; break;}
	         case OBJ_CYCLES: {t1=1; p1=1; t2=1; p2=1; break;}
	      }
	      
	      if (t1==1) {t1=_time(3, 0, "00:00", MathFloor(reGper/2), "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,0,t1);}
	      if (t2==1) {t2=_time(3, 0, "00:00", 1, "", 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false); ObjectSetInteger(ObjChartID,name,OBJPROP_TIME,1,t2);}
	      if (p1==1) {p1=_value(meanPrice); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,0,p1);}
	      if (p2==1) {p2=_value(meanPrice + meanPrice* slope * (1-MathFloor(reGper/2))); ObjectSetDouble(ObjChartID,name,OBJPROP_PRICE,1,p2);}
	      
	      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);
	      
	      ObjectSetDouble(ObjChartID,name,OBJPROP_ANGLE,ObjAngle);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY,ObjRay);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_LEFT,ObjRayLeft);
	      ObjectSetInteger(ObjChartID,name,OBJPROP_RAY_RIGHT,ObjRayRight);
	      
	      ChartRedraw();
	   }
	}
	block246(244);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #245 (Custom MQL5 code) //
void block245(int _parent_=0)
{
	if (block245==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=245;

	ChartRedraw(ChartID());
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #246 (Pass) //
void block246(int _parent_=0)
{
	if (block246==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=246;

	
	
		// (adjust) Variables
		sumPrice=2;
		dayDrawn=1;
		drawInterval=0;
		setupAge=0;
		// (finish)
	
	block313(246);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #247 (NOT DRAWN) //
void block247(int _parent_=0)
{
	if (block247==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=247;

	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=_value(dayDrawn);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block147(247);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #248 (Condition) //
void block248(int _parent_=0)
{
	if (block248==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=248;

	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=_value(drawInterval);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block34(248);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #249 (Comment) //
void block249(int _parent_=0)
{
	if (block249==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=249;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string Title="Comment Message"; // Comment
	string ObjChartSubWindow=""; // Chart Sub-Window
	int ObjCorner=CORNER_LEFT_UPPER; // Corner
	int ObjX=5; // X coordinate
	int ObjY=24; // Y coordinate
	int ObjFontSize=10; // Font size
	string Label1="drawn"; // Label 1
	string Label2="int"; // Label 2
	string Label3="setup"; // Label 3
	string Label4="bankB"; // Label 4
	string Label5="bankS"; // Label 5
	string Label6="fallError"; // Label 6
	string Label7="riseError"; // Label 7
	string Label8=""; // Label 8
	
	///////////////
	// Main code //
	///////////////
	
	if (!MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_VISUAL_MODE))
	{
	   static bool initialized = false;
	   long ObjChartID   = 0;
	   
	   int ObjAnchor     = ANCHOR_LEFT;
	   if (ObjCorner == CORNER_RIGHT_UPPER || ObjCorner == CORNER_RIGHT_LOWER)
	   {
	      ObjAnchor     = ANCHOR_RIGHT;
	   }
	
	   string namebase = "fxd_cmnt_"+"249";
	   
	   int subwindow = WindowFindVisible(ObjChartID, ObjChartSubWindow);
	
	   if (subwindow >= 0)
	   {
	      //-- draw comment title
	      if ((string)Title != "")
	      {
	         string nametitle = namebase;
	         if(ObjectFind(ObjChartID,nametitle) < 0)
	         {
	            if (!ObjectCreate(ObjChartID,nametitle,OBJ_LABEL,subwindow,0,0,0,0))
	            {
	               Print(__FUNCTION__,": failed to create text object! Error code = ",GetLastError());
	            }
	            else
	            {
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_FONTSIZE,(int)(ObjFontSize*1.3));
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_COLOR,clrGold);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_BACK,0);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_SELECTABLE,1);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_SELECTED,0);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_HIDDEN,1);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_CORNER,ObjCorner);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_ANCHOR,ObjAnchor);
	               
	               ObjectSetString(ObjChartID,nametitle,OBJPROP_FONT,"Georgia");
	               
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_XDISTANCE,ObjX);
	               ObjectSetInteger(ObjChartID,nametitle,OBJPROP_YDISTANCE,ObjY);
	            }
	         }
	         else
	         {
	            ObjX = (int)ObjectGetInteger(ObjChartID, nametitle, OBJPROP_XDISTANCE);
	            ObjY = (int)ObjectGetInteger(ObjChartID, nametitle, OBJPROP_YDISTANCE);
	         }
	         
	         
	         ObjectSetString(ObjChartID,nametitle,OBJPROP_TEXT,(string)Title);
	         
	         ObjY = (int)(ObjY+ObjFontSize*1.3/3);
	      }
	      
	      //-- draw comment rows
	      for (int i=1; i<=8; i++)
	      {
	         string text="";
	         string textlbl="";
	         
	         switch(i)
	         {
	            case 1: if (Label1 != "") { textlbl = Label1; text = (string)_text(dayDrawn); } break;
	            case 2: if (Label2 != "") { textlbl = Label2; text = (string)_text(drawInterval); } break;
	            case 3: if (Label3 != "") { textlbl = Label3; text = (string)_text(setupAge); } break;
	            case 4: if (Label4 != "") { textlbl = Label4; text = (string)_text(buyBank); } break;
	            case 5: if (Label5 != "") { textlbl = Label5; text = (string)_text(sellBank); } break;
	            case 6: if (Label6 != "") { textlbl = Label6; text = (string)_value(errorFall); } break;
	            case 7: if (Label7 != "") { textlbl = Label7; text = (string)_text(errorRise); } break;
	            case 8: if (Label8 != "") { textlbl = Label8; text = (string)_text(""); } break;
	         }
	         
	         string name    = namebase+"_"+(string)i;
	         string namelbl = name+"_l";
	
	         if (textlbl == "")
	         {
	            if (!initialized)
	            {
	               //-- pre-delete
	               ObjectDelete(ObjChartID,namelbl);
	               ObjectDelete(ObjChartID,name);   
	            }
	            
	            continue;
	         }
	
	         //-- draw initial objects
	         if(ObjectFind(ObjChartID, name) < 0)
	         {
	            if (textlbl == "")
	            {
	               continue;
	            }
	            
	            if (ObjectCreate(ObjChartID,namelbl,OBJ_LABEL,subwindow,0,0,0,0))
	            {
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_CORNER,ObjCorner);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_ANCHOR,ObjAnchor);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_BACK,0);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_SELECTABLE,0);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_SELECTED,0);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_HIDDEN,1);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_FONTSIZE,ObjFontSize);
	               ObjectSetInteger(ObjChartID,namelbl,OBJPROP_COLOR,clrDarkGray);
	               ObjectSetString(ObjChartID,namelbl,OBJPROP_FONT,"Verdana");
	            }
	            else
	            {
	               Print(__FUNCTION__,": failed to create text object! Error code = ",GetLastError());
	            }
	            
	            if (ObjectCreate(ObjChartID,name,OBJ_LABEL,subwindow,0,0,0,0))
	            {
	               ObjectSetInteger(ObjChartID,name,OBJPROP_CORNER,ObjCorner);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_ANCHOR,ObjAnchor);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_BACK,0);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTABLE,0);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_SELECTED,0);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_HIDDEN,1);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_FONTSIZE,ObjFontSize);
	               ObjectSetInteger(ObjChartID,name,OBJPROP_COLOR,clrWhite);
	               ObjectSetString(ObjChartID,name,OBJPROP_FONT,"Verdana");
	            }
	            else
	            {
	               Print(__FUNCTION__,": failed to create text object! Error code = ",GetLastError());
	            }
	         }
	         else
	         {
	            if (textlbl == "")
	            {
	               ObjectDelete(ObjChartID,namelbl);
	               ObjectDelete(ObjChartID,name);
	               continue;
	            }
	         }
	         
	         ObjY  = (int)(ObjY + ObjFontSize + ObjFontSize/2);
	         
	         //-- update label objects
	         ObjectSetInteger(ObjChartID,namelbl,OBJPROP_XDISTANCE,ObjX);
	         ObjectSetInteger(ObjChartID,namelbl,OBJPROP_YDISTANCE,ObjY);
	         ObjectSetString(ObjChartID,namelbl,OBJPROP_TEXT,(string)textlbl);
	         
	         //-- update value objects
	         int x=0;
	         int xsizelbl = (int)ObjectGetInteger(ObjChartID, namelbl, OBJPROP_XSIZE);
	         
	         if (xsizelbl == 0) {
	            //-- when the object is newly created, it returns 0 for XSIZE and YSIZE, so here we will trick it somehow
	            xsizelbl = (int)(StringLen((string)textlbl)*ObjFontSize/1.5 + ObjFontSize/2);
	         }
	         
	         x = ObjX+(xsizelbl + ObjFontSize/2);
	         
	         ObjectSetInteger(ObjChartID,name,OBJPROP_XDISTANCE,x);
	         ObjectSetInteger(ObjChartID,name,OBJPROP_YDISTANCE,ObjY);
	         ObjectSetString(ObjChartID,name,OBJPROP_TEXT,(string)text);
	      }
	   }
	   initialized = true;
	}
	
	/* Orange output */
}
string _text(string Text) {
	return(Text);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #250 (Condition&nbsp;) //
void block250(int _parent_=0)
{
	if (block250==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=250;

	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=_value(startP);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {block248(250);} else if (o2==true) {
	
		// (adjust) Variables
		dayDrawn=0;
		// (finish)
	
	/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #251 (Condition) //
void block251(int _parent_=0)
{
	if (block251==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=251;

	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=_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(0);
	   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) {
	
		// (adjust) Variables
		startP=1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #252 (check profit) //
void block252(int _parent_=0)
{
	if (block252==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=252;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string ProfitCheckMode="currency"; // Check mode
	double CurrencyAmount=0; // Amount in deposit currency
	double PercentAccountProfit=50; // % of account profit
	double PercentEquity=5; // % of current Equity
	double PercentBalance=5; // % of current Balance
	double PercentFreeMargin=5; // % of current Free margin
	
	///////////////
	// Main code //
	///////////////
	
	if (FXD_BREAK==true) {return;}
	LoopedResume();
	
	double profit=attrProfit()+attrSwap()+attrCommission();
	double amount=0;
	
	     if (ProfitCheckMode=="currency")     {amount=CurrencyAmount;}
	else if (ProfitCheckMode=="accountprofit"){amount=AccountProfit()*PercentAccountProfit/100;}
	else if (ProfitCheckMode=="equity")       {amount=AccountEquity()*PercentEquity/100;}
	else if (ProfitCheckMode=="balance")      {amount=AccountBalance()*PercentBalance/100;}
	else if (ProfitCheckMode=="freemargin")   {amount=AccountFreeMargin()*PercentFreeMargin/100;}
	
	if (profit>amount) {
	
		// (adjust) Variables
		dayDrawn=0;
		// (finish)
	
	block299(252);} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #253 (Condition) //
void block253(int _parent_=0)
{
	if (block253==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=253;

	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=_value(drawInterval);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block195(253);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #254 (Condition) //
void block254(int _parent_=0)
{
	if (block254==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=254;

	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=_iStdDev(MomenH1, 0, MODE_SMA, PRICE_CLOSE, CurrentSymbol(), PERIOD_H1, 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_iStdDev(MomenH1, 0, MODE_SMA, PRICE_CLOSE, CurrentSymbol(), PERIOD_H1, 2);
	   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) {block255(254);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #255 (Condition) //
void block255(int _parent_=0)
{
	if (block255==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=255;

	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=_fResults(mRel);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MomenH1Factor);
	   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) {
	
		// (adjust) Variables
		dayDrawn=0;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #256 (Condition&nbsp;) //
void block256(int _parent_=0)
{
	if (block256==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=256;

	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(80);
	   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) {
	
		// (adjust) Variables
		trUp=1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {block258(256); block259(256);}
}
double _iStochastic(int Kperiod, int Dperiod, int Slowing, ENUM_MA_METHOD MAmethod, ENUM_STO_PRICE PriceField, int Mode, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iStochastic(SYMBOL,TIMEFRAME,Kperiod,Dperiod,Slowing,MAmethod,PriceField),Mode,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #257 (Pass) //
void block257(int _parent_=0)
{
	if (block257==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=257;

	block256(257);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #258 (Condition&nbsp;) //
void block258(int _parent_=0)
{
	if (block258==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=258;

	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(20);
	   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) {
	
		// (adjust) Variables
		trDn=1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #259 (Condition&nbsp;) //
void block259(int _parent_=0)
{
	if (block259==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=259;

	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(50);
	   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) {block69(259);} else if (o2==true) {block260(259);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #260 (GA &nbsp; &nbsp;TE) //
void block260(int _parent_=0)
{
	if (block260==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=260;

	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=_value(trDn);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {
	
		// (adjust) Variables
		trDn=0;
		sellBank=sellBank+1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #261 (REAL RISE) //
void block261(int _parent_=0)
{
	if (block261==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=261;

	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=_value(actualRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block267(261);} else if (o2==true) {block265(261);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #262 (REAL FALL) //
void block262(int _parent_=0)
{
	if (block262==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=262;

	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=_value(actualFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block266(262);} else if (o2==true) {block264(262);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #263 (PASS THESE FIRST) //
void block263(int _parent_=0)
{
	if (block263==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=263;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block257(263);}
	block261(263); block262(263);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #264 (Pass) //
void block264(int _parent_=0)
{
	if (block264==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=264;

	
	
		// (adjust) Variables
		sellBank=0;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #265 (Pass) //
void block265(int _parent_=0)
{
	if (block265==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=265;

	
	
		// (adjust) Variables
		buyBank=0;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #266 (Condition) //
void block266(int _parent_=0)
{
	if (block266==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=266;

	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=_value(setupAge);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(minSetupA);
	   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) {block277(266); block316(266);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #267 (Condition) //
void block267(int _parent_=0)
{
	if (block267==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=267;

	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=_value(setupAge);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(minSetupA);
	   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) {block273(267); block317(267);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #272 (Condition) //
void block272(int _parent_=0)
{
	if (block272==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=272;

	int crossover=1;
	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=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISEtgt", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {
	
		// (adjust) Variables
		closeType=1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #273 (BuyRun) //
void block273(int _parent_=0)
{
	if (block273==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=273;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block272(273);} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #277 (SellRun) //
void block277(int _parent_=0)
{
	if (block277==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=277;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block278(277);} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #278 (Condition) //
void block278(int _parent_=0)
{
	if (block278==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=278;

	int crossover=1;
	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=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALLtgt", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {
	
		// (adjust) Variables
		closeType=-1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #282 (PASS THESE FIRST) //
void block282(int _parent_=0)
{
	if (block282==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=282;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block263(282);}
	block283(282);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #283 (Condition) //
void block283(int _parent_=0)
{
	if (block283==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=283;

	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=_value(closeType);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block284(283);} else if (o2==true) {block287(283);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #284 (Condition) //
void block284(int _parent_=0)
{
	if (block284==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=284;

	int crossover=1;
	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=_iSAR(step, stop, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   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) {block285(284);} else if (o2==true) {/* Yellow output */}
}
double _iSAR(double Step, double Maximum, string SYMBOL, ENUM_TIMEFRAMES TIMEFRAME, int SHIFT) {
	SHIFT=SHIFT+IndicatorMoreShift();
	double retval=IndicatorGetValue(iSAR(SYMBOL,TIMEFRAME,Step,Maximum),0,SHIFT);
	SetLastIndicatorData(retval,SYMBOL,TIMEFRAME,SHIFT);
	return(retval);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #285 (Close positions) //
void block285(int _parent_=0)
{
	if (block285==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=285;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	int OrderMinutes=0; // Only older than
	double Deviation=4; // Deviation
	
	///////////////
	// Main code //
	///////////////
	
	int closed_count=0;
	bool finished=false;
	while (finished==false) {
	   int count=0;
	   int total=PositionsTotal();
	   for (int pos=total-1; pos>=0; pos--) {
	      if (LoadOrder(GetOrderSymbol(pos))) {
	         if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	            datetime time_diff = TimeCurrent()-attrOpenTime();
	            if (time_diff < 0) {time_diff = 0;} // this actually happens sometimes
	            if (time_diff >= 60*OrderMinutes)
	            {
	               int success = CloseOrder(attrSymbol(),Deviation);
	               if (success) {
	                  closed_count++;
	               }
	               else {Print("Position close problem :(");}
	               count++;
	            }
	         }
	      }
	   }
	   if (count==0) {finished=true;}
	}
	
	block289(285);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #286 (Condition) //
void block286(int _parent_=0)
{
	if (block286==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=286;

	int crossover=1;
	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=_iSAR(step, stop, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_candles("iClose", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   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) {block288(286);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #287 (Condition) //
void block287(int _parent_=0)
{
	if (block287==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=287;

	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=_value(closeType);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(-1);
	   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) {block286(287);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #288 (Close positions) //
void block288(int _parent_=0)
{
	if (block288==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=288;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	int OrderMinutes=0; // Only older than
	double Deviation=4; // Deviation
	
	///////////////
	// Main code //
	///////////////
	
	int closed_count=0;
	bool finished=false;
	while (finished==false) {
	   int count=0;
	   int total=PositionsTotal();
	   for (int pos=total-1; pos>=0; pos--) {
	      if (LoadOrder(GetOrderSymbol(pos))) {
	         if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	            datetime time_diff = TimeCurrent()-attrOpenTime();
	            if (time_diff < 0) {time_diff = 0;} // this actually happens sometimes
	            if (time_diff >= 60*OrderMinutes)
	            {
	               int success = CloseOrder(attrSymbol(),Deviation);
	               if (success) {
	                  closed_count++;
	               }
	               else {Print("Position close problem :(");}
	               count++;
	            }
	         }
	      }
	   }
	   if (count==0) {finished=true;}
	}
	
	block289(288);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #289 (Pass) //
void block289(int _parent_=0)
{
	if (block289==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=289;

	
	
		// (adjust) Variables
		closeType=0;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #291 (SWEETSP&nbsp;<br>) //
void block291(int _parent_=0)
{
	if (block291==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=291;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISE3", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block292(291);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #292 (SWEETSP) //
void block292(int _parent_=0)
{
	if (block292==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=292;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block295(292);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #293 (SWEETSP&nbsp;<br>) //
void block293(int _parent_=0)
{
	if (block293==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=293;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALL1", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block294(293);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #294 (SWEETSP) //
void block294(int _parent_=0)
{
	if (block294==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=294;

	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=_candles("iMedian", "id", 1, "00:00", CurrentSymbol(), CurrentTimeframe());
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_OBJECT("name", "FALL2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, 1);
	   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) {block297(294);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #295 (Condition) //
void block295(int _parent_=0)
{
	if (block295==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=295;

	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=(_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1)*-1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=(_value(stLevel)-100);
	   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) {block296(295);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #296 (Condition) //
void block296(int _parent_=0)
{
	if (block296==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=296;

	int crossover=1;
	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_iStochastic(kk, dd, ss, MODE_SMA, 0, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   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) {block70(296);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #297 (Condition) //
void block297(int _parent_=0)
{
	if (block297==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=297;

	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(stLevel);
	   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) {block298(297);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #298 (Condition) //
void block298(int _parent_=0)
{
	if (block298==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=298;

	int crossover=1;
	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=_iStochastic(kk, dd, ss, MODE_SMA, 0, 1, CurrentSymbol(), CurrentTimeframe(), 1);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_iStochastic(kk, dd, ss, MODE_SMA, 0, 0, CurrentSymbol(), CurrentTimeframe(), 1);
	   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) {block75(298);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #299 (Pass&nbsp;) //
void block299(int _parent_=0)
{
	if (block299==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=299;

	
	
		// (adjust) Variables
		anchorH=confirmedHAGE;
		anchorL=confirmedLAGE;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #300 (Loop (pass "n" times)) //
void block300(int _parent_=0)
{
	if (block300==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=300;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=reGper; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	// (adjust) Variables
	loopId=reGper;
	errorSum=0;
	// (finish)
	
	for (int i=1; i<=Cycles; i++) {block301(300);}
	block303(300);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #301 (Formula&nbsp;) //
void block301(int _parent_=0)
{
	if (block301==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=301;

	double Lo=_iMA(regMa, 0, MODE_LWMA, PRICE_CLOSE, CurrentSymbol(), CurrentTimeframe(), loopId);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_OBJECT("name", "RISE2", OBJPROP_TL_PRICE_BY_SHIFT, 0, 1.2, loopId);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	dev1=(Lo - Ro);
	
	block302(301);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #302 (Custom MQL5 code) //
void block302(int _parent_=0)
{
	if (block302==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=302;

	dev1 = MathAbs(dev1);
	
	
		// (adjust) Variables
		errorSum=errorSum + dev1;
		// (finish)
	
	/* Orange output */
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #303 (Formula) //
void block303(int _parent_=0)
{
	if (block303==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=303;

	double Lo=_value(errorSum);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_value(MathPow(reGper,0.5));
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	stdDEV=(Lo / Ro);
	
	
	
		// (adjust) Variables
		errorRise=stdDEV;
		// (finish)
	
	block304(303);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #304 (Formula) //
void block304(int _parent_=0)
{
	if (block304==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=304;

	double Lo=_fResults(stdDEV);
	if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	
	double Ro=_fResults(atr2);
	if (MathAbs(Ro) == EMPTY_VALUE) {return;}
	
	RelDev=(Lo / Ro);
	
	block306(304);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #305 (PASS THESE FIRST) //
void block305(int _parent_=0)
{
	if (block305==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=305;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {
	
		// (adjust) Variables
		sumPrice=1;
		// (finish)
	
	block313(305);}
	block242(305);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #306 (ERROR FALL) //
void block306(int _parent_=0)
{
	if (block306==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=306;

	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=_value(sumPrice);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {
	
		// (adjust) Variables
		errorFall=RelDev;
		// (finish)
	
	block308(306);} else if (o2==true) {block307(306);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #307 (ERROR RISE&nbsp;<br>) //
void block307(int _parent_=0)
{
	if (block307==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=307;

	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=_value(sumPrice);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(2);
	   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) {
	
		// (adjust) Variables
		errorRise=RelDev;
		// (finish)
	
	block309(307);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #308 (Condition) //
void block308(int _parent_=0)
{
	if (block308==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=308;

	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=_value(errorFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MIN_ACCURACY);
	   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) {
	
		// (adjust) Variables
		anchorH=anchorH*DECF;
		// (finish)
	
	block311(308);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #309 (Condition) //
void block309(int _parent_=0)
{
	if (block309==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=309;

	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=_value(errorRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MIN_ACCURACY);
	   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) {
	
		// (adjust) Variables
		anchorL=anchorL*DECF;
		// (finish)
	
	block311(309);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #311 (Once per bar) //
void block311(int _parent_=0)
{
	if (block311==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=311;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string SYMBOL=CurrentSymbol(); // Market
	ENUM_TIMEFRAMES TIMEFRAME=CurrentTimeframe(); // Timeframe
	int PassMaxTimes=1; // Max. times to pass
	
	///////////////
	// Main code //
	///////////////
	
	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;
	   }
	   block315(311);
	}
	else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #313 (Condition) //
void block313(int _parent_=0)
{
	if (block313==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=313;

	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=_value(reGper);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(minP);
	   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) {block300(313);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #315 (PTF) //
void block315(int _parent_=0)
{
	if (block315==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=315;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	int Cycles=1; // Cycles
	
	///////////////
	// Main code //
	///////////////
	
	for (int i=1; i<=Cycles; i++) {block241(315);}
	
	
		// (adjust) Variables
		FailedDraws=FailedDraws+1;
		// (finish)
	
	block329(315);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #316 (Condition) //
void block316(int _parent_=0)
{
	if (block316==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=316;

	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=_value(errorFall);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MIN_ACCURACY);
	   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) {block293(316);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #317 (Condition) //
void block317(int _parent_=0)
{
	if (block317==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=317;

	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=_value(errorRise);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(MIN_ACCURACY);
	   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) {block291(317);} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #318 (BuyRun) //
void block318(int _parent_=0)
{
	if (block318==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=318;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="buys"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block323(318);} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #322 (SellRun) //
void block322(int _parent_=0)
{
	if (block322==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=322;

	//////////////////////
	// Input parameters //
	//////////////////////
	
	string OrdersScope="all"; // Group mode
	string OrdersGroup=""; // Group # (empty=Default)
	string SymbolScope="symbol"; // Market mode
	string SYMBOL=CurrentSymbol(); // Market
	string BuysOrSells="sells"; // Filter by type
	
	///////////////
	// Main code //
	///////////////
	
	bool exist=false;
	for (int pos=PositionsTotal()-1; pos>=0; pos--) {
	   if (LoadOrder(PositionGetSymbol(pos))) {
	      if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
	         exist=true; break;
	      }
	   }
	}
	
	if (exist==true) {block324(322);} else {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #323 (Condition) //
void block323(int _parent_=0)
{
	if (block323==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=323;

	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=_value(drawInterval);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(REinterval);
	   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) {
	
		// (adjust) Variables
		dayDrawn=0;
		onlyThis=-1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #324 (Condition) //
void block324(int _parent_=0)
{
	if (block324==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=324;

	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=_value(drawInterval);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(REinterval);
	   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) {
	
		// (adjust) Variables
		dayDrawn=0;
		onlyThis=1;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #327 (Condition) //
void block327(int _parent_=0)
{
	if (block327==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=327;

	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=_value(onlyThis);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(1);
	   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) {block239(327);} else if (o2==true) {block305(327);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #328 (Condition) //
void block328(int _parent_=0)
{
	if (block328==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=328;

	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=_value(onlyThis);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(-1);
	   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) {block244(328);} else if (o2==true) {block246(328);}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// fxDreema block #329 (Condition&nbsp;) //
void block329(int _parent_=0)
{
	if (block329==false || FXD_BREAK==true) {return;}
	FXD_CURRENT_FUNCTION_ID=329;

	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=_value(FailedDraws);
	   if (MathAbs(Lo) == EMPTY_VALUE) {return;}
	   
	   // Right operand of the condition
	   IndicatorMoreShift(true,i*crosswidth);
	   double Ro=_value(failsRow);
	   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) {
	
		// (adjust) Variables
		anchorH=confirmedHAGE;
		anchorL=confirmedLAGE;
		// (finish)
	
	/* Orange output */} else if (o2==true) {/* Yellow output */}
}


/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// |                                                  API FUNCTIONS                                                   | //
// |                                 System and Custom functions used in the program                                  | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/

// System functions
double AccountBalance() {return(AccountInfoDouble(ACCOUNT_BALANCE));}
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);
}
double AccountEquity() {return(AccountInfoDouble(ACCOUNT_EQUITY));}
double AccountFreeMargin() {return(AccountInfoDouble(ACCOUNT_FREEMARGIN));}
double AccountProfit() {return(AccountInfoDouble(ACCOUNT_PROFIT));}
double AlignLots(double lots, double lowerlots=0, double upperlots=0)
{
   string symbol=GetSymbol();

   double LotStep=SymbolLotStep(symbol);
   double LotSize=SymbolLotSize(symbol);
   double MinLots=SymbolMinLot(symbol);
   double MaxLots=SymbolMaxLot(symbol);
   
   //if (lots>MaxLots) {lots=lots/LotSize;}
   
   //double stepsize=0;
   //while(lots+0.000000001>stepsize){stepsize+=LotStep;}
   //lots=stepsize-LotStep;
   lots=MathRound(lots/LotStep)*LotStep;
   
   if (lots<MinLots) {lots=MinLots;}
   if (lots>MaxLots) {lots=MaxLots;}
   
   if (lowerlots > 0)
   {
      lowerlots = MathRound(lowerlots/LotStep)*LotStep;
      if (lots < lowerlots) {lots = lowerlots;}
   }
   if (upperlots > 0)
   {
      upperlots = MathRound(upperlots/LotStep)*LotStep;
      if (lots > upperlots) {lots = upperlots;}
   }

   return (lots);
}
double AlignStopLoss(
   string symbol,
   int type,
   double price,
   double sll=0,
   double slp=0,
   bool consider_freezelevel=false
   )
{
   double sl=0;
   
   if (MathAbs(sll)==EMPTY_VALUE) {sll=0;}
   if (MathAbs(slp)==EMPTY_VALUE) {slp=0;}
   if (sll==0 && slp==0) {return(0);} // no sl - return 0
   if (price<=0) {Print("AlignStopLoss() error: No price entered");return(-1);}
   
   double point   =SymbolInfoDouble(symbol,SYMBOL_POINT);
   int digits     =(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
   slp=slp*PipValue(symbol)*point;

   //-- buy-sell identifier ---------------------------------------------
   int bs=1;
   if (
      type==ORDER_TYPE_BUY
      || type==ORDER_TYPE_BUY_STOP
      || type==ORDER_TYPE_BUY_LIMIT
      || type==ORDER_TYPE_BUY_STOP_LIMIT
      )
   {
      bs=1;
   }
   else if (
      type==ORDER_TYPE_SELL
      || type==ORDER_TYPE_SELL_STOP
      || type==ORDER_TYPE_SELL_LIMIT
      || type==ORDER_TYPE_SELL_STOP_LIMIT
      )
   {
      bs=-1;
   }
   
   //-- prices that will be used ----------------------------------------
   double askbid=price;
   double bidask=price;
   
   if (type==ORDER_TYPE_BUY || type==ORDER_TYPE_SELL)
   {
      double ask =SymbolInfoDouble(symbol,SYMBOL_ASK);
      double bid =SymbolInfoDouble(symbol,SYMBOL_BID);
      
      askbid=ask;
      bidask=bid;
      if (bs<0) {
        askbid=bid;
        bidask=ask;
      }
   }
   
   //-- build sl level -------------------------------------------------- 
   if (sll==0 && slp!=0) {sll=price;}
   
   if (sll>0) {sl=sll-slp*bs;}
   
   if (sl<0) {return(-1);}
      
   sl=NormalizeDouble(sl,digits);
   
   //-- build limit levels ----------------------------------------------
   double minstops=(double)SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL);
   if (consider_freezelevel==true) {
      double freezelevel=(double)SymbolInfoInteger(symbol,SYMBOL_TRADE_FREEZE_LEVEL);
      if (freezelevel>minstops) {minstops=freezelevel;}
   }
   minstops=NormalizeDouble(minstops*point,digits);
      
   double sllimit=bidask-minstops*bs; // SL min price level
   
   //-- check and align sl, print errors --------------------------------
   if (sl>0) {
      /*if (sl==askbid)
      {
         sl=0;
      }
      else */
      if ((bs>0 && sl>askbid) || (bs<0 && sl<askbid))
      {
         string abstr="";
         if (bs>0) {abstr="Ask";} else {abstr="Bid";}
         Print(
            "Error: Invalid SL requested (",
            DoubleToStr(sl,digits),
            " for ",abstr," price ",
            askbid,
            ")"
            );
         return(-1);
      }
      else if ((bs>0 && sl>sllimit) || (bs<0 && sl<sllimit))
      {
         Print(
            "Warning: Too short SL requested (",
            DoubleToStr(sl,digits),
            " or ",
            DoubleToStr(MathAbs(sl-askbid)/point,0),
            " points), minimum will be taken (",
            DoubleToStr(sllimit,digits),
            " or ",
            DoubleToStr(MathAbs(askbid-sllimit)/point,0),
            " points)"
         );
         sl=sllimit;
         return(sl);
      }
   }
   return(sl);
}
double AlignTakeProfit(
   string symbol,
   int type,
   double price,
   double tpl=0,
   double tpp=0,
   bool consider_freezelevel=false
   )
{
   double tp=0;
   
   if (MathAbs(tpl)==EMPTY_VALUE) {tpl=0;}
   if (MathAbs(tpp)==EMPTY_VALUE) {tpp=0;}
   if (tpl==0 && tpp==0) {return(0);} // no tp - return 0
   if (price<=0) {Print("AlignTakeProfit() error: No price entered");return(-1);}

   double point   =SymbolInfoDouble(symbol,SYMBOL_POINT);
   int digits     =(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
   tpp=tpp*PipValue(symbol)*point;
   
   //-- buy-sell identifier ---------------------------------------------
   int bs=1;
   if (
      type==ORDER_TYPE_BUY
      || type==ORDER_TYPE_BUY_STOP
      || type==ORDER_TYPE_BUY_LIMIT
      || type==ORDER_TYPE_BUY_STOP_LIMIT
      )
   {
      bs=1;
   }
   else if (
      type==ORDER_TYPE_SELL
      || type==ORDER_TYPE_SELL_STOP
      || type==ORDER_TYPE_SELL_LIMIT
      || type==ORDER_TYPE_SELL_STOP_LIMIT
      )
   {
      bs=-1;
   }
   
   //-- prices that will be used ----------------------------------------
   double askbid=price;
   double bidask=price;
   
   if (type==ORDER_TYPE_BUY || type==ORDER_TYPE_SELL)
   {
      double ask =SymbolInfoDouble(symbol,SYMBOL_ASK);
      double bid =SymbolInfoDouble(symbol,SYMBOL_BID);
      
      askbid=ask;
      bidask=bid;
      if (bs<0) {
        askbid=bid;
        bidask=ask;
      }
   }
   
   //-- build tp level --------------------------------------------------- 
   if (tpl==0 && tpp!=0) {tpl=price;}

   if (tpl>0) {tp=tpl+tpp*bs;}
   
   if (tp<0) {return(-1);}

   tp=NormalizeDouble(tp,digits);
   
   //-- build limit levels ----------------------------------------------
   double minstops=(double)SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL);
   if (consider_freezelevel==true) {
      double freezelevel=(double)SymbolInfoInteger(symbol,SYMBOL_TRADE_FREEZE_LEVEL);
      if (freezelevel>minstops) {minstops=freezelevel;}
   }
   minstops=NormalizeDouble(minstops*point,digits);
   
   double tplimit=bidask+minstops*bs; // TP min price level
   
   //-- check and align tp, print errors --------------------------------
   if (tp>0) {
      /*if (tp==askbid)
      {
         tp=0;
      }
      else */
      if ((bs>0 && tp<askbid) || (bs<0 && tp>askbid))
      {
         string abstr="";
         if (bs>0) {abstr="Ask";} else {abstr="Bid";}
         Print(
            "Error: Invalid TP requested (",
            DoubleToStr(tp,digits),
            " for ",abstr," price ",
            askbid,
            ")"
            );
         return(-1);
      }
      else if ((bs>0 && tp<tplimit) || (bs<0 && tp>tplimit))
      {
         Print(
            "Warning: Too short TP requested (",
            DoubleToStr(tp,digits),
            " or ",
            DoubleToStr(MathAbs(tp-askbid)/point,0),
            " points), minimum will be taken (",
            DoubleToStr(tplimit,digits),
            " or ",
            DoubleToStr(MathAbs(askbid-tplimit)/point,0),
            " points)"
         );
         tp=tplimit;
         return(tp);
      }
   }
   return(tp);
}
int ArraySearch(int &array[], int value)
{
   bool founded=false;
   int index=-1;
   int size=ArraySize(array);
   if (size>0)
   {
      for (int i=0; i<size; i++) {
         if (array[i]==value) {
            founded=true;
            index=i;
            break;
         }  
   	}
   }
   if (founded==true) {return (index);} else {return (-1);}
}
int ArraySearch(double &array[], double value)
{
   bool founded=false;
   int index=-1;
   int size=ArraySize(array);
   if (size>0)
   {
      for (int i=0; i<size; i++) {
         if (array[i]==value) {
            founded=true;
            index=i;
            break;
         }  
      }
   }
   if (founded==true) {return (index);} else {return (-1);}
}
int ArraySearch(string &array[], string value)
{
   bool founded=false;
   int index=-1;
   int size=ArraySize(array);
   if (size>0)
   {
      for (int i=0; i<size; i++) {
         if (array[i]==value) {
            founded=true;
            index=i;
            break;
         }  
      }
   }
   if (founded==true) {return (index);} else {return (-1);}
}
bool ArrayStrip(int &array[], int value)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (array[i]!=value)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayStrip(double &array[], double value)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (array[i]!=value)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayStrip(string &array[], string value)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (array[i]!=value)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayStripKey(double &array[], double key)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (i!=key)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayStripKey(int &array[], int key)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (i!=key)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayStripKey(string &array[], int key)
{
   bool stripped=false;
   int size=ArraySize(array);
   if (size>0)
   {
      int i=0; int x=0;
      for (i=0; i<size; i++)
      {
         if (i!=key)
         {
            array[x]=array[i];
            x++;
         } else {
            stripped=true;  
         }
      }
      ArrayResize(array,x);
   }
   return (stripped);
}
bool ArrayValue(int &array[], int value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}
   }
   if (founded==false) {
      ArrayResize(array,size+1);
      array[size]=value;
      return (true);
   } else {
      return (false);  
   }
}
bool ArrayValue(double &array[], double value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}
   }
   if (founded==false) {
      ArrayResize(array,size+1);
      array[size]=value;
      return (true);
   } else {
      return (false);  
   }
}
bool ArrayValue(string &array[], string value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}
   }
   if (founded==false) {
      ArrayResize(array,size+1);
      array[size]=value;
      return (true);
   } else {
      return (false);  
   }
}
double Bet1326(string group, string symbol, double initial_lots, bool reverse=false)
{  
   int pos=0;
   int total=0;
   double lots=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
   
         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }
         
         if (profit<0) {profit_or_loss=-1;}
         else {profit_or_loss=1;}
         
         break;
      }
   }
   
   //--
   if (initial_lots < SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN)) {
      initial_lots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);  
   }

   if (lots==0) {lots = initial_lots;}
   else
   {
      if ((reverse==false && profit_or_loss==1) || (reverse==true && profit_or_loss==-1))
      {
         double div = lots/initial_lots;
         
         if (div < 1.5) {lots = initial_lots*3;}
         else if (div < 2.5) {lots = initial_lots*6;}
         else if (div < 3.5) {lots = initial_lots*2;}
         else {lots = initial_lots;}
      }
      else {
         lots = initial_lots;
      }
   }
   
   return lots;
}
double BetDalembert(string group, string symbol, double initial_lots, double reverse=false)
{  
   int pos=0;
   int total=0;
   double lots=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
   
         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }
         
         if (profit<0) {profit_or_loss=-1;}
         else {profit_or_loss=1;}
         
         break;
      }
   }
   
   //--
   if (initial_lots < SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN)) {
      initial_lots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);  
   }

   if (lots==0) {lots = initial_lots;}
   else
   {
      if ((reverse==0 && profit_or_loss==1) || (reverse==1 && profit_or_loss==-1))
      {
         lots = lots - initial_lots;
         if (lots < initial_lots) {lots = initial_lots;}
      }
      else {
         lots = lots + initial_lots;
      }
   }
   
   return lots;
}
double BetFibonacci(
   string group,
   string symbol,
   double initial_lots
   )
{
   int pos=0;
   int total=0;
   double lots=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
   
         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }
         
         if (profit<0) {profit_or_loss=-1;}
         else {profit_or_loss=1;}
         
         break;
      }
   }
   
   //--
   if (initial_lots < SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN)) {
      initial_lots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);  
   }

   if (lots==0) {lots = initial_lots;}
   else
   {  
      int fibo1=1, fibo2=0, fibo3=0, fibo4=0;
      double div = lots/initial_lots;
      
      if (div<=0) {div=1;}

      while(true)
      {
         fibo1=fibo1+fibo2;
         fibo3=fibo2;
         fibo2=fibo1-fibo2;
         fibo4=fibo2-fibo3;
         if (fibo1 > NormalizeDouble(div, 2)) {break;}
      }
      //Print("("+fibo1 + "+" + fibo2+"+"+fibo3+") > "+div);
      if (profit_or_loss==1)
      {
         if (fibo4<=0) {fibo4=1;}
         //Print("Profit "+lots+"*"+fibo4);
         lots=initial_lots*(fibo4);
      }
      else {
         //Print("Loss "+lots+"*"+fibo1+"+"+fibo2);
         lots=initial_lots*(fibo1);
      }
   }
   
   lots=NormalizeDouble(lots, 2);
   return lots;
}
double BetLabouchere(string s_group, string symbol, double initial_lots, string list_of_numbers, double reverse=false)
{   
   int group = (int)StringToInteger(s_group);
   
   int pos=0;
   int total=0;
   double lots=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
   
         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }

         if (profit<0) {profit_or_loss=-1;}
         else {profit_or_loss=1;}
         
         break;
      }
   }
   
   //-- Labouchere stuff
   static int mem_group[];
   static string mem_list[];
   static int mem_ticket[];
   int start_again=false;
   
   //- get the list of numbers as it is stored in the memory, or store it
   int id=ArraySearch(mem_group, group);
   if (id == -1) {
      start_again=true;
      if (list_of_numbers=="") {list_of_numbers="1";}
      id = ArraySize(mem_group);
      ArrayResize(mem_group, id+1, id+1);
      ArrayResize(mem_list, id+1, id+1);
      ArrayResize(mem_ticket, id+1, id+1);
      mem_group[id]=group;
      mem_list[id]=list_of_numbers;
   }

   if (mem_ticket[id]==(int)OrderTicket()) {
      // the last known ticket (mem_ticket[id]) should be different than OderTicket() normally
      // when failed to create a new trade - the last ticket remains the same
      // so we need to reset
      mem_list[id]=list_of_numbers;
   }
   mem_ticket[id]=(int)OrderTicket();
   
   //- now turn the string into integer array
   int list[];
   string listS[];
   StringExplode(",", mem_list[id], listS);
   ArrayResize(list, ArraySize(listS), ArraySize(listS));
   for (int s=0; s<ArraySize(listS); s++) {
      list[s]=(int)StringToInteger(StringTrim(listS[s]));  
   }

   //-- 
   int size = ArraySize(list);

   if (initial_lots < SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN)) {
      initial_lots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);  
   }

   if (lots==0) {
      start_again=true;
   }
   
   if (start_again==true)
   {
      if (size==1) {
         lots = initial_lots*list[0];
      } else {
         lots = initial_lots*(list[0]+list[size-1]);
      }
   }
   else 
   {
      if ((reverse==0 && profit_or_loss==1) || (reverse==1 && profit_or_loss==-1))
      {
         if (size==1) {
            lots=initial_lots*list[0];
            ArrayResize(list, 0, 0);
         }
         else if (size==2) {
            lots = initial_lots*(list[0]+list[1]);
            ArrayResize(list, 0, 0);
         }
         else if (size>2) {
            lots = initial_lots*(list[0]+list[size-1]);
            // Cancel first and last numbers in our list
            // shift array 1 step left
            for(pos=0; pos<size-1; pos++) {
               list[pos]=list[pos+1];
            }
            ArrayResize(list,ArraySize(list)-2, ArraySize(list)-2); // remove last 2 elements   	
         }
         if (lots < initial_lots) {lots = initial_lots;}
      }
      else {
         if (size>1)
         {
            ArrayResize(list, size+1, size+1);
            list[size]=list[0]+list[size-1];
            lots = initial_lots*(list[0]+list[size]);
         } else {
            lots = initial_lots*list[0];
         }
         if (lots < initial_lots) {lots = initial_lots;}
      }

   }
   
   Print("Labouchere (for group "+(string)id+") current list of numbers:"+StringImplode(",", list));
   size=ArraySize(list);
   if (size==0) {
      ArrayStripKey(mem_group, id);
      ArrayStripKey(mem_list, id);
      ArrayStripKey(mem_ticket, id);
   } else {
      mem_list[id]=StringImplode(",", list);
   }

   return lots;
}
double BetMartingale(
   string group,
   string symbol,
   double initial_lots,
   double multiply_on_loss,
   double multiply_on_profit,
   double add_on_loss,
   double add_on_profit,
   int reset_on_loss,
   int reset_on_profit
   )
{
   int pos=0;
   int total=0;
   double lots=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   int in_a_row=0;
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
      in_a_row++;
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}

         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }
         
         if (profit_or_loss == 0)
         {
            if (profit<0) {profit_or_loss=-1;}
            else {profit_or_loss=1;}
         }
         else {
                 if (profit_or_loss==1 && profit<0) {break;}
            else if (profit_or_loss==-1 && profit>=0) {break;}
         }
         
         in_a_row++;
      }
   }

   if (lots==0) {lots = initial_lots;}
   else {
      if (profit_or_loss==1)
      {
         if (reset_on_profit>0 && in_a_row >= reset_on_profit) {
            lots=initial_lots;  
         }
         else {
            if (multiply_on_profit<=0) {multiply_on_profit=1;}
            lots=(lots*multiply_on_profit) + add_on_profit;
         }
      }
      else {
         if (reset_on_loss>0 && in_a_row >= reset_on_loss) {
            lots=initial_lots;  
         }
         else {
            if (multiply_on_loss<=0) {multiply_on_loss=1;}
            lots=(lots*multiply_on_loss) + add_on_loss;
         }
      }
   }
   
   return lots;
}
double BetSequence(string s_group, string symbol, double initial_lots, string sequence_on_loss, string sequence_on_profit, bool reverse=false)
{
   int group = (int)StringToInteger(s_group);
   
   int pos=0;
   int total=0;
   double lots=0;
   int size=0;
   double profit=0;
   int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
   
   //-- try to get last lot size from running trades
   if (LoadOrder(symbol)) {
      lots=attrLots();
   }
   
   //-- if no running trade was found, search in history trades
   if (lots==0)
   {
      HistorySelect(0,TimeCurrent());
      total=HistoryDealsTotal();
      
      for (pos=total-1; pos>=0; pos--)
      {
         if (!LoadHistoryOrder(pos,"select_by_pos")) {continue;}
         if (LoadedType()!=3) {continue;}
         //if (OrderMagicNumber() != MagicStart+group) {continue;}
         if (OrderSymbol() != symbol) {continue;}
         if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
   
         if (lots==0) {
            lots=OrderLots();
         }
         
         profit = OrderClosePrice()-OrderOpenPrice();
         profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
         if (IsOrderTypeSell()) {profit = -1*profit;}
         if (profit == 0) {
            return(lots);
         }
   
         if (profit<0) {profit_or_loss=-1;}
         else {profit_or_loss=1;}
         
         break;
      }
   }
   
   //-- Sequence stuff
   static int mem_group[];
   static string mem_list_loss[];
   static string mem_list_profit[];
   static int mem_ticket[];
   
   //- get the list of numbers as it is stored in the memory, or store it
   int id=ArraySearch(mem_group, group);
   if (id == -1)
   {
      if (sequence_on_loss=="") {sequence_on_loss="1";}
      if (sequence_on_profit=="") {sequence_on_profit="1";}
      id = ArraySize(mem_group);
      ArrayResize(mem_group, id+1, id+1);
      ArrayResize(mem_list_loss, id+1, id+1);
      ArrayResize(mem_list_profit, id+1, id+1);
      ArrayResize(mem_ticket, id+1, id+1);
      mem_group[id]        =group;
      mem_list_loss[id]    =sequence_on_loss;
      mem_list_profit[id]  =sequence_on_profit;
   }
   
   bool loss_reset=false;
   bool profit_reset=false;
   if (profit_or_loss==-1 && mem_list_loss[id]=="") {
      loss_reset=true;
      mem_list_profit[id]="";
   }
   if (profit_or_loss==1 && mem_list_profit[id]=="") {
      profit_reset=true;
      mem_list_loss[id]="";
   }
   
   if (profit_or_loss==1 || mem_list_loss[id]=="") {
      mem_list_loss[id]=sequence_on_loss;
      if (loss_reset) {mem_list_loss[id]="1,"+mem_list_loss[id];}
      
   }
   if (profit_or_loss==-1 ||mem_list_profit[id]=="") {
      mem_list_profit[id]=sequence_on_profit;
      if (profit_reset) {mem_list_profit[id]="1,"+mem_list_profit[id];}
   }
   
   if (mem_ticket[id]==(int)OrderTicket()) {
      // the last known ticket (mem_ticket[id]) should be different than OderTicket() normally
      // when failed to create a new trade - the last ticket remains the same
      // so we need to reset
      mem_list_loss[id]=sequence_on_loss;
      mem_list_profit[id]=sequence_on_profit;
   }
   mem_ticket[id]=(int)OrderTicket();
   
   //- now turn the string into integer array
   int s=0;
   int list_loss[];
   int list_profit[];
   string listS[];
   StringExplode(",", mem_list_loss[id], listS);
   ArrayResize(list_loss, ArraySize(listS), ArraySize(listS));
   for (s=0; s<ArraySize(listS); s++) {
      list_loss[s]=(int)StringToInteger(StringTrim(listS[s]));  
   }
   StringExplode(",", mem_list_profit[id], listS);
   ArrayResize(list_profit, ArraySize(listS), ArraySize(listS));
   for (s=0; s<ArraySize(listS); s++) {
      list_profit[s]=(int)StringToInteger(StringTrim(listS[s]));  
   }

   //--
   if (initial_lots < SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN)) {
      initial_lots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);  
   }

   if (lots==0) {lots = initial_lots;}
   else
   {
      if ((reverse==false && profit_or_loss==1) || (reverse==true && profit_or_loss==-1))
      {
         lots = initial_lots*list_profit[0];
         // shift array 1 step left
         size=ArraySize(list_profit);
         for(pos=0; pos<size-1; pos++) {
            list_profit[pos]=list_profit[pos+1];
         }
         if (size>0) {
            ArrayResize(list_profit, size-1, size-1);
            mem_list_profit[id]=StringImplode(",", list_profit);
         }
         // reset the opposite sequence
         //mem_list_loss[id]="";
      }
      else {
         
         lots = initial_lots*list_loss[0];
         // shift array 1 step left
         size=ArraySize(list_loss);
         for(pos=0; pos<size-1; pos++) {
            list_loss[pos]=list_loss[pos+1];
         }
         if (size>0) {
            ArrayResize(list_loss, size-1, size-1);
            mem_list_loss[id]=StringImplode(",", list_loss);
         }
         // reset the opposite sequence
         //mem_list_profit[id]="";
      }
   }
   
   return lots;
}
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 BuyNow(
   string symbol,
   double lots,
   double sll,
   double tpl,
   double slp,
   double tpp,
   double slippage=0,
   int magic=0,
   string comment=""
   )
{
   bool success=OrderCreate(
      symbol,
      POSITION_TYPE_BUY,
      lots,
      0,
      sll,
      tpl,
      slp,
      tpp,
      slippage,
      magic,
      comment,
      0
      );
   return(success);
}
double ChartEventParameterDouble(int cmd=0,double inp=-1) {static double mem=-1; if(cmd==1){mem=inp;} return(mem);}
long ChartEventParameterLong(int cmd=0,long inp=-1) {static long mem=-1; if(cmd==1){mem=inp;} return(mem);}
string ChartEventParameterString(int cmd=0,string inp="") {static string mem=""; if(cmd==1){mem=inp;} return(mem);}
int ChartEventType(int cmd=0,int inp=-1) {static int mem=-1; if(cmd==1){mem=inp;} return(mem);}
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);
}
bool CloseOrder(string symbol, double deviation=0)
{
   bool success=false;
   if (PositionSelect(symbol)) {
      success=CloseOrder(symbol,PositionGetDouble(POSITION_VOLUME),deviation);
   }
   
   OnTrade();
   return(success);
}
bool CloseOrder(string symbol, double volume, double deviation)
{
   volume=AlignLots(volume);

   bool success=false;
   if (PositionSelect(symbol))
   {
      int total=PositionsTotal();
      
      double price=0;
      //-- type ---------------------------------------------------------
      ENUM_POSITION_TYPE ContraType=0;
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) {
         ContraType=POSITION_TYPE_SELL;
         price=SymbolInfoDouble(symbol,SYMBOL_BID);
      }
      else if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) {
         ContraType=POSITION_TYPE_BUY;
         price=SymbolInfoDouble(symbol,SYMBOL_ASK);
      }
      //-- comment ------------------------------------------------------
      string comment="";
      if (volume>PositionGetDouble(POSITION_VOLUME)) {
         volume=PositionGetDouble(POSITION_VOLUME);
      }
      if (volume==PositionGetDouble(POSITION_VOLUME)) {
         comment="Position #"+IntegerToString(PositionGetInteger(POSITION_IDENTIFIER))+" closed";
      }
      else {
         comment="Position #"+IntegerToString(PositionGetInteger(POSITION_IDENTIFIER))+" partially closed";
      }
      //-- send ---------------------------------------------------------
      success=OrderCreate(
         symbol,
         ContraType,
         volume,
         price,
         0,
         0,
         0,
         0,
         deviation,
         PositionGetInteger(POSITION_MAGIC),
         comment,
         ORDER_TIME_GTC, // not important
         0 // not inportant
         );
   }
   else {
      Print("Cannot close a position: There is no opened position on ",symbol);  
   }
   OnTrade();
   return(success);
}
string CurrentSymbol(string symbol="")
{
   static string memory="";
   if (symbol!="") {memory=symbol;} else
   if (memory=="") {memory=Symbol();}
   return(memory);
}
ENUM_TIMEFRAMES CurrentTimeframe(ENUM_TIMEFRAMES tf=-1)
{
   static ENUM_TIMEFRAMES memory=0;
   if (tf>=0) {memory=tf;}
   return(memory);
}
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 current_spread = (SymbolInfoDouble(Symbol(),SYMBOL_ASK)-SymbolInfoDouble(Symbol(),SYMBOL_BID))/(CustomPoint(Symbol()));
   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);
}
double DynamicLots(string mode="balance", double value=0, double sl=0, string align="align")
{
   double size=0;
   string symbol=GetSymbol();
   double LotStep=SymbolLotStep(symbol);
   double LotSize=SymbolLotSize(symbol);
   double MinLots=SymbolMinLot(symbol);
   double MaxLots=SymbolMaxLot(symbol);
   double TickValue=SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE);
   double margin_required=0;
   bool ocm = OrderCalcMargin(ORDER_TYPE_BUY,symbol,1,ask(symbol),margin_required); // This is the MODE_MARGINREQUIRED analog in MQL5
   //if (value>MaxLots) {value=value/LotSize;} // Money-to-Lot conversion
   
        if (mode=="fixed" || mode=="lots") {size=value;}
   else if (mode=="block-equity")     {size=(value/100)*AccountEquity()/margin_required;}
   else if (mode=="block-balance")    {size=(value/100)*AccountBalance()/margin_required;}
   else if (mode=="block-freemargin") {size=(value/100)*AccountFreeMargin()/margin_required;}
   else if (mode=="equity")     {size=(value/100)*AccountEquity()/(LotSize*TickValue);}
   else if (mode=="balance")    {size=(value/100)*AccountBalance()/(LotSize*TickValue);}
   else if (mode=="freemargin") {size=(value/100)*AccountFreeMargin()/(LotSize*TickValue);}
   else if (mode=="equityRisk") {size=((value/100)*AccountEquity())/(sl*TickValue*PipValue(symbol));}
   else if (mode=="balanceRisk"){size=((value/100)*AccountBalance())/(sl*TickValue*PipValue(symbol));}
   else if (mode=="freemarginRisk") {size=((value/100)*AccountFreeMargin())/(sl*TickValue*PipValue(symbol));}
   else if (mode=="fixedRisk")   {size=(value)/(sl*TickValue*PipValue(symbol));}
   else if (mode=="fixedRatio" || mode=="RJFR") { 
      /////
      // Ryan Jones Fixed Ratio MM static data
      static double RJFR_start_lots=0;
      static double RJFR_delta=0;
      static double RJFR_units=1;
      static double RJFR_target_lower=0;
      static double RJFR_target_upper=0;
      /////
      
      if (RJFR_start_lots<=0) {RJFR_start_lots=value;}
      if (RJFR_start_lots<MinLots) {RJFR_start_lots=MinLots;}
      if (RJFR_delta<=0) {RJFR_delta=sl;}
      if (RJFR_target_upper<=0) {
         RJFR_target_upper=AccountEquity()+(RJFR_units*RJFR_delta);
         Print("Fixed Ratio MM: Units=>",RJFR_units,"; Delta=",RJFR_delta,"; Upper Target Equity=>",RJFR_target_upper);
      }
      if (AccountEquity()>=RJFR_target_upper)
      {
         while(true) {
            Print("Fixed Ratio MM going up to ",(RJFR_start_lots*(RJFR_units+1))," lots: Equity is above Upper Target Equity (",AccountEquity(),">=",RJFR_target_upper,")");
            RJFR_units++;
            RJFR_target_lower=RJFR_target_upper;
            RJFR_target_upper=RJFR_target_upper+(RJFR_units*RJFR_delta);
            Print("Fixed Ratio MM: Units=>",RJFR_units,"; Delta=",RJFR_delta,"; Lower Target Equity=>",RJFR_target_lower,"; Upper Target Equity=>",RJFR_target_upper);
            if (AccountEquity()<RJFR_target_upper) {break;}
         }
      }
      else if (AccountEquity()<=RJFR_target_lower)
      {
         while(true) {
         if (AccountEquity()>RJFR_target_lower) {break;}
            if (RJFR_units>1) {         
               Print("Fixed Ratio MM going down to ",(RJFR_start_lots*(RJFR_units-1))," lots: Equity is below Lower Target Equity | ", AccountEquity()," <= ",RJFR_target_lower,")");
               RJFR_target_upper=RJFR_target_lower;
               RJFR_target_lower=RJFR_target_lower-((RJFR_units-1)*RJFR_delta);
               RJFR_units--;
               Print("Fixed Ratio MM: Units=>",RJFR_units,"; Delta=",RJFR_delta,"; Lower Target Equity=>",RJFR_target_lower,"; Upper Target Equity=>",RJFR_target_upper);
            } else {break;}
         }
      }
      size=RJFR_start_lots*RJFR_units;
   }
   
   static bool alert_min_lots=false;
   if (size<MinLots && alert_min_lots==false) {alert_min_lots=true;
      Alert("You want to trade ",size," lot, but your broker's minimum is ",MinLots," lot. The trade/order will continue with ",MinLots," lot instead of ",size," lot. The same rule will be applied for next trades/orders with desired lot size lower than the minimum. You will not see this message again until you restart the program.");
   }

   //double stepsize=0;
   //while(size+0.000000001>stepsize){stepsize+=LotStep;}
   //size=stepsize-LotStep;
   size=MathRound(size/LotStep)*LotStep;
   
   if (align=="align") {
      if (size<MinLots) {size=MinLots;}
      if (size>MaxLots) {size=MaxLots;}
   }
   
   return (size);
}
string ErrorMessage(int error_code=-1)
{
   if (error_code<0) {error_code=GetLastError();}
   string error_string="";

   switch(error_code)
   {
      //--- Runtime
      case 0: return("");
      case 4001: error_string="Unexpected internal error"; break;
      case 4002: error_string="Wrong parameter in the inner call of the client terminal function"; break;
      case 4003: error_string="Wrong parameter when calling the system function"; break;
      case 4004: error_string="Not enough memory to perform the system function"; break;
      case 4005: error_string="The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes"; break;
      case 4006: error_string="Array of a wrong type, wrong size, or a damaged object of a dynamic array"; break;
      case 4007: error_string="Not enough memory for the relocation of an array, or an attempt to change the size of a static array"; break;
      case 4008: error_string="Not enough memory for the relocation of string"; break;
      case 4009: error_string="Not initialized string"; break;
      case 4010: error_string="Invalid date and/or time"; break;
      case 4011: error_string="Requested array size exceeds 2 GB"; break;
      case 4012: error_string="Wrong pointer"; break;
      case 4013: error_string="Wrong type of pointer"; break;
      case 4014: error_string="System function is not allowed to call"; break;
      //-- Charts
      case 4101: error_string="Wrong chart ID"; break;
      case 4102: error_string="Chart does not respond"; break;
      case 4103: error_string="Chart not found"; break;
      case 4104: error_string="No Expert Advisor in the chart that could handle the event"; break;
      case 4105: error_string="Chart opening error"; break;
      case 4106: error_string="Failed to change chart symbol and period"; break;
      case 4107: error_string="Wrong parameter for timer"; break;
      case 4108: error_string="Failed to create timer"; break;
      case 4109: error_string="Wrong chart property ID"; break;
      case 4110: error_string="Error creating screenshots"; break;
      case 4111: error_string="Error navigating through chart"; break;
      case 4112: error_string="Error applying template"; break;
      case 4113: error_string="Subwindow containing the indicator was not found"; break;
      case 4114: error_string="Error adding an indicator to chart"; break;
      case 4115: error_string="Error deleting an indicator from the chart"; break;
      case 4116: error_string="Indicator not found on the specified chart"; break;
      //-- Graphical Objects
      case 4201: error_string="Error working with a graphical object"; break;
      case 4202: error_string="Graphical object was not found"; break;
      case 4203: error_string="Wrong ID of a graphical object property"; break;
      case 4204: error_string="Unable to get date corresponding to the value"; break;
      case 4205: error_string="Unable to get value corresponding to the date"; break;
      //-- Market Info
      case 4301: error_string="Unknown symbol"; break;
      case 4302: error_string="Symbol is not selected in MarketWatch"; break;
      case 4303: error_string="Wrong identifier of a symbol property"; break;
      case 4304: error_string="Time of the last tick is not known (no ticks)"; break;
      case 4305: error_string="Error adding or deleting a symbol in MarketWatch"; break;
      //-- History Access
      case 4401: error_string="Requested history not found"; break;
      case 4402: error_string="Wrong ID of the history property"; break;
      //-- Global Variables
      case 4501: error_string="Global variable of the client terminal is not found"; break;
      case 4502: error_string="Global variable of the client terminal with the same name already exists"; break;
      case 4510: error_string="Email sending failed"; break;
      case 4511: error_string="Sound playing failed"; break;
      case 4512: error_string="Wrong identifier of the program property"; break;
      case 4513: error_string="Wrong identifier of the terminal property"; break;
      case 4514: error_string="File sending via ftp failed"; break;
      //-- Custom Indicator Buffers
      case 4601: error_string="Not enough memory for the distribution of indicator buffers"; break;
      case 4602: error_string="Wrong indicator buffer index"; break;
      //-- Custom Indicator Properties
      case 4603: error_string="Wrong ID of the custom indicator property"; break;
      //-- Account
      case 4701: error_string="Wrong account property ID"; break;
      case 4751: error_string="Wrong trade property ID"; break;
      case 4752: error_string="Trading by Expert Advisors prohibited"; break;
      case 4753: error_string="Position not found"; break;
      case 4754: error_string="Order not found"; break;
      case 4755: error_string="Deal not found"; break;
      case 4756: error_string="Trade request sending failed"; break;
      //-- Indicators
      case 4801: error_string="Unknown symbol"; break;
      case 4802: error_string="Indicator cannot be created"; break;
      case 4803: error_string="Not enough memory to add the indicator"; break;
      case 4804: error_string="The indicator cannot be applied to another indicator"; break;
      case 4805: error_string="Error applying an indicator to chart"; break;
      case 4806: error_string="Requested data not found"; break;
      case 4807: error_string="Wrong indicator handle"; break;
      case 4808: error_string="Wrong number of parameters when creating an indicator"; break;
      case 4809: error_string="No parameters when creating an indicator"; break;
      case 4810: error_string="The first parameter in the array must be the name of the custom indicator"; break;
      case 4811: error_string="Invalid parameter type in the array when creating an indicator"; break;
      case 4812: error_string="Wrong index of the requested indicator buffer"; break;
      //-- Depth of Market
      case 4901: error_string="Depth Of Market can not be added"; break;
      case 4902: error_string="Depth Of Market can not be removed"; break;
      case 4903: error_string="The data from Depth Of Market can not be obtained"; break;
      case 4904: error_string="Error in subscribing to receive new data from Depth Of Market"; break;
      //-- File Operations
      case 5001: error_string="More than 64 files cannot be opened at the same time"; break;
      case 5002: error_string="Invalid file name"; break;
      case 5003: error_string="Too long file name"; break;
      case 5004: error_string="File opening error"; break;
      case 5005: error_string="Not enough memory for cache to read"; break;
      case 5006: error_string="File deleting error"; break;
      case 5007: error_string="A file with this handle was closed, or was not opening at all"; break;
      case 5008: error_string="Wrong file handle"; break;
      case 5009: error_string="The file must be opened for writing"; break;
      case 5010: error_string="The file must be opened for reading"; break;
      case 5011: error_string="The file must be opened as a binary one"; break;
      case 5012: error_string="The file must be opened as a text"; break;
      case 5013: error_string="The file must be opened as a text or CSV"; break;
      case 5014: error_string="The file must be opened as CSV"; break;
      case 5015: error_string="File reading error"; break;
      case 5016: error_string="String size must be specified, because the file is opened as binary"; break;
      case 5017: error_string="A text file must be for string arrays, for other arrays - binary"; break;
      case 5018: error_string="This is not a file, this is a directory"; break;
      case 5019: error_string="File does not exist"; break;
      case 5020: error_string="File can not be rewritten"; break;
      case 5021: error_string="Wrong directory name"; break;
      case 5022: error_string="Directory does not exist"; break;
      case 5023: error_string="This is a file, not a directory"; break;
      case 5024: error_string="The directory cannot be removed"; break;
      case 5025: error_string="Failed to clear the directory (probably one or more files are blocked and removal operation failed)"; break;
      case 5026: error_string="Failed to write a resource to a file"; break;
      //-- String Casting
      case 5030: error_string="No date in the string"; break;
      case 5031: error_string="Wrong date in the string"; break;
      case 5032: error_string="Wrong time in the string"; break;
      case 5033: error_string="Error converting string to date"; break;
      case 5034: error_string="Not enough memory for the string"; break;
      case 5035: error_string="The string length is less than expected"; break;
      case 5036: error_string="Too large number, more than ULONG_MAX"; break;
      case 5037: error_string="Invalid format string"; break;
      case 5038: error_string="Amount of format specifiers more than the parameters"; break;
      case 5039: error_string="Amount of parameters more than the format specifiers"; break;
      case 5040: error_string="Damaged parameter of string type"; break;
      case 5041: error_string="Position outside the string"; break;
      case 5042: error_string="0 added to the string end, a useless operation"; break;
      case 5043: error_string="Unknown data type when converting to a string"; break;
      case 5044: error_string="Damaged string object"; break;
      //-- Operations with Arrays
      case 5050: error_string="Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in numeric array only"; break;
      case 5051: error_string="The receiving array is declared as AS_SERIES, and it is of insufficient size"; break;
      case 5052: error_string="Too small array, the starting position is outside the array"; break;
      case 5053: error_string="An array of zero length"; break;
      case 5054: error_string="Must be a numeric array"; break;
      case 5055: error_string="Must be a one-dimensional array"; break;
      case 5056: error_string="Timeseries cannot be used"; break;
      case 5057: error_string="Must be an array of type double"; break;
      case 5058: error_string="Must be an array of type float"; break;
      case 5059: error_string="Must be an array of type long"; break;
      case 5060: error_string="Must be an array of type int"; break;
      case 5061: error_string="Must be an array of type short"; break;
      case 5062: error_string="Must be an array of type char"; break;
      //-- trading errors
      case 10004: error_string="Requote occured"; break;
      case 10006: error_string="Order is not accepted by the server"; break;
      case 10007: error_string="Request canceled by trader"; break;
      case 10010: error_string="Only part of the request was completed"; break;
      case 10011: error_string="Request processing error"; break;
      case 10012: error_string="Request canceled by timeout"; break;
      case 10013: error_string="Invalid request"; break;
      case 10014: error_string="Invalid volume"; break;
      case 10015: error_string="Invalid price"; break;
      case 10016: error_string="Invalid SL or TP"; break;
      case 10017: error_string="Trading is disabled"; break;
      case 10018: error_string="Market is closed"; break;
      case 10019: error_string="Not enough money to trade"; break;
      case 10020: error_string="Prices changed"; break;
      case 10021: error_string="There are no quotes to process the request"; break;
      case 10022: error_string="Invalid expiration date in the order request"; break;
      case 10023: error_string="Order state changed"; break;
      case 10024: error_string="Too frequent requests"; break;
      case 10025: error_string="No changes in request"; break;
      case 10026: error_string="Autotrading is disabled by the server"; break;
      case 10027: error_string="Autotrading is disabled by the client terminal"; break;
      case 10028: error_string="Request locked for processing"; break;
      case 10029: error_string="Order or trade frozen"; break;
      case 10030: error_string="Invalid order filling type"; break;
      case 10031: error_string="No connection with the trade server"; break;
      case 10032: error_string="Operation is allowed only for live accounts"; break;
      case 10033: error_string="The number of pending orders has reached the limit"; break;
      case 10034: error_string="The volume of orders and trades for the symbol has reached the limit"; break;
      case 10035: error_string="Incorrect or prohibited order type"; break;
      case 10036: error_string="Position with the specified POSITION_IDENTIFIER has already been closed"; break;
      //-- User-Defined Errors
      case 65536: error_string="User defined errors"; break;
      default:   error_string="Unknown error";
   }

   //if (error_code>0) {error_string="("+(string)error_code+") "+error_string);}
   StringConcatenate(error_string, error_string," (",error_code,")");
   return(error_string);
}
bool FilterOrderBy(string group_mode="all", string group="0", string market_mode="all", string market="", string BuysOrSells="both", string LimitsOrStops="")
{
   bool type_pass = false;
   
   static string market0="-";
   static string markets[];
   static int markets_size=0;
   bool market_pass=false;
   
   static string group0="-";
   static string groups[];
   static int groups_size=0;
   bool group_pass=false;

   int i=0;
   
   // Trades && History trades
   if (LimitsOrStops=="")
   {
      if (
            (BuysOrSells=="both"  && (IsOrderTypeBuy() || IsOrderTypeSell()))
         || (BuysOrSells=="buys"  && IsOrderTypeBuy())
         || (BuysOrSells=="sells" && IsOrderTypeSell())
         )
      {
         type_pass = true;
      }
   }
   // Pending orders
   else
   {
      //if (market_mode=="all" || OrderGetString(ORDER_SYMBOL)==markets[i]) {
      long type = OrderGetInteger(ORDER_TYPE);
      if (
         ((BuysOrSells=="buys"||BuysOrSells=="both") && (type==ORDER_TYPE_BUY_LIMIT || type==ORDER_TYPE_BUY_STOP))
         ||
         ((BuysOrSells=="sells"||BuysOrSells=="both") && (type==ORDER_TYPE_SELL_LIMIT || type==ORDER_TYPE_SELL_STOP))
         )
      {
         if (
               ((LimitsOrStops=="limits"||LimitsOrStops=="both") && (type==ORDER_TYPE_BUY_LIMIT || type==ORDER_TYPE_SELL_LIMIT))
            || ((LimitsOrStops=="stops"||LimitsOrStops=="both") && (type==ORDER_TYPE_BUY_STOP || type==ORDER_TYPE_SELL_STOP))
            )
         {
            type_pass = true;
         }
      }
   }
   if (type_pass == false) {return false;}
   
   //-- check group
   if (group_mode=="group")
   {
      if (group0!=group)
      {
         group0=group;
         StringExplode(",",group,groups);
         groups_size = ArraySize(groups);
         for(i=0; i<groups_size; i++)
         {
            groups[i]=StringTrim(groups[i]);
            if (groups[i]=="") {groups[i]="0";}
         }
      }
      for(i=0; i<groups_size; i++)
      {
         if (OrderMagicNumber()==(MagicStart+(int)groups[i]))
         {
            group_pass=true;
            break;
         }
      }
   }
   else if (group_mode=="all" || (group_mode=="manual" && OrderMagicNumber()==0)) {
      group_pass = true;  
   }
   if (group_pass == false) {return false;}
   
   // check market
   if (market_mode=="all") {
      market_pass=true;
      
   }
   else {
      if (market0!=market)
      {
         market0=market;
         if (market=="")
         {
            markets_size = 1;
            ArrayResize(markets,1);
            markets[0]=Symbol();
         }
         else
         {
            StringExplode(",",market,markets);
            markets_size = ArraySize(markets);
            for(i=0; i<markets_size; i++)
            {
               markets[i]=StringTrim(markets[i]);
               if (markets[i]=="") {markets[i]=Symbol();}
            }
         }
      }
      for(i=0; i<markets_size; i++) {
         if (OrderSymbol()==markets[i]) {
            market_pass = true;
            break;
         }
      }
   }
   if (market_pass == false) {return false;}
 
   return(true);
}
string GetOrderSymbol(int index)
{
	return(PositionGetSymbol(index));
}
string GetSymbol(string symbol="")
{
   static string memory="";
   if (symbol=="") {
      if (memory=="") {memory=Symbol();}
   }
   else {memory=symbol;}
   return(memory);
}
/******************************************************/
/* Checks if element exist in array                   */
/* Returns "true" if exists and "false" if not exists */
/******************************************************/
bool InArray(int &array[], int value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}  
   }
   return (founded);
}
bool InArray(double &array[], double value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}  
   }
   return (founded);
}
bool InArray(string &array[], string value)
{
   bool founded=false;
   int size=ArraySize(array);
   for (int i=0; i<size; i++) {
      if (array[i]==value) {founded=true; break;}  
   }
   return (founded);
}
double IndicatorGetValue(int handle, int mode=0, int shift=0)
{
   static double buffer[1];
   
   if (handle<0) {
      Print("Error: Indicator not handled. (handle=",handle," | error code=",GetLastError(),")");
      return(0);
   }
   
   int tryouts=0;
   
   while(true) {
      if (BarsCalculated(handle)>0) {break;}
      else {
         tryouts++;
         if (MQL5InfoInteger(MQL5_TESTING)) {
            Sleep(10);
         }
         else {
            if (tryouts>10) {
               Print("Error: Indicator cannot load (handle=",handle," | error code=",GetLastError(),")");
               break;
            }
            Sleep(100);
         }
      }
   }
   int success=CopyBuffer(handle,mode,shift,1,buffer);
   if (success<0) {
      Print("Error: Cannot get value from an indicator. (handle=",handle," | error code=",GetLastError(),")");
      return(0);
   }
   //ArraySetAsSeries(buffer,true);

   return(buffer[0]);
}
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 IsFillingTypeAllowed(string symbol,int fill_type)
  {
//--- Obtain the value of the property that describes allowed filling modes
   int filling=(int)SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);
//--- Return true, if mode fill_type is allowed
   return((filling & fill_type)==fill_type);
  }
bool IsOrderTypeBuy() {
   if (LoadedType()==1){
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) {return(true);} else {return(false);}
   }
   if (LoadedType()==3) {
      if (
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_BUY
      ) {return(true);} else {return(false);}
   }
   if (LoadedType()==4) {
      if (
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_BUY_LIMIT
      ||
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_BUY_STOP
      ) {return(true);} else {return(false);}
   }
   if (
      OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_LIMIT
      ||
      OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP
      ) {return(true);} else {return(false);}
   return(false);
}
bool IsOrderTypeSell() {
   if (LoadedType()==1){if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) {return(true);} else {return(false);}}
   if (LoadedType()==3) {
      if (
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_SELL
      ) {return(true);} else {return(false);}
   }
   if (LoadedType()==4) {
      if (
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_SELL_LIMIT
      ||
      HistoryOrderGetInteger(OrderTicket(),ORDER_TYPE)==ORDER_TYPE_SELL_STOP
      ) {return(true);} else {return(false);}
   }
   if (
      OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_LIMIT
      ||
      OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_STOP
      ) {return(true);} else {return(false);}
   return(false);
}
int LastIndicatorShift(bool set=false, int shift=0)
{
   static int mem;
   if (set==true) {mem=shift;}
   return(mem);
}
string LastIndicatorSymbol(bool set=false, string symbol="")
{
   static string mem;
   if (set==true) {mem=symbol;}
   return(mem);
}
int LastIndicatorTimeframe(bool set=false, int timeframe=0)
{
   static int mem;
   if (set==true) {mem=timeframe;}
   return(mem);
}
double LastIndicatorValue(bool set=false, double value=0)
{
   static double mem;
   if (set==true) {mem=value;}
   return(mem);
}
bool LoadHistoryOrder(int index, string selectby="select_by_pos")
{
   if (selectby=="select_by_pos") {
      ulong ticket=HistoryDealGetTicket(index);
      ulong oticket=0; //HistoryOrderGetTicket(index);
      oticket=HistoryDealGetInteger(ticket, DEAL_ORDER);
      if (ticket>0 || oticket>0) {
         if (HistoryOrderGetInteger(oticket,ORDER_TYPE)>=2 && HistoryOrderSelect(oticket))
         {
            OrderTicket(oticket);
            LoadedType(4);
            return(true);
         }
         else if (
            HistoryOrderGetInteger(oticket,ORDER_TYPE)<2
            &&
            HistoryOrderSelect(HistoryDealGetInteger(ticket,DEAL_POSITION_ID))
            &&
            (ENUM_DEAL_ENTRY)HistoryDealGetInteger(ticket,DEAL_ENTRY)==DEAL_ENTRY_OUT
            )
         {
            OrderTicket(ticket);
            LoadedType(3);
            return(true);
         }
      }
   }
   if (selectby=="select_by_ticket") {
      if (HistoryOrderSelect(index)) {
         HistoryDealSelect(index); // Select deal, it will be just one with pos=0
         HistoryDealGetTicket(0); // Load the one and only selected deal
         OrderTicket(index);
         if (HistoryOrderGetInteger(index,ORDER_TYPE)>=2) {
            LoadedType(4); return(true);
         }
         else {
            LoadedType(3); return(true);
         }
      }
   }
   return(false);
}
bool LoadOrder(ulong ticket)
{
   LoadedType(2);
   bool success=OrderSelect(ticket);
   if (success) {OrderTicket(ticket);}
   return(success);
}
bool LoadOrder(string symbol)
{
   LoadedType(1);
   bool success=PositionSelect(symbol);
   if (success) {OrderTicket((ulong)PositionGetInteger(POSITION_IDENTIFIER));}
   return(success);
}
string LoadedObjectName(string name="") {static string memory=""; if (name!="") {memory=name;} return(memory);}
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);
}
bool LoopedResume()
{
   int ticket=attrTicketInLoop();
   string symbol=attrSymbolInLoop();
   
   if (LoadedType()==3) {
      if (ticket>0 && ticket!=attrTicket()) {
         return(LoadHistoryOrder((int)ticket,"select_by_ticket"));
      }
   }
   else if (LoadedType()==1) {
      if (symbol!="" && symbol!=attrSymbol()) {
         return(LoadOrder(symbol));
      }
   }
   else if (LoadedType()==2) {
      if (ticket>0 && ticket!=attrTicket()) {
         return(LoadOrder(ticket));
      }
   }
   return(false);
}
bool ModifyOrder(string symbol, double sll=0, double tpl=0, double slp=0, double tpp=0)
{
   int type=(int)PositionGetInteger(POSITION_TYPE);
   int bs=1;
   if (type==POSITION_TYPE_SELL) {bs=-1;}

   while(true)
   {
      uint time0=GetTickCount();
      
      if (!PositionSelect(symbol)) {return false;}
      
      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      double ask=SymbolInfoDouble(symbol,SYMBOL_ASK);
      double bid=SymbolInfoDouble(symbol,SYMBOL_BID);
      double op=PositionGetDouble(POSITION_PRICE_OPEN);
      
      op=NormalizeDouble(op,digits);
      sll=NormalizeDouble(sll,digits);
      tpl=NormalizeDouble(tpl,digits);
   
      //-- SL and TP ----------------------------------------------------
      double sl=0, tp=0, vsl=0, vtp=0;
      
      sl=AlignStopLoss(symbol, type, op, sll, slp);
      if (sl<0) {break;}
      tp=AlignTakeProfit(symbol, type, op, tpl, tpp);
      if (tp<0) {break;}
      
      sl=NormalizeDouble(sl,digits);
      tp=NormalizeDouble(tp,digits);

      if (
            sl==NormalizeDouble(attrStopLoss(),digits)
         && tp==NormalizeDouble(attrTakeProfit(),digits)
         )
      {
         return(true);
      }
   
      double point     =SymbolInfoDouble(symbol,SYMBOL_POINT);
      double SLinPips  =0;
      double TPinPips  =0;
      double price     =0;
      if (IsOrderTypeBuy()) {price=ask;} else {price=bid;}
      if (sl>0) {SLinPips=NormalizeDouble((MathAbs(sl-price)/point),0);} 
      if (tp>0) {TPinPips=NormalizeDouble((MathAbs(tp-price)/point),0);}
      
      MqlTradeRequest request;
      MqlTradeResult result;
      MqlTradeCheckResult check_result;
      ZeroMemory(request);
      ZeroMemory(result);
      ZeroMemory(check_result);
   
      request.action =TRADE_ACTION_SLTP;
      request.symbol =symbol;
      request.sl     =sl;
      request.tp     =tp;
      request.magic  =PositionGetInteger(POSITION_MAGIC);
      request.comment=PositionGetString(POSITION_COMMENT);
      //request.comment="SL->"+DoubleToString(SLinPips,0)+"points TP->"+DoubleToString(TPinPips,0)+"points";
   
      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 (result.retcode!=TRADE_RETCODE_DONE)
      {
         string errmsgpfx="Modify position 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 (PositionSelect(symbol) && (sl == NormalizeDouble(OrderStopLoss(), digits) && tp == NormalizeDouble(OrderTakeProfit(), digits))) {break;}
            Sleep(1);
         }
         if (w==5000) {
            Print("Check error: Modify position stops");  
         }
         if (!PositionSelect(symbol) || (sl != NormalizeDouble(OrderStopLoss(), digits) || tp != NormalizeDouble(OrderTakeProfit(), digits))) {
            Print("Something went wrong whem modifying stops of the position");
            return false;
         }
         
         if (!PositionSelect(symbol)) {return false;}
         PositionModified((int)PositionGetInteger(POSITION_IDENTIFIER));
      }
      
      break;
   }
   OnTrade();
   
   return(true);
}
bool ModifyOrder(
   ulong ticket,
   double op,
   double sll,
   double tpl,
   double slp,
   double tpp,
   int type_time,
   datetime exp
   )
{  
   while(true)
   {
      uint time0=GetTickCount();
      
      if (!OrderSelect(ticket)) {return false;}
      
      string symbol  =OrderGetString(ORDER_SYMBOL);
      int type       =(int)OrderGetInteger(ORDER_TYPE);
      int digits     =(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      double ask     =SymbolInfoDouble(symbol,SYMBOL_ASK);
      double bid     =SymbolInfoDouble(symbol,SYMBOL_BID);
      double point   =SymbolInfoDouble(symbol,SYMBOL_POINT);
      
      if (OrderType()<2) {op=OrderOpenPrice();} else {op=NormalizeDouble(op,digits);}
      sll=NormalizeDouble(sll,digits);
      tpl=NormalizeDouble(tpl,digits);
      if (op<0 || op>=EMPTY_VALUE)  {break;}
      if (sll<0) {break;}
      if (slp<0) {break;}
      if (tpl<0) {break;}
      if (tpp<0) {break;}
      
      //-- SL and TP ----------------------------------------------------
      double sl=0, tp=0, vsl=0, vtp=0;
      
      sl=AlignStopLoss(symbol, type, op, sll, slp);
      if (sl<0) {break;}
      tp=AlignTakeProfit(symbol, type, op, tpl, tpp);
      if (tp<0) {break;}
      
      sl=NormalizeDouble(sl,digits);
      tp=NormalizeDouble(tp,digits);
      
      //-- check if needed to modify ------------------------------------
      if (
            op==NormalizeDouble(OrderGetDouble(ORDER_PRICE_OPEN),digits)
         && sl==NormalizeDouble(OrderGetDouble(ORDER_SL),digits)
         && tp==NormalizeDouble(OrderGetDouble(ORDER_TP),digits)
         && exp==OrderGetInteger(ORDER_TIME_EXPIRATION)
      ) {
         return(true);
      }

      //-- modify -------------------------------------------------------
      MqlTradeRequest request;
      MqlTradeResult result;
      MqlTradeCheckResult check_result;
      ZeroMemory(request);
      ZeroMemory(result);
      ZeroMemory(check_result);
   
      request.action       =TRADE_ACTION_MODIFY;
      request.order        =ticket;
      request.price        =op;
      request.volume       =OrderGetDouble(ORDER_VOLUME_CURRENT);
      request.sl           =sl;
      request.tp           =tp;
      request.magic        =OrderGetInteger(ORDER_MAGIC);
      request.type_time    =(ENUM_ORDER_TYPE_TIME)type_time;
      request.expiration   =exp;
      request.comment      =OrderGetString(ORDER_COMMENT);
      //-- filling type
      uint filling=(uint)SymbolInfoInteger(request.symbol,SYMBOL_FILLING_MODE);
      if (filling==SYMBOL_FILLING_FOK) {
         request.type_filling=ORDER_FILLING_FOK;
      }
      else if (filling==SYMBOL_FILLING_IOC) {
         request.type_filling=ORDER_FILLING_IOC;
      }
   
      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 (result.retcode!=TRADE_RETCODE_DONE)
      {
         string errmsgpfx="Modify position 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) && (sl == NormalizeDouble(OrderStopLoss(), digits) && tp == NormalizeDouble(OrderTakeProfit(), digits))) {break;}
            Sleep(1);
         }
         if (w==5000) {
            Print("Check error: Modify order stops");  
         }
         if (!OrderSelect(ticket) || (sl != NormalizeDouble(OrderStopLoss(), digits) || tp != NormalizeDouble(OrderTakeProfit(), digits))) {
            Print("Something went wrong whem modifying stops of the position");
            return false;
         }
         
         if (!OrderSelect(ticket)) {return false;}
         PendingModified((int)ticket);
      }
   
      break;
   }
   OnTrade();
   
   return(true);
}
int ObjectGetShiftByValue(string name, double value) {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   datetime Arr[];
   MqlRates mql4[];
   if(ObjectGetTimeByValue(0,name,value)<0) {return(-1);}
   CopyRates(NULL,timeframe,0,1,mql4);
      if(CopyTime(NULL, timeframe, mql4[0].time, ObjectGetTimeByValue(0,name,value), Arr)>0) {return(ArraySize(Arr)-1);}
      else {return(-1);}
}

int ObjectGetShiftByValue(long chart_id, string name, double value) {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   datetime Arr[];
   MqlRates mql4[];
   if(ObjectGetTimeByValue(chart_id,name,value)<0) {return(-1);}
   CopyRates(NULL, timeframe, 0, 1, mql4);
   if(CopyTime(NULL, timeframe, mql4[0].time, ObjectGetTimeByValue(chart_id,name,value),Arr)>0) {return(ArraySize(Arr)-1);}
   else {return(-1);}
}
double ObjectGetValueByShift(string name,
                               int shift)
{
 ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
 MqlRates mql4[];
 CopyRates(NULL,timeframe,shift,1,mql4);
 return(ObjectGetValueByTime(0,name,mql4[0].time,0));
}

double ObjectGetValueByShift(long ctart_id, string name, int shift)
{
 ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
 MqlRates mql4[];
 CopyRates(NULL,timeframe,shift,1,mql4);
 return(ObjectGetValueByTime(ctart_id,name,mql4[0].time,0));
}
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);
}
double OrderClosePrice() {
   if (LoadedType()==1){
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) {return(SymbolInfoDouble(PositionGetString(POSITION_SYMBOL),SYMBOL_ASK));}
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) {return(SymbolInfoDouble(PositionGetString(POSITION_SYMBOL),SYMBOL_BID));}
   }
   if (LoadedType()==3){return(HistoryDealGetDouble(attrTicket(),DEAL_PRICE));}
   if (LoadedType()==4){return(HistoryDealGetDouble(attrTicket(),DEAL_PRICE));}
   return(OrderGetDouble(ORDER_PRICE_CURRENT));
}
bool OrderCreate(
   string symbol="",
   int    type=ORDER_TYPE_BUY,
   double lots=0,
   double op=0,
   double sll=0,
   double tpl=0,
   double slp=0,
   double tpp=0,
   double slippage=0,
   ulong  magic=0,
   string comment=NULL,
   ENUM_ORDER_TYPE_TIME type_time=ORDER_TIME_GTC,
   datetime expiration=0
   )
{
   OnTrade(); // When position is closed by sl or tp, this event is not fired (by MetaTrader) until the end of the tick, and if a new position is opened, it will be missed. 

   uint time0=GetTickCount();
   
   bool closing = false;
   double lots0 = 0;
   int type0 = type;
   if (type == POSITION_TYPE_BUY || type == POSITION_TYPE_SELL)
   {
      if (PositionSelect(symbol))
      {
         if ((int)PositionGetInteger(POSITION_TYPE) != type) {
            closing = true;
         }
         lots0 = NormalizeDouble(OrderLots(), 5);
         type0 = OrderType();
      }
   }
   
   int ticket=-1;
   int bs=1;
   if (
         type==ORDER_TYPE_SELL
      || type==ORDER_TYPE_SELL_STOP
      || type==ORDER_TYPE_SELL_LIMIT
   )
   {bs=-1;} // Positive when Buy, negative when Sell
   
   if (symbol=="") {symbol=Symbol();}
   
   lots=AlignLots(lots);

   //-- attempts to send position/order ---------------------------------
   while(true)
   {   
      int digits     =(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      double ask     =SymbolInfoDouble(symbol,SYMBOL_ASK);
      double bid     =SymbolInfoDouble(symbol,SYMBOL_BID);
      double point   =SymbolInfoDouble(symbol,SYMBOL_POINT);
      
      //- not enough money check: fix maximum possible lot by margin required, or quit
      if ((type==POSITION_TYPE_BUY || type==POSITION_TYPE_SELL) && closing==false)
      {
         double LotStep          =SymbolLotStep(symbol);
         double MinLots          =SymbolMinLot(symbol);
         double margin_required  =0; bool ocm = OrderCalcMargin((ENUM_ORDER_TYPE)type,symbol,1,ask(symbol),margin_required);
         static bool not_enough_message = false;
         
         if (margin_required != 0)
         {
            double max_size_by_margin = AccountFreeMargin()/margin_required;
         
            if (lots > max_size_by_margin) {
               double lots_old = lots;
               lots = max_size_by_margin;
               if (lots<MinLots)
               {
                  if (not_enough_message==false) {
                     Print("Not enough money to trade :( The robot is still working, waiting for some funds to appear...");
                  }
                  not_enough_message = true;
                  return(false);
               }
               else
               {
                  lots = MathFloor(lots/LotStep)*LotStep;
                  Print("Not enough money to trade "+DoubleToString(lots_old, 2)+", the volume to trade will be the maximum possible of "+DoubleToString(lots, 2));
               }
            }
         }
         not_enough_message = false;
      }
      
      if (type==ORDER_TYPE_BUY || type==ORDER_TYPE_SELL)
      {
         op=ask;
         if (bs<0) {
           op=bid;
         }
      }
      op=NormalizeDouble(op, digits);
      if (op<0 || op>=EMPTY_VALUE)  {break;}
      if (sll<0) {break;}
      if (slp<0) {break;}
      if (tpl<0) {break;}
      if (tpp<0) {break;}
      
      //-- SL and TP ----------------------------------------------------
      double sl=0, tp=0;
      
      sl=AlignStopLoss(symbol, type, op, NormalizeDouble(sll,digits), slp);
      if (sl<0) {break;}
      tp=AlignTakeProfit(symbol, type, op, NormalizeDouble(tpl,digits), tpp);
      if (tp<0) {break;}
      
      sl = NormalizeDouble(sl,digits);
      tp = NormalizeDouble(tp,digits);
      
      //-- send ---------------------------------------------------------
      MqlTradeRequest request;
      MqlTradeResult result;
      MqlTradeCheckResult check_result;
      ZeroMemory(request);
      ZeroMemory(result);
      ZeroMemory(check_result);
      
      ENUM_SYMBOL_TRADE_EXECUTION exec =(ENUM_SYMBOL_TRADE_EXECUTION)SymbolInfoInteger(symbol,SYMBOL_TRADE_EXEMODE);

      //if (expiration==0) {type_time=ORDER_TIME_GTC;}

      request.symbol       = symbol;
      request.type         = (ENUM_ORDER_TYPE)type;
      request.volume       = lots;
      request.price        = op;
      request.deviation    = (ulong)(slippage*PipValue(symbol));
      request.sl           = sl;
      request.tp           = tp;
      request.comment      = comment;
      request.magic        = magic;
      request.type_time    = type_time;
      request.expiration   = expiration;
      
      //-- request action
      if (type>ORDER_TYPE_SELL)
      {
         request.action       = TRADE_ACTION_PENDING;
      }
      else
      {
         request.action       = TRADE_ACTION_DEAL;
      }
      //-- filling type
      
      // check ORDER_FILLING_RETURN for pending orders only 
      if (type>ORDER_TYPE_SELL && IsFillingTypeAllowed(symbol, ORDER_FILLING_RETURN))
      {
         request.type_filling = ORDER_FILLING_RETURN;
      }
      else if (IsFillingTypeAllowed(symbol, ORDER_FILLING_FOK))
      {
         request.type_filling = ORDER_FILLING_FOK;
      }
      else if (IsFillingTypeAllowed(symbol, ORDER_FILLING_IOC))
      {
         request.type_filling = ORDER_FILLING_IOC;
      }
      // check ORDER_FILLING_RETURN again, if for some strange reason the other two are not supported for positions
      else if (IsFillingTypeAllowed(symbol, ORDER_FILLING_RETURN))
      {
         request.type_filling = ORDER_FILLING_RETURN;
      }
      
      
      if (!OrderCheck(request,check_result))  {
         Print("OrderCheck() failed: "+(string)check_result.comment+" ("+(string)check_result.retcode+")");
         return false;
      }

      int success=OrderSend(request,result);
      
      //-- error check --------------------------------------------------
      if (!success || result.retcode!=TRADE_RETCODE_DONE)
      {
         string errmsgpfx="New position error";
         if (type>ORDER_TYPE_SELL) {
            errmsgpfx="New pending 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)
      {
         //== Whatever was created, we need to wait until MT5 updates it's cache

         //-- Synchronize: Position
         if (type<=ORDER_TYPE_SELL)
         {
            if (closing == false)
            {
               //- new position: 2 situations here - new position or add to position
               //- ... because of that we will check the lot size instead of PositionSelect
               while (true)
               {
                  if (LoadOrder(symbol) && (lots0 != NormalizeDouble(OrderLots(), 5))) {break;}
                  Sleep(10);
               }
            }
            else
            {
               //- closing position: full
               if (lots0 == NormalizeDouble(result.volume, 5))
               {
                  while (true)
                  {
                     if (!LoadOrder(symbol)) {break;}
                     Sleep(10);
                  }
               }
               //- closing position: partial
               else if (lots0 > NormalizeDouble(result.volume, 5))
               {
                  while (true)
                  {
                     if (LoadOrder(symbol) && (lots0 != NormalizeDouble(OrderLots(), 5))) {break;}
                     Sleep(10);
                  }
               }
               else if (lots0 < NormalizeDouble(result.volume, 5))
               {
               //-- position reverse
                  while (true)
                  {
                     if (LoadOrder(symbol) && (type0 != OrderType())) {break;}
                     Sleep(10);
                  }
               }
            }
         }
         //-- Synchronize: Order
         else
         {
            while (true)
            {
               if (LoadOrder(result.order)) {break;}
               Sleep(10);
            }
         }
      }
      break;
   }
   OnTrade();
   return(true);
}
double OrderLots() {return(OrderVolume());}
int OrderMagicNumber()
{
   if (LoadedType()==1){return((int)PositionGetInteger(POSITION_MAGIC));}
   if (LoadedType()==3){return((int)HistoryOrderGetInteger(HistoryDealGetInteger(OrderTicket(),DEAL_POSITION_ID),ORDER_MAGIC));}
   if (LoadedType()==4){return((int)HistoryOrderGetInteger(OrderTicket(),ORDER_MAGIC));}
   return((int)OrderGetInteger(ORDER_MAGIC));
}
double OrderOpenPrice() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_PRICE_OPEN));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(OrderTicket(),DEAL_POSITION_ID),ORDER_PRICE_OPEN));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(OrderTicket(),ORDER_PRICE_OPEN));}
   return(OrderGetDouble(ORDER_PRICE_OPEN));
}
datetime OrderOpenTime() {
   if (LoadedType()==1){return((datetime)PositionGetInteger(POSITION_TIME));}
   if (LoadedType()==3){return((datetime)HistoryOrderGetInteger(HistoryDealGetInteger(OrderTicket(),DEAL_POSITION_ID),ORDER_TIME_SETUP));}
   if (LoadedType()==4){return((datetime)HistoryOrderGetInteger(OrderTicket(),ORDER_TIME_SETUP));}
   return((datetime)OrderGetInteger(ORDER_TIME_SETUP));
}
double OrderStopLoss() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_SL));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(OrderTicket(),DEAL_POSITION_ID),ORDER_SL));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(OrderTicket(),ORDER_SL));}
   return(OrderGetDouble(ORDER_SL));
}
string OrderSymbol()
{
   if (LoadedType()==1){return(PositionGetString(POSITION_SYMBOL));}
   if (LoadedType()==3){return(HistoryDealGetString(OrderTicket(),DEAL_SYMBOL));}
   if (LoadedType()==4){return(HistoryOrderGetString(OrderTicket(),ORDER_SYMBOL));}
   return(OrderGetString(ORDER_SYMBOL));
}
double OrderTakeProfit() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_TP));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(OrderTicket(),DEAL_POSITION_ID),ORDER_TP));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(OrderTicket(),ORDER_TP));}
   return(OrderGetDouble(ORDER_TP));
}
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 OrderVolume() {
   if (LoadedType()==1){return(NormalizeDouble(PositionGetDouble(POSITION_VOLUME), 5));}
   if (LoadedType()==3){return(NormalizeDouble(HistoryDealGetDouble(attrTicket(),DEAL_VOLUME), 5));}
   if (LoadedType()==4){return(NormalizeDouble(HistoryOrderGetDouble(attrTicket(),ORDER_VOLUME_INITIAL), 5));}
   return(NormalizeDouble(OrderGetDouble(ORDER_VOLUME_CURRENT), 5));
}
bool PendingModified(ulong ticket=-1, string action="set")
{
   static int memory[];
   
   if (ticket==-1) {
      ticket=(int)OrderTicket();
      action="get";
   }
   else if (ticket>-1 && action!="clear") {
      action="set";
   }
   
   if (action=="set") {
   //- Set Pending Ticket
      ArrayValue(memory,(int)ticket);
      return(true);
   }
   else if (action=="clear") {
   //- Unset Pending Ticket
      ArrayStrip(memory,(int)ticket);
      return(true);
   }
   else if (action=="get") {
   //- Get State
      return(InArray(memory,(int)ticket));
   }
   
   Print("Error: The second parameter of the function \"PendingModified\" should be \"set\", \"get\" or \"clear\"");
   return (false);
}
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);
   */
}
bool PositionModified(int id=-1, string action="set")
{
   static int memory[];
   
   if (id==-1) {
      id=(int)OrderTicket();
      action="get";
   }
   else if (id>-1 && action!="clear") {
      action="set";
   }
   
   if (action=="set") {
   //- Set Position ID
      ArrayValue(memory,(int)id);
      return(true);
   }
   else if (action=="clear") {
   //- Unset Position ID
      ArrayStrip(memory,(int)id);
      return(true);
   }
   else if (action=="get") {
   //- Get State
      return(InArray(memory,(int)id));
   }
   
   Print("Error: The second parameter of the function \"PositionModified\" should be \"set\", \"get\" or \"clear\"");
   return (false);
}
int SellNow(
   string symbol,
   double lots,
   double sll,
   double tpl,
   double slp,
   double tpp,
   double slippage=0,
   int magic=0,
   string comment=""
   )
{
   bool success=OrderCreate(
      symbol,
      POSITION_TYPE_SELL,
      lots,
      0,
      sll,
      tpl,
      slp,
      tpp,
      slippage,
      magic,
      comment,
      0
      );
   return(success);
}
void SetLastIndicatorData(double value=0, string symbol="", int timeframe=0, int shift=0)
{
   LastIndicatorValue(true,value);
   LastIndicatorSymbol(true,symbol);
   LastIndicatorTimeframe(true,timeframe);
   LastIndicatorShift(true,shift);
   IndicatorMoreShift(true,0); // reset
   return;
}
string SetSymbol(string symbol="")
{
   if (symbol=="") {symbol=Symbol();}
   GetSymbol(symbol); return(symbol);
}
bool SkipThePass(bool set=false)
{
   static int mem_fid=0;
   static bool mem=false;
   if (set==true) {
      mem=true;
      mem_fid=FXD_CURRENT_FUNCTION_ID;
   }
   else {
      if (mem_fid!=FXD_CURRENT_FUNCTION_ID) {
         mem=false; // reset
         return(false);
      }
      if (mem==true) {
         mem=false; // reset
         return(true);
      }
   }
   return(mem);
}
datetime StrToTime(string value)
{
	return(StringToTime(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++;    
   }
}
string StringImplode(string sDelimiter, string &sImplode[]){
   string slImplode = "";
   for (int i = 0; i < ArraySize(sImplode); i++) {
      StringConcatenate(slImplode, slImplode,sImplode[i],sDelimiter);
   }
   return(StringSubstr(slImplode, 0, (StringLen(slImplode) - StringLen(sDelimiter))));
}
string StringImplode(string sDelimiter, int &sImplode[]){
   string slImplode = "";
   for (int i = 0; i < ArraySize(sImplode); i++) {
      StringConcatenate(slImplode, slImplode,sImplode[i],sDelimiter);
   }
   return(StringSubstr(slImplode, 0, (StringLen(slImplode) - StringLen(sDelimiter))));
}
string StringImplode(string sDelimiter, double &sImplode[]){
   string slImplode = "";
   for (int i = 0; i < ArraySize(sImplode); i++) {
      StringConcatenate(slImplode, slImplode,sImplode[i],sDelimiter);
   }
   return(StringSubstr(slImplode, 0, (StringLen(slImplode) - StringLen(sDelimiter))));
}
string StringTrim(string text)
{
   StringTrimRight(text);
   StringTrimLeft(text);
   return(text);
}
double SymbolAsk(string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(SymbolInfoDouble(symbol,SYMBOL_ASK));
}
double SymbolBid(string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(SymbolInfoDouble(symbol,SYMBOL_BID));
}
int SymbolDigits(string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return((int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));
}
double SymbolLotSize(string symbol="")
{
	if (symbol=="") {symbol=Symbol();}
   return SymbolInfoDouble(symbol,SYMBOL_TRADE_CONTRACT_SIZE);
}
double SymbolLotStep(string symbol="")
{
   if (symbol=="") {symbol=Symbol();}
   return SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP);
}
double SymbolMaxLot(string symbol="")
{
   if (symbol=="") {symbol=Symbol();}
   return (SymbolInfoDouble(symbol,SYMBOL_VOLUME_MAX));
}
double SymbolMinLot(string symbol="")
{
   if (symbol=="") {symbol=Symbol();}
   return (SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN));
}
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 TakeProfit(string mode="buy", double TP=0, double price=0)
{
   double ask=SymbolInfoDouble(GetSymbol(),SYMBOL_ASK);
   double bid=SymbolInfoDouble(GetSymbol(),SYMBOL_BID);
   if (TP!=0 && (mode=="buy" || mode=="")) {if (price>0) {ask=price;} TP=ask+toDigits(TP);}
   if (TP!=0 && mode=="sell") {if (price>0) {bid=price;} TP=bid-toDigits(TP);}
   return(TP);
}
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; int size=0; int i=0; int 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 (symbol=="") {symbol=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 (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 TicksFromStart(bool upd=false)
{
   static int ticks=1;
   if (upd==true) {ticks++; if (ticks<0) ticks=0;}
   return(ticks);
}
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(bool local_time=false, int y=0, int m=0, int d=0, int h=0, int i=0, int s=0)
{
   MqlDateTime tm;
   if (local_time) {TimeLocal(tm);} else {TimeCurrent(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;
}
double ask(string symbol="")
{
   if (symbol=="") {symbol=GetSymbol();}
   return(SymbolInfoDouble(symbol,SYMBOL_ASK));
}
double attrCommission() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_COMMISSION));}
   if (LoadedType()==3){return(HistoryDealGetDouble(attrTicket(),DEAL_COMMISSION));}
   if (LoadedType()==4){return(0);}
   return(0);
}
double attrLots() {return(attrVolume());}
double attrOpenPrice() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_PRICE_OPEN));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(attrTicket(),DEAL_POSITION_ID),ORDER_PRICE_CURRENT));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(attrTicket(),ORDER_PRICE_OPEN));}
   return(OrderGetDouble(ORDER_PRICE_OPEN));
}
datetime attrOpenTime() {
   if (LoadedType()==1){return((datetime)PositionGetInteger(POSITION_TIME));}
   if (LoadedType()==3){return((datetime)HistoryOrderGetInteger(HistoryDealGetInteger(attrTicket(),DEAL_POSITION_ID),ORDER_TIME_SETUP));}
   if (LoadedType()==4){return((datetime)HistoryOrderGetInteger(attrTicket(),ORDER_TIME_SETUP));}
   return((datetime)OrderGetInteger(ORDER_TIME_SETUP));
}
double attrProfit() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_PROFIT));}
   if (LoadedType()==3){return(HistoryDealGetDouble(attrTicket(),DEAL_PROFIT));}
   if (LoadedType()==4){return(0);}
   return(0);
}
double attrStopLoss() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_SL));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(attrTicket(),DEAL_POSITION_ID),ORDER_SL));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(attrTicket(),ORDER_SL));}
   return(OrderGetDouble(ORDER_SL));
}
double attrSwap() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_SWAP));}
   if (LoadedType()==3){return(HistoryDealGetDouble(attrTicket(),DEAL_SWAP));}
   if (LoadedType()==4){return(0);}
   return(0);
}
string attrSymbol()
{
   if (LoadedType()==1){return(PositionGetString(POSITION_SYMBOL));}
   if (LoadedType()==3){return(HistoryDealGetString(attrTicket(),DEAL_SYMBOL));}
   if (LoadedType()==4){return(HistoryOrderGetString(attrTicket(),ORDER_SYMBOL));}
   return(OrderGetString(ORDER_SYMBOL));
}
string attrSymbolInLoop(string symbol="")
{
   static string s;
   if (symbol!="") {s=symbol;}
   return(s);
}
double attrTakeProfit() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_TP));}
   if (LoadedType()==3){return(HistoryOrderGetDouble(HistoryDealGetInteger(attrTicket(),DEAL_POSITION_ID),ORDER_TP));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(attrTicket(),ORDER_TP));}
   return(OrderGetDouble(ORDER_TP));
}
ulong attrTicket(ulong Ticket=0)
{
   return(OrderTicket(Ticket));
}
int attrTicketInLoop(int ticket=0)
{
   static int t;
   if (ticket>0) {t=ticket;}
   return(t);
}
int attrType() {
   if (LoadedType()==1){return((int)PositionGetInteger(POSITION_TYPE));}
   if (LoadedType()==3){
      int OT=(int)HistoryDealGetInteger(attrTicket(),DEAL_TYPE);
      if(OT==1){return(0);}
      if(OT==0){return(1);}
      return(OT);
   }
   if (LoadedType()==4){return((int)HistoryOrderGetInteger(attrTicket(),ORDER_TYPE));}
   return((int)OrderGetInteger(ORDER_TYPE));
}
double attrVolume() {
   if (LoadedType()==1){return(PositionGetDouble(POSITION_VOLUME));}
   if (LoadedType()==3){return(HistoryDealGetDouble(attrTicket(),DEAL_VOLUME));}
   if (LoadedType()==4){return(HistoryOrderGetDouble(attrTicket(),ORDER_VOLUME_INITIAL));}
   return(OrderGetDouble(ORDER_VOLUME_CURRENT));
}
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 iBarShift(string symbol,int timeframe,datetime time,bool exact=false)
{
   if(time<0) return(-1);
   ENUM_TIMEFRAMES tf=TFMigrate(timeframe);
   datetime Arr[],time1;
   CopyTime(symbol,tf,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,tf,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
}
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)
   {
      //-- calculate the current period minutes
      //-- we need to calculate the difference in time between 2 candles
      // but because we have holidays, we will compare 2 neighbour candles until we get the same time difference
      int i=0;   
      while(true)
      {
         mins_tf = (int)(iTime(SYMBOL, TIMEFRAME, i) - iTime(SYMBOL, TIMEFRAME, i+1));
   
         if (mins_tf0 == mins_tf) {break;}
         mins_tf0 = mins_tf;
         i++;
      }
      mins_tf = mins_tf / 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
   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--;
   }
   
   return CandleID;
}
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 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;

	if (symbol=="") {symbol=GetSymbol();}
	if (symbol==last_symbol) {return(last_point);}

	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);
				break;
			}
			i++;
			if (i>=size) {i=0;}
			if (i==start_i) {break;}
		}
	}

	if (SymbolInfoInteger(symbol, SYMBOL_TIME)<=0) {Print("Market "+symbol+" does not exists!"); return(0);}

	i=size;
	size=size+1;
	ArrayResize(symbols, size);
	ArrayResize(points, size);
	symbols[i]=symbol;
	points[i]=0;
	last_symbol=symbol;
	last_i=i;

	if (points[i]==0) {points[i]=SymbolInfoDouble(symbol, SYMBOL_POINT);}
	last_point=points[i];
	return(last_point);
}

string fxD_BlocksLookupTable(int cmd=0, string id="", bool onoff=false, bool toggle=false)
{
	int intID=0;
	bool notfound=false;

	while(true)
	{
		intID=(int)StringToInteger(id);
		break;
	}
	switch(intID)
	{
		case 1: if(!cmd){block1();}else if(cmd==1){block1=onoff;}else if(cmd==2){block1=!(block1);}break;
		case 2: if(!cmd){block2();}else if(cmd==1){block2=onoff;}else if(cmd==2){block2=!(block2);}else if(cmd==3){return("43");}break;
		case 3: if(!cmd){block3();}else if(cmd==1){block3=onoff;}else if(cmd==2){block3=!(block3);}else if(cmd==3){return("2");}break;
		case 4: if(!cmd){block4();}else if(cmd==1){block4=onoff;}else if(cmd==2){block4=!(block4);}else if(cmd==3){return("11");}break;
		case 5: if(!cmd){block5();}else if(cmd==1){block5=onoff;}else if(cmd==2){block5=!(block5);}else if(cmd==3){return("4");}break;
		case 6: if(!cmd){block6();}else if(cmd==1){block6=onoff;}else if(cmd==2){block6=!(block6);}else if(cmd==3){return("4,5");}break;
		case 7: if(!cmd){block7();}else if(cmd==1){block7=onoff;}else if(cmd==2){block7=!(block7);}else if(cmd==3){return("2");}break;
		case 8: if(!cmd){block8();}else if(cmd==1){block8=onoff;}else if(cmd==2){block8=!(block8);}else if(cmd==3){return("17");}break;
		case 9: if(!cmd){block9();}else if(cmd==1){block9=onoff;}else if(cmd==2){block9=!(block9);}else if(cmd==3){return("8");}break;
		case 10: if(!cmd){block10();}else if(cmd==1){block10=onoff;}else if(cmd==2){block10=!(block10);}else if(cmd==3){return("8,9");}break;
		case 11: if(!cmd){block11();}else if(cmd==1){block11=onoff;}else if(cmd==2){block11=!(block11);}else if(cmd==3){return("3");}break;
		case 12: if(!cmd){block12();}else if(cmd==1){block12=onoff;}else if(cmd==2){block12=!(block12);}else if(cmd==3){return("13");}break;
		case 13: if(!cmd){block13();}else if(cmd==1){block13=onoff;}else if(cmd==2){block13=!(block13);}else if(cmd==3){return("11");}break;
		case 14: if(!cmd){block14();}else if(cmd==1){block14=onoff;}else if(cmd==2){block14=!(block14);}else if(cmd==3){return("12");}break;
		case 15: if(!cmd){block15();}else if(cmd==1){block15=onoff;}else if(cmd==2){block15=!(block15);}else if(cmd==3){return("14");}break;
		case 16: if(!cmd){block16();}else if(cmd==1){block16=onoff;}else if(cmd==2){block16=!(block16);}else if(cmd==3){return("13");}break;
		case 17: if(!cmd){block17();}else if(cmd==1){block17=onoff;}else if(cmd==2){block17=!(block17);}else if(cmd==3){return("7");}break;
		case 18: if(!cmd){block18();}else if(cmd==1){block18=onoff;}else if(cmd==2){block18=!(block18);}else if(cmd==3){return("19");}break;
		case 19: if(!cmd){block19();}else if(cmd==1){block19=onoff;}else if(cmd==2){block19=!(block19);}else if(cmd==3){return("17");}break;
		case 20: if(!cmd){block20();}else if(cmd==1){block20=onoff;}else if(cmd==2){block20=!(block20);}else if(cmd==3){return("18");}break;
		case 21: if(!cmd){block21();}else if(cmd==1){block21=onoff;}else if(cmd==2){block21=!(block21);}else if(cmd==3){return("20");}break;
		case 22: if(!cmd){block22();}else if(cmd==1){block22=onoff;}else if(cmd==2){block22=!(block22);}else if(cmd==3){return("19");}break;
		case 23: if(!cmd){block23();}else if(cmd==1){block23=onoff;}else if(cmd==2){block23=!(block23);}else if(cmd==3){return("43");}break;
		case 24: if(!cmd){block24();}else if(cmd==1){block24=onoff;}else if(cmd==2){block24=!(block24);}else if(cmd==3){return("26");}break;
		case 25: if(!cmd){block25();}else if(cmd==1){block25=onoff;}else if(cmd==2){block25=!(block25);}else if(cmd==3){return("24");}break;
		case 26: if(!cmd){block26();}else if(cmd==1){block26=onoff;}else if(cmd==2){block26=!(block26);}else if(cmd==3){return("27");}break;
		case 27: if(!cmd){block27();}else if(cmd==1){block27=onoff;}else if(cmd==2){block27=!(block27);}else if(cmd==3){return("175");}break;
		case 28: if(!cmd){block28();}else if(cmd==1){block28=onoff;}else if(cmd==2){block28=!(block28);}else if(cmd==3){return("26");}break;
		case 29: if(!cmd){block29();}else if(cmd==1){block29=onoff;}else if(cmd==2){block29=!(block29);}else if(cmd==3){return("27");}break;
		case 33: if(!cmd){block33();}else if(cmd==1){block33=onoff;}else if(cmd==2){block33=!(block33);}else if(cmd==3){return("148");}break;
		case 34: if(!cmd){block34();}else if(cmd==1){block34=onoff;}else if(cmd==2){block34=!(block34);}else if(cmd==3){return("248");}break;
		case 35: if(!cmd){block35();}else if(cmd==1){block35=onoff;}else if(cmd==2){block35=!(block35);}else if(cmd==3){return("199");}break;
		case 37: if(!cmd){block37();}else if(cmd==1){block37=onoff;}else if(cmd==2){block37=!(block37);}else if(cmd==3){return("34");}break;
		case 41: if(!cmd){block41();}else if(cmd==1){block41=onoff;}else if(cmd==2){block41=!(block41);}else if(cmd==3){return("56");}break;
		case 43: if(!cmd){block43();}else if(cmd==1){block43=onoff;}else if(cmd==2){block43=!(block43);}else if(cmd==3){return("51");}break;
		case 51: if(!cmd){block51();}else if(cmd==1){block51=onoff;}else if(cmd==2){block51=!(block51);}else if(cmd==3){return("175");}break;
		case 52: if(!cmd){block52();}else if(cmd==1){block52=onoff;}else if(cmd==2){block52=!(block52);}else if(cmd==3){return("37");}break;
		case 53: if(!cmd){block53();}else if(cmd==1){block53=onoff;}else if(cmd==2){block53=!(block53);}else if(cmd==3){return("52");}break;
		case 54: if(!cmd){block54();}else if(cmd==1){block54=onoff;}else if(cmd==2){block54=!(block54);}else if(cmd==3){return("41");}break;
		case 55: if(!cmd){block55();}else if(cmd==1){block55=onoff;}else if(cmd==2){block55=!(block55);}else if(cmd==3){return("41");}break;
		case 56: if(!cmd){block56();}else if(cmd==1){block56=onoff;}else if(cmd==2){block56=!(block56);}else if(cmd==3){return("51");}break;
		case 57: if(!cmd){block57();}else if(cmd==1){block57=onoff;}else if(cmd==2){block57=!(block57);}else if(cmd==3){return("56");}break;
		case 59: if(!cmd){block59();}else if(cmd==1){block59=onoff;}else if(cmd==2){block59=!(block59);}else if(cmd==3){return("57");}break;
		case 69: if(!cmd){block69();}else if(cmd==1){block69=onoff;}else if(cmd==2){block69=!(block69);}else if(cmd==3){return("259");}break;
		case 70: if(!cmd){block70();}else if(cmd==1){block70=onoff;}else if(cmd==2){block70=!(block70);}else if(cmd==3){return("296");}break;
		case 75: if(!cmd){block75();}else if(cmd==1){block75=onoff;}else if(cmd==2){block75=!(block75);}else if(cmd==3){return("298");}break;
		case 76: if(!cmd){block76();}else if(cmd==1){block76=onoff;}else if(cmd==2){block76=!(block76);}else if(cmd==3){return("53");}break;
		case 77: if(!cmd){block77();}else if(cmd==1){block77=onoff;}else if(cmd==2){block77=!(block77);}else if(cmd==3){return("76");}break;
		case 86: if(!cmd){block86();}else if(cmd==1){block86=onoff;}else if(cmd==2){block86=!(block86);}else if(cmd==3){return("77");}break;
		case 87: if(!cmd){block87();}else if(cmd==1){block87=onoff;}else if(cmd==2){block87=!(block87);}else if(cmd==3){return("86");}break;
		case 88: if(!cmd){block88();}else if(cmd==1){block88=onoff;}else if(cmd==2){block88=!(block88);}else if(cmd==3){return("70");}break;
		case 89: if(!cmd){block89();}else if(cmd==1){block89=onoff;}else if(cmd==2){block89=!(block89);}else if(cmd==3){return("88,92");}break;
		case 90: if(!cmd){block90();}else if(cmd==1){block90=onoff;}else if(cmd==2){block90=!(block90);}else if(cmd==3){return("88,92");}break;
		case 91: if(!cmd){block91();}else if(cmd==1){block91=onoff;}else if(cmd==2){block91=!(block91);}else if(cmd==3){return("90");}break;
		case 92: if(!cmd){block92();}else if(cmd==1){block92=onoff;}else if(cmd==2){block92=!(block92);}else if(cmd==3){return("75");}break;
		case 93: if(!cmd){block93();}else if(cmd==1){block93=onoff;}else if(cmd==2){block93=!(block93);}else if(cmd==3){return("59");}break;
		case 94: if(!cmd){block94();}else if(cmd==1){block94=onoff;}else if(cmd==2){block94=!(block94);}else if(cmd==3){return("98");}break;
		case 95: if(!cmd){block95();}else if(cmd==1){block95=onoff;}else if(cmd==2){block95=!(block95);}else if(cmd==3){return("97");}break;
		case 96: if(!cmd){block96();}else if(cmd==1){block96=onoff;}else if(cmd==2){block96=!(block96);}else if(cmd==3){return("59");}break;
		case 97: if(!cmd){block97();}else if(cmd==1){block97=onoff;}else if(cmd==2){block97=!(block97);}else if(cmd==3){return("96");}break;
		case 98: if(!cmd){block98();}else if(cmd==1){block98=onoff;}else if(cmd==2){block98=!(block98);}else if(cmd==3){return("96");}break;
		case 99: if(!cmd){block99();}else if(cmd==1){block99=onoff;}else if(cmd==2){block99=!(block99);}else if(cmd==3){return("70,75");}break;
		case 102: if(!cmd){block102();}else if(cmd==1){block102=onoff;}else if(cmd==2){block102=!(block102);}else if(cmd==3){return("54,55");}break;
		case 103: if(!cmd){block103();}else if(cmd==1){block103=onoff;}else if(cmd==2){block103=!(block103);}else if(cmd==3){return("54,55");}break;
		case 104: if(!cmd){block104();}else if(cmd==1){block104=onoff;}else if(cmd==2){block104=!(block104);}else if(cmd==3){return("102,103");}break;
		case 106: if(!cmd){block106();}else if(cmd==1){block106=onoff;}else if(cmd==2){block106=!(block106);}break;
		case 107: if(!cmd){block107();}else if(cmd==1){block107=onoff;}else if(cmd==2){block107=!(block107);}else if(cmd==3){return("106");}break;
		case 108: if(!cmd){block108();}else if(cmd==1){block108=onoff;}else if(cmd==2){block108=!(block108);}else if(cmd==3){return("93");}break;
		case 109: if(!cmd){block109();}else if(cmd==1){block109=onoff;}else if(cmd==2){block109=!(block109);}else if(cmd==3){return("114");}break;
		case 110: if(!cmd){block110();}else if(cmd==1){block110=onoff;}else if(cmd==2){block110=!(block110);}else if(cmd==3){return("116");}break;
		case 111: if(!cmd){block111();}else if(cmd==1){block111=onoff;}else if(cmd==2){block111=!(block111);}else if(cmd==3){return("93");}break;
		case 112: if(!cmd){block112();}else if(cmd==1){block112=onoff;}else if(cmd==2){block112=!(block112);}else if(cmd==3){return("111");}break;
		case 113: if(!cmd){block113();}else if(cmd==1){block113=onoff;}else if(cmd==2){block113=!(block113);}else if(cmd==3){return("112");}break;
		case 114: if(!cmd){block114();}else if(cmd==1){block114=onoff;}else if(cmd==2){block114=!(block114);}else if(cmd==3){return("111");}break;
		case 115: if(!cmd){block115();}else if(cmd==1){block115=onoff;}else if(cmd==2){block115=!(block115);}else if(cmd==3){return("109");}break;
		case 116: if(!cmd){block116();}else if(cmd==1){block116=onoff;}else if(cmd==2){block116=!(block116);}else if(cmd==3){return("111");}break;
		case 117: if(!cmd){block117();}else if(cmd==1){block117=onoff;}else if(cmd==2){block117=!(block117);}else if(cmd==3){return("110");}break;
		case 118: if(!cmd){block118();}else if(cmd==1){block118=onoff;}else if(cmd==2){block118=!(block118);}else if(cmd==3){return("113,136,135");}break;
		case 119: if(!cmd){block119();}else if(cmd==1){block119=onoff;}else if(cmd==2){block119=!(block119);}else if(cmd==3){return("124");}break;
		case 120: if(!cmd){block120();}else if(cmd==1){block120=onoff;}else if(cmd==2){block120=!(block120);}else if(cmd==3){return("119,123");}break;
		case 121: if(!cmd){block121();}else if(cmd==1){block121=onoff;}else if(cmd==2){block121=!(block121);}else if(cmd==3){return("119,123");}break;
		case 122: if(!cmd){block122();}else if(cmd==1){block122=onoff;}else if(cmd==2){block122=!(block122);}else if(cmd==3){return("121");}break;
		case 123: if(!cmd){block123();}else if(cmd==1){block123=onoff;}else if(cmd==2){block123=!(block123);}else if(cmd==3){return("125");}break;
		case 124: if(!cmd){block124();}else if(cmd==1){block124=onoff;}else if(cmd==2){block124=!(block124);}else if(cmd==3){return("133");}break;
		case 125: if(!cmd){block125();}else if(cmd==1){block125=onoff;}else if(cmd==2){block125=!(block125);}else if(cmd==3){return("134");}break;
		case 126: if(!cmd){block126();}else if(cmd==1){block126=onoff;}else if(cmd==2){block126=!(block126);}else if(cmd==3){return("127");}break;
		case 127: if(!cmd){block127();}else if(cmd==1){block127=onoff;}else if(cmd==2){block127=!(block127);}else if(cmd==3){return("161");}break;
		case 128: if(!cmd){block128();}else if(cmd==1){block128=onoff;}else if(cmd==2){block128=!(block128);}else if(cmd==3){return("127");}break;
		case 129: if(!cmd){block129();}else if(cmd==1){block129=onoff;}else if(cmd==2){block129=!(block129);}else if(cmd==3){return("128");}break;
		case 130: if(!cmd){block130();}else if(cmd==1){block130=onoff;}else if(cmd==2){block130=!(block130);}else if(cmd==3){return("126");}break;
		case 131: if(!cmd){block131();}else if(cmd==1){block131=onoff;}else if(cmd==2){block131=!(block131);}else if(cmd==3){return("129");}break;
		case 132: if(!cmd){block132();}else if(cmd==1){block132=onoff;}else if(cmd==2){block132=!(block132);}else if(cmd==3){return("133,134");}break;
		case 133: if(!cmd){block133();}else if(cmd==1){block133=onoff;}else if(cmd==2){block133=!(block133);}else if(cmd==3){return("136");}break;
		case 134: if(!cmd){block134();}else if(cmd==1){block134=onoff;}else if(cmd==2){block134=!(block134);}else if(cmd==3){return("135");}break;
		case 135: if(!cmd){block135();}else if(cmd==1){block135=onoff;}else if(cmd==2){block135=!(block135);}else if(cmd==3){return("129");}break;
		case 136: if(!cmd){block136();}else if(cmd==1){block136=onoff;}else if(cmd==2){block136=!(block136);}else if(cmd==3){return("126");}break;
		case 147: if(!cmd){block147();}else if(cmd==1){block147=onoff;}else if(cmd==2){block147=!(block147);}else if(cmd==3){return("247");}break;
		case 148: if(!cmd){block148();}else if(cmd==1){block148=onoff;}else if(cmd==2){block148=!(block148);}else if(cmd==3){return("147");}break;
		case 150: if(!cmd){block150();}else if(cmd==1){block150=onoff;}else if(cmd==2){block150=!(block150);}else if(cmd==3){return("133,134");}break;
		case 151: if(!cmd){block151();}else if(cmd==1){block151=onoff;}else if(cmd==2){block151=!(block151);}else if(cmd==3){return("1");}break;
		case 154: if(!cmd){block154();}else if(cmd==1){block154=onoff;}else if(cmd==2){block154=!(block154);}else if(cmd==3){return("151");}break;
		case 155: if(!cmd){block155();}else if(cmd==1){block155=onoff;}else if(cmd==2){block155=!(block155);}else if(cmd==3){return("174,173");}break;
		case 156: if(!cmd){block156();}else if(cmd==1){block156=onoff;}else if(cmd==2){block156=!(block156);}else if(cmd==3){return("158");}break;
		case 157: if(!cmd){block157();}else if(cmd==1){block157=onoff;}else if(cmd==2){block157=!(block157);}else if(cmd==3){return("156");}break;
		case 158: if(!cmd){block158();}else if(cmd==1){block158=onoff;}else if(cmd==2){block158=!(block158);}else if(cmd==3){return("155");}break;
		case 159: if(!cmd){block159();}else if(cmd==1){block159=onoff;}else if(cmd==2){block159=!(block159);}else if(cmd==3){return("157");}break;
		case 160: if(!cmd){block160();}else if(cmd==1){block160=onoff;}else if(cmd==2){block160=!(block160);}else if(cmd==3){return("1");}break;
		case 161: if(!cmd){block161();}else if(cmd==1){block161=onoff;}else if(cmd==2){block161=!(block161);}else if(cmd==3){return("113");}break;
		case 173: if(!cmd){block173();}else if(cmd==1){block173=onoff;}else if(cmd==2){block173=!(block173);}else if(cmd==3){return("186");}break;
		case 174: if(!cmd){block174();}else if(cmd==1){block174=onoff;}else if(cmd==2){block174=!(block174);}else if(cmd==3){return("186");}break;
		case 175: if(!cmd){block175();}else if(cmd==1){block175=onoff;}else if(cmd==2){block175=!(block175);}else if(cmd==3){return("160");}break;
		case 186: if(!cmd){block186();}else if(cmd==1){block186=onoff;}else if(cmd==2){block186=!(block186);}else if(cmd==3){return("154");}break;
		case 189: if(!cmd){block189();}else if(cmd==1){block189=onoff;}else if(cmd==2){block189=!(block189);}else if(cmd==3){return("207");}break;
		case 190: if(!cmd){block190();}else if(cmd==1){block190=onoff;}else if(cmd==2){block190=!(block190);}else if(cmd==3){return("207");}break;
		case 191: if(!cmd){block191();}else if(cmd==1){block191=onoff;}else if(cmd==2){block191=!(block191);}else if(cmd==3){return("208");}break;
		case 192: if(!cmd){block192();}else if(cmd==1){block192=onoff;}else if(cmd==2){block192=!(block192);}else if(cmd==3){return("208");}break;
		case 193: if(!cmd){block193();}else if(cmd==1){block193=onoff;}else if(cmd==2){block193=!(block193);}else if(cmd==3){return("211");}break;
		case 194: if(!cmd){block194();}else if(cmd==1){block194=onoff;}else if(cmd==2){block194=!(block194);}else if(cmd==3){return("189,190,208");}break;
		case 195: if(!cmd){block195();}else if(cmd==1){block195=onoff;}else if(cmd==2){block195=!(block195);}else if(cmd==3){return("253");}break;
		case 196: if(!cmd){block196();}else if(cmd==1){block196=onoff;}else if(cmd==2){block196=!(block196);}else if(cmd==3){return("193");}break;
		case 197: if(!cmd){block197();}else if(cmd==1){block197=onoff;}else if(cmd==2){block197=!(block197);}else if(cmd==3){return("196");}break;
		case 199: if(!cmd){block199();}else if(cmd==1){block199=onoff;}else if(cmd==2){block199=!(block199);}else if(cmd==3){return("23");}break;
		case 201: if(!cmd){block201();}else if(cmd==1){block201=onoff;}else if(cmd==2){block201=!(block201);}else if(cmd==3){return("87");}break;
		case 207: if(!cmd){block207();}else if(cmd==1){block207=onoff;}else if(cmd==2){block207=!(block207);}else if(cmd==3){return("195");}break;
		case 208: if(!cmd){block208();}else if(cmd==1){block208=onoff;}else if(cmd==2){block208=!(block208);}else if(cmd==3){return("195");}break;
		case 210: if(!cmd){block210();}else if(cmd==1){block210=onoff;}else if(cmd==2){block210=!(block210);}else if(cmd==3){return("191,192,207");}break;
		case 211: if(!cmd){block211();}else if(cmd==1){block211=onoff;}else if(cmd==2){block211=!(block211);}else if(cmd==3){return("189,190,191,192");}break;
		case 230: if(!cmd){block230();}else if(cmd==1){block230=onoff;}else if(cmd==2){block230=!(block230);}else if(cmd==3){return("240");}break;
		case 231: if(!cmd){block231();}else if(cmd==1){block231=onoff;}else if(cmd==2){block231=!(block231);}else if(cmd==3){return("230");}break;
		case 232: if(!cmd){block232();}else if(cmd==1){block232=onoff;}else if(cmd==2){block232=!(block232);}else if(cmd==3){return("230");}break;
		case 233: if(!cmd){block233();}else if(cmd==1){block233=onoff;}else if(cmd==2){block233=!(block233);}else if(cmd==3){return("232");}break;
		case 234: if(!cmd){block234();}else if(cmd==1){block234=onoff;}else if(cmd==2){block234=!(block234);}else if(cmd==3){return("233");}break;
		case 237: if(!cmd){block237();}else if(cmd==1){block237=onoff;}else if(cmd==2){block237=!(block237);}else if(cmd==3){return("234");}break;
		case 238: if(!cmd){block238();}else if(cmd==1){block238=onoff;}else if(cmd==2){block238=!(block238);}else if(cmd==3){return("241");}break;
		case 239: if(!cmd){block239();}else if(cmd==1){block239=onoff;}else if(cmd==2){block239=!(block239);}else if(cmd==3){return("327");}break;
		case 240: if(!cmd){block240();}else if(cmd==1){block240=onoff;}else if(cmd==2){block240=!(block240);}else if(cmd==3){return("238,243");}break;
		case 241: if(!cmd){block241();}else if(cmd==1){block241=onoff;}else if(cmd==2){block241=!(block241);}else if(cmd==3){return("33,315");}break;
		case 242: if(!cmd){block242();}else if(cmd==1){block242=onoff;}else if(cmd==2){block242=!(block242);}else if(cmd==3){return("305");}break;
		case 243: if(!cmd){block243();}else if(cmd==1){block243=onoff;}else if(cmd==2){block243=!(block243);}else if(cmd==3){return("242");}break;
		case 244: if(!cmd){block244();}else if(cmd==1){block244=onoff;}else if(cmd==2){block244=!(block244);}else if(cmd==3){return("328");}break;
		case 245: if(!cmd){block245();}else if(cmd==1){block245=onoff;}else if(cmd==2){block245=!(block245);}else if(cmd==3){return("201");}break;
		case 246: if(!cmd){block246();}else if(cmd==1){block246=onoff;}else if(cmd==2){block246=!(block246);}else if(cmd==3){return("244,328");}break;
		case 247: if(!cmd){block247();}else if(cmd==1){block247=onoff;}else if(cmd==2){block247=!(block247);}else if(cmd==3){return("35");}break;
		case 248: if(!cmd){block248();}else if(cmd==1){block248=onoff;}else if(cmd==2){block248=!(block248);}else if(cmd==3){return("250");}break;
		case 249: if(!cmd){block249();}else if(cmd==1){block249=onoff;}else if(cmd==2){block249=!(block249);}else if(cmd==3){return("175");}break;
		case 250: if(!cmd){block250();}else if(cmd==1){block250=onoff;}else if(cmd==2){block250=!(block250);}else if(cmd==3){return("35");}break;
		case 251: if(!cmd){block251();}else if(cmd==1){block251=onoff;}else if(cmd==2){block251=!(block251);}else if(cmd==3){return("175");}break;
		case 252: if(!cmd){block252();}else if(cmd==1){block252=onoff;}else if(cmd==2){block252=!(block252);}else if(cmd==3){return("197");}break;
		case 253: if(!cmd){block253();}else if(cmd==1){block253=onoff;}else if(cmd==2){block253=!(block253);}else if(cmd==3){return("23");}break;
		case 254: if(!cmd){block254();}else if(cmd==1){block254=onoff;}else if(cmd==2){block254=!(block254);}else if(cmd==3){return("175");}break;
		case 255: if(!cmd){block255();}else if(cmd==1){block255=onoff;}else if(cmd==2){block255=!(block255);}else if(cmd==3){return("254");}break;
		case 256: if(!cmd){block256();}else if(cmd==1){block256=onoff;}else if(cmd==2){block256=!(block256);}else if(cmd==3){return("257");}break;
		case 257: if(!cmd){block257();}else if(cmd==1){block257=onoff;}else if(cmd==2){block257=!(block257);}else if(cmd==3){return("263");}break;
		case 258: if(!cmd){block258();}else if(cmd==1){block258=onoff;}else if(cmd==2){block258=!(block258);}else if(cmd==3){return("256");}break;
		case 259: if(!cmd){block259();}else if(cmd==1){block259=onoff;}else if(cmd==2){block259=!(block259);}else if(cmd==3){return("256");}break;
		case 260: if(!cmd){block260();}else if(cmd==1){block260=onoff;}else if(cmd==2){block260=!(block260);}else if(cmd==3){return("259");}break;
		case 261: if(!cmd){block261();}else if(cmd==1){block261=onoff;}else if(cmd==2){block261=!(block261);}else if(cmd==3){return("263");}break;
		case 262: if(!cmd){block262();}else if(cmd==1){block262=onoff;}else if(cmd==2){block262=!(block262);}else if(cmd==3){return("263");}break;
		case 263: if(!cmd){block263();}else if(cmd==1){block263=onoff;}else if(cmd==2){block263=!(block263);}else if(cmd==3){return("282");}break;
		case 264: if(!cmd){block264();}else if(cmd==1){block264=onoff;}else if(cmd==2){block264=!(block264);}else if(cmd==3){return("262");}break;
		case 265: if(!cmd){block265();}else if(cmd==1){block265=onoff;}else if(cmd==2){block265=!(block265);}else if(cmd==3){return("261");}break;
		case 266: if(!cmd){block266();}else if(cmd==1){block266=onoff;}else if(cmd==2){block266=!(block266);}else if(cmd==3){return("262");}break;
		case 267: if(!cmd){block267();}else if(cmd==1){block267=onoff;}else if(cmd==2){block267=!(block267);}else if(cmd==3){return("261");}break;
		case 272: if(!cmd){block272();}else if(cmd==1){block272=onoff;}else if(cmd==2){block272=!(block272);}else if(cmd==3){return("273");}break;
		case 273: if(!cmd){block273();}else if(cmd==1){block273=onoff;}else if(cmd==2){block273=!(block273);}else if(cmd==3){return("267");}break;
		case 277: if(!cmd){block277();}else if(cmd==1){block277=onoff;}else if(cmd==2){block277=!(block277);}else if(cmd==3){return("266");}break;
		case 278: if(!cmd){block278();}else if(cmd==1){block278=onoff;}else if(cmd==2){block278=!(block278);}else if(cmd==3){return("277");}break;
		case 282: if(!cmd){block282();}else if(cmd==1){block282=onoff;}else if(cmd==2){block282=!(block282);}else if(cmd==3){return("108");}break;
		case 283: if(!cmd){block283();}else if(cmd==1){block283=onoff;}else if(cmd==2){block283=!(block283);}else if(cmd==3){return("282");}break;
		case 284: if(!cmd){block284();}else if(cmd==1){block284=onoff;}else if(cmd==2){block284=!(block284);}else if(cmd==3){return("283");}break;
		case 285: if(!cmd){block285();}else if(cmd==1){block285=onoff;}else if(cmd==2){block285=!(block285);}else if(cmd==3){return("284");}break;
		case 286: if(!cmd){block286();}else if(cmd==1){block286=onoff;}else if(cmd==2){block286=!(block286);}else if(cmd==3){return("287");}break;
		case 287: if(!cmd){block287();}else if(cmd==1){block287=onoff;}else if(cmd==2){block287=!(block287);}else if(cmd==3){return("283");}break;
		case 288: if(!cmd){block288();}else if(cmd==1){block288=onoff;}else if(cmd==2){block288=!(block288);}else if(cmd==3){return("286");}break;
		case 289: if(!cmd){block289();}else if(cmd==1){block289=onoff;}else if(cmd==2){block289=!(block289);}else if(cmd==3){return("285,288");}break;
		case 291: if(!cmd){block291();}else if(cmd==1){block291=onoff;}else if(cmd==2){block291=!(block291);}else if(cmd==3){return("317");}break;
		case 292: if(!cmd){block292();}else if(cmd==1){block292=onoff;}else if(cmd==2){block292=!(block292);}else if(cmd==3){return("291");}break;
		case 293: if(!cmd){block293();}else if(cmd==1){block293=onoff;}else if(cmd==2){block293=!(block293);}else if(cmd==3){return("316");}break;
		case 294: if(!cmd){block294();}else if(cmd==1){block294=onoff;}else if(cmd==2){block294=!(block294);}else if(cmd==3){return("293");}break;
		case 295: if(!cmd){block295();}else if(cmd==1){block295=onoff;}else if(cmd==2){block295=!(block295);}else if(cmd==3){return("292");}break;
		case 296: if(!cmd){block296();}else if(cmd==1){block296=onoff;}else if(cmd==2){block296=!(block296);}else if(cmd==3){return("295");}break;
		case 297: if(!cmd){block297();}else if(cmd==1){block297=onoff;}else if(cmd==2){block297=!(block297);}else if(cmd==3){return("294");}break;
		case 298: if(!cmd){block298();}else if(cmd==1){block298=onoff;}else if(cmd==2){block298=!(block298);}else if(cmd==3){return("297");}break;
		case 299: if(!cmd){block299();}else if(cmd==1){block299=onoff;}else if(cmd==2){block299=!(block299);}else if(cmd==3){return("197,252");}break;
		case 300: if(!cmd){block300();}else if(cmd==1){block300=onoff;}else if(cmd==2){block300=!(block300);}else if(cmd==3){return("313");}break;
		case 301: if(!cmd){block301();}else if(cmd==1){block301=onoff;}else if(cmd==2){block301=!(block301);}else if(cmd==3){return("300");}break;
		case 302: if(!cmd){block302();}else if(cmd==1){block302=onoff;}else if(cmd==2){block302=!(block302);}else if(cmd==3){return("301");}break;
		case 303: if(!cmd){block303();}else if(cmd==1){block303=onoff;}else if(cmd==2){block303=!(block303);}else if(cmd==3){return("300");}break;
		case 304: if(!cmd){block304();}else if(cmd==1){block304=onoff;}else if(cmd==2){block304=!(block304);}else if(cmd==3){return("303");}break;
		case 305: if(!cmd){block305();}else if(cmd==1){block305=onoff;}else if(cmd==2){block305=!(block305);}else if(cmd==3){return("239,327");}break;
		case 306: if(!cmd){block306();}else if(cmd==1){block306=onoff;}else if(cmd==2){block306=!(block306);}else if(cmd==3){return("304");}break;
		case 307: if(!cmd){block307();}else if(cmd==1){block307=onoff;}else if(cmd==2){block307=!(block307);}else if(cmd==3){return("306");}break;
		case 308: if(!cmd){block308();}else if(cmd==1){block308=onoff;}else if(cmd==2){block308=!(block308);}else if(cmd==3){return("306");}break;
		case 309: if(!cmd){block309();}else if(cmd==1){block309=onoff;}else if(cmd==2){block309=!(block309);}else if(cmd==3){return("307");}break;
		case 311: if(!cmd){block311();}else if(cmd==1){block311=onoff;}else if(cmd==2){block311=!(block311);}else if(cmd==3){return("308,309");}break;
		case 313: if(!cmd){block313();}else if(cmd==1){block313=onoff;}else if(cmd==2){block313=!(block313);}else if(cmd==3){return("305,246");}break;
		case 315: if(!cmd){block315();}else if(cmd==1){block315=onoff;}else if(cmd==2){block315=!(block315);}else if(cmd==3){return("311");}break;
		case 316: if(!cmd){block316();}else if(cmd==1){block316=onoff;}else if(cmd==2){block316=!(block316);}else if(cmd==3){return("266");}break;
		case 317: if(!cmd){block317();}else if(cmd==1){block317=onoff;}else if(cmd==2){block317=!(block317);}else if(cmd==3){return("267");}break;
		case 318: if(!cmd){block318();}else if(cmd==1){block318=onoff;}else if(cmd==2){block318=!(block318);}else if(cmd==3){return("29");}break;
		case 322: if(!cmd){block322();}else if(cmd==1){block322=onoff;}else if(cmd==2){block322=!(block322);}else if(cmd==3){return("29");}break;
		case 323: if(!cmd){block323();}else if(cmd==1){block323=onoff;}else if(cmd==2){block323=!(block323);}else if(cmd==3){return("318");}break;
		case 324: if(!cmd){block324();}else if(cmd==1){block324=onoff;}else if(cmd==2){block324=!(block324);}else if(cmd==3){return("322");}break;
		case 327: if(!cmd){block327();}else if(cmd==1){block327=onoff;}else if(cmd==2){block327=!(block327);}else if(cmd==3){return("241");}break;
		case 328: if(!cmd){block328();}else if(cmd==1){block328=onoff;}else if(cmd==2){block328=!(block328);}else if(cmd==3){return("242");}break;
		case 329: if(!cmd){block329();}else if(cmd==1){block329=onoff;}else if(cmd==2){block329=!(block329);}else if(cmd==3){return("315");}break;
		default:notfound=true;
	}
	if (notfound==true) {
		string attempt="";
		if (cmd==0) {attempt=" (attempt to run block)";}
		else if (cmd==1) {
			if (onoff==true) {attempt=" (attempt to turn block ON)";}
			else {attempt=" (attempt to turn block OFF)";}
		}
		else if (cmd==2) {
			attempt=" (attempt to toggle block)";
		}
		else if (cmd==3) {
			attempt=" (attempt to get connections information for block)";
		}
		Alert("fxDreema Error: Block "+id+" was not found for this project!"+attempt);
	}
	return("");
}

//+------------------------------------------------------------------+
//| END                                                              |
//| Created with fxDreema EA Builder           https://fxdreema.com/ |
//+------------------------------------------------------------------+
/*<fxdreema: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
:fxdreema>*/