Navigation:Home > Content >

GEPARD_7_EDU-plus.mq4

Time: 2011-09-20 | Download file:GEPARD_7_EDU-plus.mq4

//------------------------------------------------------------------------
// 2013-07-05 by Capella at http://worldwide-invest.org/
// - No-DLL-version (no need for any DLL-file)
// - Key-protection overruled
// - Minor correction of translated (Russian to English)
// - Fixed compilation warning bugs
// 2013-07-11 by Capella at http://worldwide-invest.org/
// - Added suffix
// 2013-08-15 by bobcsi at http://worldwide-invest.org/
// - added price check in function f0_4() that otherwise could cause unnecessary attempt to modify orders
// 2013-08-15 by Capella at http://worldwide-invest.org/
// - cleaned program code to make it easier to follow 
// - deleted currency pairs that are in wrong order
// - set the default settings to only trade with currencies + gold and silver
// - changed default GMT-offset to 0
// - changed default sUseFlatIndicator to TRUE, as individual tickdata backtests done on all 28 pairs show better performance
// - overruled TestingOneSymbolMode setting so it work for backtesting on individual currencies
//------------------------------------------------------------------------

#property copyright "GEPARD 7 Copyright © 2008-2012, Forex Team"
#property link      "http://plati.ru/asp/pay.asp?id_d=466922"

#include 

// ----------------------------------------- Externals -----------------------------------------------

extern string sNameEA = "_______ GEPARD 7 EDU_______";
extern string sCopyright = "Copyright © 2008-2012, Forex Team";
extern string sContact = "e-mail: forex.ex4@gmail.com";
extern string sSelling = "http://plati.ru/asp/pay.asp?id_d=466922";
extern int AskOpenRecommendedDC = 1;
extern string sSetting = "Place on a EURUSD, on any time frame";
extern string sDescript10 = "_______ 1. Trading Tools _______";
extern string sSymbolSuffix = "";
extern string sDescript11 = "0 - not trade, 1 - trade (BUY&SELL), 2 - only BUY, 3 - only SELL";
extern string sSymbols1 = "AUDCAD: 1; AUDCHF: 1; AUDJPY: 1; AUDNZD: 1; AUDUSD: 1; CADCHF: 1; CADJPY: 1; CHFJPY: 1; EURAUD: 1; EURCAD: 1; EURCHF: 1; EURGBP: 1; EURJPY: 1; EURNZD: 1; EURUSD: 1";
extern string sSymbols2 = "GBPAUD: 1; GBPCAD: 1; GBPCHF: 1; GBPJPY: 1; GBPNZD: 1; GBPUSD: 1; NZDCAD: 1; NZDCHF: 1; NZDJPY: 1; NZDUSD: 1; USDCAD: 1; USDCHF: 1; USDJPY: 1";
extern string sSymbols3 = "#AA: 0; #AIG: 0; #AXP: 0; #BA: 0; #BAC: 0; #CAT: 0; #CSCO: 0; #CVX: 0; #DD: 0; #DIS: 0; #EBAY: 0; #FCX: 0; #FDX: 0; #GE: 0; #GS: 0; #HAL: 0; #HD: 0; #HON: 0; #HPQ: 0; #IBM: 0; #INTC: 0; #IP: 0";
extern string sSymbols4 = "#JNJ: 0; #JPM: 0; #KO: 0; #KFT: 0; #MCD: 0; #MMM: 0; #MO: 0; #MRK: 0; #MSFT: 0; #ORCL: 0; #PEP: 0; #PFE: 0; #PG: 0; #T: 0; #TRV: 0; #UPS: 0; #UTX: 0; #V: 0; #VZ: 0; #WFC: 0; #WMT: 0; #XOM: 0";
extern string sSymbols5 = "XAUUSD: 1; GOLD: 0; XAGUSD: 1; SILVER: 0; #DIA: 0; #FAS: 0; #FXI: 0; #GLD: 0; #QQQ: 0; #SDS: 0; #SMH: 0; #SPY: 0; #SSO: 0; #TLT: 0; #XLI: 0";
extern int CountOfCycles = 5;
extern string sUseBuy = "";
extern string sUseSell = "";
extern int dUseOnlyPlusSwaps = 0;
extern string sUseOnlyPlusSwaps = "";
extern int dMaxSpreadForTradeSymbol = 12;
extern string sMaxSpreadForTradeSymbol = "XAUUSD: 100; GOLD: 100";
extern string sDescript20 = "_________ 2. General Settings _________";
extern double dRisk = 0.005;
extern string sRisk = "";
extern int MaxOrdersCount = 0;
extern int dMaxSymbolOrdersCount = 0;
extern string sMaxSymbolOrdersCount = "";
extern double MaxOpenValPosition = 7.0;
extern int dUseOneWayRealOrdersB = 1;
extern string sUseOneWayRealOrdersB = "";
extern int dUseOneWayRealOrdersS = 1;
extern string sUseOneWayRealOrdersS = "";
extern double dMinDistanceRealOrdersB_PR = 4.0;
extern string sMinDistanceRealOrdersB_PR = "";
extern double dMinDistanceRealOrdersS_PR = 4.0;
extern string sMinDistanceRealOrdersS_PR = "";
extern int dCloseLockedOrdersOnAverage = 0;
extern string sCloseLockedOrdersOnAverage = "";
extern double dCloseLockedMinDistance_PR = 2.0;
extern string sDescript30 = "_______ 3. Generalized take profit, stop loss and trailing _______";
extern int dFixedTakeProfit = 0;
extern string sFixedTakeProfit = "";
extern int dFixedStopLoss = 0;
extern string sFixedStopLoss = "";
extern int dTimeStopLoss_Minutes = 0;
extern string sTimeStopLoss_Minutes = "";
extern double TimeSL_OnlyAfterDistance_PR = 0.0;
extern double dProfitForBreakevenSL_PR = 0.7;
extern int dTrailingStop = 0;
extern string sTrailingStop = "";
extern int dStepTrailingStop = 0;
extern string sStepTrailingStop = "";
extern double dTrailingStop_PR = 1.0;
extern double dStepTrailingStop_PR = 0.1;
extern int dDeleteTPWhenTrailing = 1;
extern double dLagForProfitSL_PR = 0.15;
extern int CloseOrdersOppositeTrend_OsMA = 0;
extern int CloseOrdersOppositeTrend_SAR = 0;
extern int CloseOrdersOppositeTrend_ALL = 0;
extern int CloseOOT_OnlyAfterMinutes = 0;
extern double CloseOOT_OnlyAfterDistance_PR = 0.0;
extern int BlockOpenWorseOrder_Minutes = 720;
extern int dUseGridTracking = 0;
extern double dGridRisk = 0.0;
extern double dGridStep_PR_B = 0.3;
extern double dGridTakeProfit_PR_B = 0.3;
extern double dGridStopLoss_PR_B = 0.0;
extern double dGridStep_PR_S = 0.3;
extern double dGridTakeProfit_PR_S = 0.3;
extern double dGridStopLoss_PR_S = 0.0;
extern string sDescript40 = "_______ 4. Opening orders for correction of motion _______";
extern string sDescript41 = "4.1. Opening Orders for fast motion correction after consolidation";
extern int CR_UseCorrection = 1;
extern double CR_WaitCorrectionAfterMove_PR = 1.2;
extern double CR_WaitCorrectionAfterFlat_PR = 0.2;
extern double CR_MaxDistanceFromBottom_PR = 0.1;
extern double CR_SizeCorrection_PR = 0.4;
extern double CR_StopLoss_PR = 0.0;
extern int CR_StopLoss_UseSAR = 0;
extern int CR_UseTrailingStop = 1;
extern int CR_AnalizMove_Period = 5;
extern int CR_AnalizMove_CountBars = 6;
extern int CR_AnalizFlat_Period = 2;
extern int CR_AnalizFlat_CountBars = 2;
extern string sDescript42 = "4.2. Opening Orders on levels of support / resistance";
extern int dUseTradeLevels = 1;
extern string sUseTradeLevels = "";
extern int dTL_PeriodOpen = 6;
extern string sTL_PeriodOpen = "";
extern int dTL_PeriodOpenCountBars = 70;
extern string sTL_PeriodOpenCountBars = "";
extern double dTL_FindLevelOpen_PR = 0.7;
extern string sTL_FindLevelOpen_PR = "";
extern double dTL_MaxDistFromLevelOpen_PR = 0.07;
extern string sTL_MaxDistFromLevelOpen_PR = "";
extern int dTL_PeriodClose = 5;
extern string sTL_PeriodClose = "";
extern int dTL_PeriodCloseCountBars = 60;
extern string sTL_PeriodCloseCountBars = "";
extern double dTL_FindLevelClose_PR = 0.5;
extern string sTL_FindLevelClose_PR = "";
extern double dTL_MaxDistFromLevelClose_PR = 0.1;
extern string sTL_MaxDistFromLevelClose_PR = "";
extern double dTL_StopLoss_PR = 0.0;
extern string sTL_StopLoss_PR = "";
extern string sDescript50 = "_______ 5. Using oscillation in flat _______";
extern string sDescript51 = "5.1. Opening warrants flat of the channel";
extern int dUseFlatIndicator = 1;
extern string sUseFlatIndicator = "";
extern double diFL_MinWidthCanal_PR = 0.1;
extern string siFL_MinWidthCanal_PR = "";
extern double diFL_MaxWidthCanal_PR = 0.4;
extern string siFL_MaxWidthCanal_PR = "";
extern int diFL_MinExtremumsCount = 1;
extern string siFL_MinExtremumsCount = "";
extern int diFL_Period = 2;
extern string siFL_Period = "";
extern int diFL_CountBars = 8;
extern string siFL_CountBars = "";
extern int diFL_UseConditionTakeOver = 1;
extern int diFL_PeriodTakeOver = 4;
extern int diFL_CountBarsTakeOver = 2;
extern double diFL_StopLoss_PR = 0.0;
extern string siFL_StopLoss_PR = "";
extern int diFL_StopLoss_UseSAR = 0;
extern int FL_UseTrailingStop = 0;
extern double diFL_LotSizeMultiply = 1.0;
extern string siFL_LotSizeMultiply = "";
extern string sDescript52 = "5.2. Scalping on the RSI";
extern int dUseEA_SCL = 0;
extern int SERVER_GMT_OFFSET = 0;
extern int dSCL_UseTimeWork = 1;
extern int dSCL_StartWorkHour_GMT = 22;
extern int dSCL_StartWorkMinute = 0;
extern int dSCL_EndWorkHour_GMT = 2;
extern int dSCL_EndWorkMinute = 0;
extern int dSCL_MaxSpread = 5;
extern int diSCL_RSI1_TimeFrame = 2;
extern int diSCL_RSI1_Period = 6;
extern double diSCL_RSI1_Value = 30.0;
extern int diSCL_RSI2_TimeFrame = 0;
extern int diSCL_RSI2_Period = 20;
extern double diSCL_RSI2_Value = 36.0;
extern int diSCL_MA_TimeFrame = 2;
extern int diSCL_MA_Period = 8;
extern double diSCL_MinDistFromMA_PR = 0.03;
extern double diSCL_ShowTakeProfit_PR = 0.1;
extern double diSCL_ShowStopLoss_PR = 0.0;
extern double diSCL_RealTakeProfit_PR = 0.03;
extern double diSCL_RealStopLoss_PR = 0.0;
extern int diSCL_ReverseClose = 1;
extern int diSCL_RevCloseOnlyProfit = 1;
extern string sDescript60 = "_______ 6. The use of trend movements _______";
extern string sDescript61 = "6.1. Opening Orders Indicator Parabolic SAR";
extern int dUseTrendOrders_ParabolicSAR = 1;
extern int diSAR_RO_TimeFrame = 6;
extern double diSAR_RO_Step = 0.02;
extern double diSAR_RO_Maximum = 0.2;
extern string sDescript62 = "6.2. Opening Orders Indicator Stochastic";
extern int dUseOrders_Stochastic = 1;
extern int diStoch_RO_TimeFrame = 6;
extern int diStoch_RO_KPeriod = 5;
extern int diStoch_RO_DPeriod = 3;
extern int diStoch_RO_Slowing = 3;
extern int diStoch_RO_Method = 2;
extern int diStoch_RO_Price = 0;
extern double diStoch_RO_TakeProfit_PR = 1.0;
extern double diStoch_RO_StopLoss_PR = 0.0;
extern int diStoch_RO_ReverseClose = 0;
extern int diStoch_RO_RevCloseOnlyProfit = 1;
extern int diStoch_RO_UseAverageTP = 0;
extern string sDescript63 = "6.3. Opening Orders Indicator ADX";
extern int dUseTrendOrders_ADX = 1;
extern int diADX_RO_TimeFrame = 6;
extern int diADX_RO_Period = 14;
extern int diADX_RO_TypePrice = 6;
extern double diADX_RO_ValueToCloseOrders = 60.0;
extern double diADX_RO_ValueSignalTrend = 20.0;
extern double diADX_RO_ValueSignalEndTrend = 15.0;
extern double diADX_RO_TakeProfit_PR = 3.0;
extern double diADX_RO_StopLoss_PR = 0.0;
extern int diADX_RO_CloseOnlyProfit = 1;
extern int diADX_RO_UseAverageTP = 0;
extern string sDescript64 = "6.4. Opening Orders Indicator CCI";
extern int dUseOrders_CCI = 1;
extern int diCCI_RO_TimeFrame = 6;
extern int diCCI_RO_Period_Slow = 125;
extern int diCCI_RO_Period_Medium = 25;
extern int diCCI_RO_Period_Fast = 5;
extern int diCCI_RO_TypePrice = 0;
extern double diCCI_RO_TakeProfit_PR = 3.0;
extern double diCCI_RO_StopLoss_PR = 0.0;
extern int diCCI_RO_ReverseClose = 1;
extern int diCCI_RO_RevCloseOnlyProfit = 1;
extern string sDescript70 = "_______ 7. Arbitration - the use of market anomalies and inefficiencies _______";
extern string sDescript71 = "7.1. Exchange rate arbitrage - the deviation of the currency pair of the estimated";
extern int dUseArbitrage_ExchRate = 0;
extern int dArb_EXR_CountIterForRates = 10;
extern int dArb_EXR_TypeOfTakeProfit = 1;
extern int dArb_EXR_TimeSL_Minutes = 10;
extern string sDescript72 = "7.2. Closure of gap - trade at closing gap occurring at the opening of the new session";
extern int dUseCloseOpeningGAP = 1;
extern double diCOG_MinSizeGAP_PR = 0.2;
extern double diCOG_MaxSizeGAP_PR = 0.0;
extern double diCOG_TakeProfit_KF_GAP = 0.7;
extern double diCOG_StopLoss_KF_GAP = 0.4;
extern string sDescript80 = "_______ 8. Filters to open positions _______";
extern string sDescript81 = "8.1. Filter indicator acceleration Accelerator";
extern int dUseAcceleratorIndicator = 1;
extern string sUseAcceleratorIndicator = "";
extern int diAC_CountBars = 3;
extern string siAC_CountBars = "";
extern int diAC_CountTimeFrames = 2;
extern string siAC_CountTimeFrames = "";
extern int diAC_StartTimeFrame = 0;
extern string siAC_StartTimeFrame = "";
extern string sDescript82 = "8.2. Filter Indicator speed Speed";
extern int dUseSpeedIndicator = 1;
extern string sUseSpeedIndicator = "";
extern int diSP_CountBars = 2;
extern string siSP_CountBars = "";
extern int diSP_CountTimeFrames = 2;
extern string siSP_CountTimeFrames = "";
extern int diSP_StartTimeFrame = 1;
extern string siSP_StartTimeFrame = "";
extern string sDescript83 = "8.3. Filter restrictive levels HighLowLimit";
extern int dCountHighLowLimits = 2;
extern string sCountHighLowLimits = "";
extern double diHL_LimitDistance1_PR = 2.0;
extern string siHL_LimitDistance1_PR = "";
extern int diHL_Period1 = 5;
extern string siHL_Period1 = "";
extern int diHL_CountBars1 = 6;
extern string siHL_CountBars1 = "";
extern double diHL_LimitDistance2_PR = 5.0;
extern string siHL_LimitDistance2_PR = "";
extern int diHL_Period2 = 7;
extern string siHL_Period2 = "";
extern int diHL_CountBars2 = 2;
extern string siHL_CountBars2 = "";
extern string sDescript84 = "8.4. Filter trend movements OsMA";
extern int dUseTrendFilterOsMA = 0;
extern int diOsMA_TimeFrame = 5;
extern int diOsMA_FastEMA = 12;
extern int diOsMA_SlowEMA = 26;
extern int diOsMA_SignalSMA = 9;
extern int diOsMA_TypePrice = 6;
extern string sDescript85 = "8.5. Filter trend movements Parabolic SAR";
extern int dUseTrendFilterSAR = 0;
extern int diSAR_Filter_TimeFrame = 5;
extern double diSAR_Filter_Step = 0.02;
extern double diSAR_Filter_Maximum = 0.2;
extern string sDescript86 = "8.6. Filter trend movements ADX";
extern int dUseTrendFilterADX = 0;
extern int diADX_Filter_TimeFrame = 5;
extern int diADX_Filter_Period = 14;
extern int diADX_Filter_TypePrice = 6;
extern double diADX_Filter_ValueSignalTrend = 20.0;
extern string sDescript87 = "8.7. Filters highs / lows";
extern int dUseFilterMaxMin1 = 1;
extern int dMaxMin_Filter_TimeFrame1 = 7;
extern int dMaxMin_Filter_CountBars1 = 8;
extern double dMaxMin_LimitDistance_PR1 = 1.5;
extern int dUseFilterMaxMin2 = 1;
extern int dMaxMin_Filter_TimeFrame2 = 6;
extern int dMaxMin_Filter_CountBars2 = 3;
extern double dMaxMin_LimitDistance_PR2 = 0.5;
extern string sDescript88 = "8.8. Filter levels ban purchases / sales";
extern string sBuyDenyLevel1 = "";
extern string sBuyDenyLevel2 = "";
extern string sSellDenyLevel1 = "";
extern string sSellDenyLevel2 = "";
extern string sDescript90 = "_______ 9. Technical settings _______";
extern string sDescript91 = "TypeOfQuoteDigits - Type the bit quotation: 0 - auto, 1 - standard (4 digits), 2 - Enhanced (5 digits)";
extern int TypeOfQuoteDigits = 0;
extern string sDescript92 = "CustomNameForCurrencyPair - template name for the currency pair (AAA - the first currency pair, BBB - the second currency pairs)";
extern string CustomNameForCurrencyPair = "AAABBB";
extern double dMinLotSize = 0.01;
extern string sMinLotSize = "";
extern double dMaxLotSize = 0.0;
extern string sMaxLotSize = "";
extern double dStepLotSize = 0.01;
extern string sStepLotSize = "";
extern int dSlipPage = 0;
extern string sSlipPage = "";
extern int Set_TP_SL_ByModifyOrder = 0;
//extern bool TestingOneSymbolMode = FALSE;
extern int InverseTrading = 0;
extern int OwnMagicPrefix = 5732;
extern string PrefixOrderComment = "G7 ";
extern bool PrintInfoOpenValPosition = FALSE;
extern bool UsePreventCheckingOrder = TRUE;
extern bool CommentOrderOperations = TRUE;
extern bool PlaySoundWhenOpenOrder = FALSE;
extern string FileNameSoundOpenOrder = "alert.wav";

// -------------------------------------------- Globals -----------------------------------------------

int gi_500 = 0;
int gi_504 = 0;
int gi_508 = 0;
string gs_512 = "";
int gi_520 = 0;
string gs_524 = "";
int gi_1132;
int gi_1144;
int gi_1668 = 0;
string gs_1672 = "";
double gd_1680 = 0.0005;
string gs_1688 = "";
int gi_1696 = 1;
string gs_1700 = "";
int gi_1708 = 35;
string gs_1712 = "";  
int gi_592 = 0;
string gs_596 = "";
int gi_604 = 17;
string gs_608 = "";
int gi_616 = 17;
string gs_620 = "";
int gi_628 = 83;
string gs_632 = "";
int gi_640 = 83;
string gs_644 = "";
int gi_652 = 0;
string gs_656 = "";
int gi_664 = 0;
string gs_668 = "";
int gi_676 = 0;
string gs_680 = "";
int gi_688 = 0;
string gs_692 = "";
int gi_700 = 0;
string gs_704 = "";
int gi_712 = 0;
string gs_716 = "";
int gi_2148 = 1;
string gs_2152 = "";
int gi_2160 = 0;
int gi_2164 = 10;
string gs_2168 = "";
int gi_2176 = 50;
string gs_2180 = "";
int gi_2188 = 10;
int gi_2192 = 0;
int gi_2196;
string gsa_2200[];
double gda_2204[];
double gda_2208[];
double gda_2212[];
double gda_2216[];
int gia_2220[];
int gia_2224[];
int gia_2228[];
double gda_2232[];
double gda_2236[];
double gda_2240[];
int gia_2244[];
int gia_2248[];
int gia_2252[];
int gia_2256[];
int gia_2260[];
int gia_2264[];
int gia_2268[];
int gia_2272[];
int gia_2276[];
int gia_2280[];
int gia_2284[];
int gia_2288[];
int gia_2292[];
int gia_2296[];
int gia_2300[];
int gia_2304[];
int gia_2308[];
int gia_2312[];
int gia_2316[];
double gda_2320[];
double gda_2324[];
int gia_2328[];
int gia_2332[];
int gia_2336[];
int gia_2340[];
int gia_2344[];
int gia_2348[];
int gia_2352[];
int gia_2356[];
int gia_2360[];
int gia_2364[];
int gia_2368[];
int gia_2372[];
double gda_2376[];
double gda_2380[];
double gda_2384[];
int gia_2388[];
double gda_2392[];
int gia_2396[];
int gia_2400[];
double gda_2404[];
int gia_2408[];
int gia_2412[];
int gia_2416[];
int gia_2420[];
int gia_2424[];
double gda_2428[];
double gda_2432[];
int gia_2436[];
int gia_2440[];
double gda_2444[];
double gda_2448[];
double gda_2452[];
int gia_2456[];
double gda_2460[];
double gda_2464[];
int gia_2468[];
int gia_2472[];
int gia_2476[];
double gda_2480[];
double gda_2484[];
double gda_2488[];
double gda_2492[];
double gda_2496[];
int gia_2500[];
int gia_2504[];
int gia_2508[];
int gia_2512[];
int gia_2516[];
string gs_2520;
double gd_2528;
double gd_2536;
double gd_2544;
double gd_2552;
double gd_2560;
double gd_2568;
double gd_2576;
int gi_2592;
int gi_2596;
int gi_2600;
int gi_2604;
int gi_2608;
int gi_2612;
int gi_2616;
int gi_2620;
int gi_2624;
int gi_2628;
int gi_2632;
int gi_2636;
int gi_2640;
int gi_2644;
int gi_2648;
int gi_2652;
int gi_2656;
int gi_2660;
int gi_2664;
double gd_2668;
double gd_2676;
int gi_2684;
int gi_2688;
int gi_2692;
int gi_2696;
int gi_2700;
int gi_2704;
int gi_2708;
int gi_2712;
int gi_2716;
int gi_2720;
int gi_2724;
double gd_2728;
int gi_2736;
int gi_2740;
int gi_2744;
double gd_2748;
int gi_2756;
int gi_2760;
double gd_2764;
int gi_2772;
int gi_2776;
int gi_2780;
double gd_2784;
double gd_2792;
int gi_2800;
int gi_2804;
int gi_2808;
double gd_2812;
double gd_2820;
int gi_2828;
double gd_2832;
double gd_2848;
int gi_2856;
int gi_2860;
int gi_2864;
bool gi_2868 = FALSE;
int gi_2872 = 0;
int gi_2876;
int gi_2880 = 0;
int gi_2884;
string gs_2896;
int gi_2904;
bool gi_2908;
bool gi_2912;
int gi_2916;
int gi_2920;
double gd_2928;
double gd_2936;
double gd_2944;
double gd_2960;
double gd_2968;
string gs_2976;
double gd_2984;
double gd_2992;
double gd_3000;
double gd_3008;
double gd_3016;
//double gd_3024;
int gi_3032;
int gi_3036;
int gi_3040;
int gi_3044;
bool gi_3048;
bool gi_3052;
bool gi_3056;
string gs_3060;
int gi_3068;
int gi_3072 = 0;
string gsa_3076[];
double gda_3080[];
double gda_3084[];
double gd_3088;
double gda_3096[];
double gda_3100[];
int gia_3104[6];
double gda_3108[6];
double gda_3112[6];
double gda_3116[6];
double gd_3120;
double gd_3128;
double gda_3136[2];
double gda_3140[2];
double gd_3144;
double gd_3152;
bool gi_3160;
double gd_3164;
double gd_3172;
double gd_3180;
double gd_3188;
double gd_3196;
double gd_3204;
double gd_3212;
double gd_3220;
double gd_3228;
double gd_3236;
double gd_3244;
double gd_3252;
double gd_3260;
double gd_3268;
double gd_3276;
double gda_3284[];
double gda_3288[10][10];
int gia_3292[10];
int gia_3296[];
int gia_3300[];
int gi_3304 = 0;
int gi_3308 = 1;
int gi_3312 = 2;
int gi_3316 = 3;
int gi_3320 = 4;
int gi_3324 = 5;
int gia_3328[10] = {1, 5, 15, 30, 60, 240, 1440, 10080, 43200, 0};

// ----------------------------------------- Program Initialization -------------------------------

int init() 
{
   int li_4;
   int li_12;
   int li_16;
	int li_0;
	int li_8;
   bool li_20;
   string ls_24;
   string ls_32;
   string ls_40;
   string lsa_48[];
   string ls_52;
   double ld_60;
   int li_68;
   string ls_72;
   string ls_80;
   string ls_88;
	
   gi_2904 = GetTickCount();
   if (dUseArbitrage_ExchRate == 1) 
		gi_2908 = TRUE;
   else 
		gi_2908 = FALSE;
   if (dUseEA_SCL == 1 && dSCL_UseTimeWork == 1) 
	{
      gi_1132 = dSCL_StartWorkHour_GMT + SERVER_GMT_OFFSET;
      for (gi_1144 = dSCL_EndWorkHour_GMT + SERVER_GMT_OFFSET; gi_1132 >= 24; gi_1132 -= 24) 
		{
			// don't do anything?!
      }
      while (gi_1132 < 0) 
			gi_1132 += 24;
      while (gi_1144 >= 24) 
			gi_1144 -= 24;
      while (gi_1144 < 0) 
			gi_1144 += 24;
   }
   if (!f0_18()) 
	{
      MessageBox("The parameters are correctly set! \n Refer to the log file!");
      gi_2868 = TRUE;
      Sleep(86400000);
   }
   if (IsTesting() || IsOptimization()) 
	{
      Print("The Expert Advisor trades on multi-currencies");
      Print("Testing on a single instrument without hedging opportunities does not make sense.");
/*
      if (!TestingOneSymbolMode) 
		{
         MessageBox("EA is a multi-currency EA! \n Testing one single instrument without hedging opportunities does not make sense.");
         gi_2868 = TRUE;
         Sleep(86400000);
      }
*/   
	}
/*	
   gs_2896 = AccountNumber();
   if (!(IsDemo() || IsTesting() || IsOptimization())) 
	{
      if (StringLen(gs_2896) > 2) 
			ls_52 = StringSubstr(gs_2896, 1, StringLen(gs_2896) - 2);
      else 
			ls_52 = gs_2896;
      li_68 = StrToInteger(ls_52);
      li_68 = li_68 % 182 + 182;
      ld_60 = li_68 * li_68;
      li_4 = 0;
      for (li_0 = 0; li_0 < StringLen(gs_2896); li_0 += 2) 
		{
         ls_52 = StringSubstr(gs_2896, li_0, 1);
         li_68 = StrToInteger(ls_52);
         if (li_68 != 0) 
			{
            if (li_4 == 0) 
					ld_60 *= li_68;
            else 
					ld_60 += li_68;
         }
         li_4 = 1 - li_4;
      }
      for (li_0 = 1; li_0 < StringLen(gs_2896); li_0 += 2) 
		{
         ls_52 = StringSubstr(gs_2896, li_0, 1);
         li_68 = StrToInteger(ls_52);
         if (li_68 != 0) 
			{
            if (li_4 == 0) 
					ld_60 *= li_68;
            else 
					ld_60 += li_68;
         }
         li_4 = 1 - li_4;
      }
   }
*/	
   gi_2876 = 10000 * OwnMagicPrefix;
   gi_2196 = 0;
   for (li_8 = 1; li_8 <= 5; li_8++) 
	{
      switch (li_8) 
		{
      case 1:
         ls_24 = sSymbols1;
         break;
      case 2:
         ls_24 = sSymbols2;
         break;
      case 3:
         ls_24 = sSymbols3;
         break;
      case 4:
         ls_24 = sSymbols4;
         break;
      case 5:
         ls_24 = sSymbols5;
      }
      li_16 = f0_30(ls_24, lsa_48, ";");
      for (li_0 = 0; li_0 < li_16; li_0++) 
		{
         li_12 = StringFind(lsa_48[li_0], ":");
         if (li_12 != -1) 
			{
            ls_40 = f0_31(StringSubstr(lsa_48[li_0], li_12 + 1));
            if (ls_40 == "1" || ls_40 == "2" || ls_40 == "3") 
				{
               ls_32 = f0_31(StringSubstr(lsa_48[li_0], 0, li_12));
               gi_2196++;
               ArrayResize(gsa_2200, gi_2196);
               ArrayResize(gia_2224, gi_2196);
               ArrayResize(gia_2228, gi_2196);
               gsa_2200[gi_2196 - 1] = ls_32 + sSymbolSuffix;
               gia_2224[gi_2196 - 1] = 0;
               gia_2228[gi_2196 - 1] = 0;
               if (ls_40 == "1" || ls_40 == "2") 
						gia_2224[gi_2196 - 1] = 1;
               if (ls_40 == "1" || ls_40 == "3") 
						gia_2228[gi_2196 - 1] = 1;
            }
         }
      }
   }
   ArrayResize(gda_3284, gi_2196);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
		gda_3284[li_0] = 0;
   ArrayResize(gia_3296, gi_2196);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
		gia_3296[li_0] = 0;
   ArrayResize(gia_3300, gi_2196);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
		gia_3300[li_0] = 0;
   ArrayResize(gda_2204, gi_2196);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
		gda_2204[li_0] = MarketInfo(gsa_2200[li_0], MODE_POINT);
   ArrayResize(gda_2208, gi_2196);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
		gda_2208[li_0] = MarketInfo(gsa_2200[li_0], MODE_DIGITS);
   ArrayResize(gda_2212, gi_2196);
   ArrayResize(gda_2216, gi_2196);
   gi_3068 = 0;
   ArrayResize(gsa_3076, gi_3068);
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
	{
      if (f0_35(gsa_2200[li_0], CustomNameForCurrencyPair)) 
		{
         for (li_4 = 0; li_4 < 2; li_4++) 
			{
            ls_32 = f0_20(gsa_2200[li_0], li_4 + 1, CustomNameForCurrencyPair);
            li_20 = FALSE;
            for (li_8 = 0; li_8 < gi_3068; li_8++) 
				{
               if (gsa_3076[li_8] == ls_32) 
					{
                  li_20 = TRUE;
                  break;
               }
            }
            if (!li_20) 
				{
               gi_3068++;
               ArrayResize(gsa_3076, gi_3068);
               gsa_3076[gi_3068 - 1] = ls_32;
            }
         }
      }
   }
   ArrayResize(gda_3080, gi_3068);
   ArrayResize(gda_3084, gi_3068);
   ArrayResize(gda_3096, gi_3068);
   ArrayResize(gda_3100, gi_3068);
   f0_33();
   f0_43();
   f0_16();
   return (0);
}

// -------------------------------------- Program de-initialization ------------------------

int deinit() 
{
   if (IsTesting() || IsOptimization()) 
		Print("Time testing / optimization: ", (GetTickCount() - gi_2904) / 1000, " seconds.");
   return (0);
}

// -------------------------------------- Program start -------------------------------------

int start() 
{
   int li_8;
	int li_0;
	int li_4;

   if (!f0_34()) 
		return (0);
   if (Day() != gi_2872) 
		f0_43();
   for (li_0 = 0; li_0 < gi_2196; li_0++) 
	{
      if (!gi_2908 && li_0 % CountOfCycles != gi_2880) 
			continue;
      gs_2520 = gsa_2200[li_0];
      if (IsTesting() || IsOptimization() && gs_2520 != Symbol()) 
			continue;
      if (!IsTesting() && MarketInfo(gs_2520, MODE_TRADEALLOWED) == 0.0) 
			continue;
      if (f0_44(li_0) == TRUE) 
		{
         if (f0_16()) 
			{
            if (f0_13()) 
				{
               if (gia_2244[li_0] != 0)
                  if (gd_2560 > gia_2244[li_0]) 
						continue;
               li_8 = 1;
               if (gi_2908) 
						li_8 = 2;
               for (li_4 = 0; li_4 < li_8; li_4++) 
					{
                  if (li_4 == 0 && gi_2908) 
							gi_2912 = TRUE;
                  else 
							gi_2912 = FALSE;
                  if (!gi_2912 && li_0 % CountOfCycles != gi_2880) 
							continue;
                  if (gi_2912) 
							f0_1();
                  else 
							f0_24();
                  if (gi_2912) 
							f0_14(li_0);
                  else 
							f0_15(li_0);
                  if (MaxOrdersCount > 0)
                     if (OrdersTotal() >= MaxOrdersCount) 
								continue;
/*							
                  if (IsTesting() || IsOptimization()) gd_3088 = 0;
                  else gd_3088 = gd_3024;
*/
                  if (f0_16()) 
						{
                     if (f0_13()) 
							{
                        gd_2928 = f0_9(li_0);
                        if (AccountFreeMargin() <= 0.0)
                           if (gia_3104[gi_3304] + gia_3104[gi_3308] == 0) 
										continue;
                        f0_39(li_0);
                     }
                  }
               }
            }
         }
      }
   }
   gi_2880++;
   if (gi_2880 >= CountOfCycles) 
		gi_2880 = 0;
   return (0);
}

// ------------------------------------- Program functions starts here -----------------------

bool f0_18() 
{
   bool li_0 = TRUE;

   if (OwnMagicPrefix < 0) 
		OwnMagicPrefix = -OwnMagicPrefix;
   if (OwnMagicPrefix > 214747) 
	{
      li_0 = FALSE;
      Print("The maximum possible value is OwnMagicPrefix is 214747. Change this value.");
      Print("Error: set the variable OwnMagicPrefix to a lower value!");
   }
   return (li_0);
}

int f0_44(int ai_0) 
{
   gi_2592 = gia_2224[ai_0];
   gi_2596 = gia_2228[ai_0];
   if (gi_2592 == 0 && gi_2596 == 0) 
		return (0);
   gd_2528 = gda_2204[ai_0];
   gd_2536 = gda_2208[ai_0];
   if (gd_2528 == 0.0) 
		return (0);
   gd_2544 = MarketInfo(gs_2520, MODE_BID);
   gd_3268 = 0;
   gd_2552 = MarketInfo(gs_2520, MODE_ASK);
   gd_2576 = MarketInfo(gs_2520, MODE_TIME);
   gd_2560 = MarketInfo(gs_2520, MODE_SPREAD);
   gd_2568 = MarketInfo(gs_2520, MODE_STOPLEVEL);
   gi_2600 = gia_2248[ai_0];
   gi_2604 = gia_2252[ai_0];
   gi_2608 = gia_2256[ai_0];
   gi_2612 = gia_2260[ai_0];
   gi_2616 = gia_2264[ai_0];
   gi_2620 = gia_2268[ai_0];
   if (gi_2600 > 0) 
	{
      gi_2600 = MathMax(MarketInfo(gs_2520, MODE_STOPLEVEL), gi_2600);
      gi_2608 = gi_2600;
      gi_2612 = gi_2600;
   }
   if (gi_2604 > 0) 
	{
      gi_2604 = MathMax(MarketInfo(gs_2520, MODE_STOPLEVEL), gi_2604);
      gi_2616 = gi_2604;
      gi_2620 = gi_2604;
   }
   gi_2624 = gia_2272[ai_0];
   gi_2628 = gia_2276[ai_0];
   gi_2632 = gia_2280[ai_0];
   gi_2636 = gia_2284[ai_0];
   gi_2640 = gia_2288[ai_0];
   gi_2644 = gia_2296[ai_0];
   gi_2648 = gia_2300[ai_0];
   gi_2652 = gia_2304[ai_0];
   gi_2656 = gia_2308[ai_0];
   gi_2660 = gia_2312[ai_0];
   gi_2664 = gia_2316[ai_0];
   gd_2668 = gda_2320[ai_0];
   gd_2676 = gda_2324[ai_0];
   gi_2684 = gia_2332[ai_0];
   gi_2688 = gia_2336[ai_0];
   gi_2692 = gia_2340[ai_0];
   gi_2696 = gia_2344[ai_0];
   gi_2700 = gia_2348[ai_0];
   gi_2704 = gia_2352[ai_0];
   gi_2708 = gia_2356[ai_0];
   gi_2712 = gia_2360[ai_0];
   gi_2716 = gia_2364[ai_0];
   gi_2720 = gia_2368[ai_0];
   gi_2724 = gia_2372[ai_0];
   gd_2728 = gda_2376[ai_0];
   gi_2736 = gda_2380[ai_0];
   gi_2740 = gda_2384[ai_0];
   gi_2744 = gia_2388[ai_0];
   gd_2748 = gda_2392[ai_0];
   gi_2756 = gia_2396[ai_0];
   gi_2760 = gia_2400[ai_0];
   gd_2764 = gda_2404[ai_0];
   gi_2772 = gia_2408[ai_0];
   gi_2776 = gia_2412[ai_0];
   gi_2780 = gia_2456[ai_0];
   gd_2784 = gda_2460[ai_0];
   gd_2792 = gda_2464[ai_0];
   gi_2800 = gia_2468[ai_0];
   gi_2804 = gia_2472[ai_0];
   gi_2808 = gia_2476[ai_0];
   gd_2812 = gda_2480[ai_0];
   gd_2820 = gda_2484[ai_0];
   gi_2828 = gia_2500[ai_0];
   gd_2832 = gda_2232[ai_0];
   gd_2848 = gda_2236[ai_0];
   gi_2856 = gia_2504[ai_0];
   gi_2860 = gia_2508[ai_0];
   gi_2864 = gia_2512[ai_0];
   return (1);
}

void f0_39(int ai_0) 
{
   double ld_16;
	int li_4;
	
   for (li_4 = 0; li_4 < 2; li_4++) 
	{
      if (li_4 == 0) 
		{
         gi_3036 = gi_3304;
         gs_3060 = "BUY";
         gi_2916 = 0;
         gd_2984 = gd_2552;
      } 
		else 
		{
         gi_3036 = gi_3308;
         gs_3060 = "SELL";
         gi_2916 = 1;
         gd_2984 = gd_2544;
      }
      gd_2992 = 100.0 * MathFloor(gd_2984 / gd_2528 / 100.0) * gd_2528;
      gd_3188 = 1;
      gd_3088 = 0;
      if (gi_2828 == 1) 
		{
         gi_3052 = FALSE;
         gd_2936 = gd_2928;
         if (gi_2912 && gd_3268 > 0.0) 
			{
            if (gi_3036 == gi_3304 && gd_3276 < gda_3284[ai_0] && gda_3284[ai_0] - gd_3276 > gd_2560) 
				{
               gi_3052 = TRUE;
               gi_2920 = gi_2876 + 710;
               gd_2944 = gd_2984;
               gd_2968 = 0;
               gd_2960 = 0;
               if (dArb_EXR_TypeOfTakeProfit == 2) 
						gd_2968 = gd_2944 + gd_2560 * gd_2528;
            } 
				else 
				{
               if (gi_3036 == gi_3308 && gd_3276 > gda_3284[ai_0] && gd_3276 - gda_3284[ai_0] > gd_2560) 
					{
                  gi_3052 = TRUE;
                  gi_2920 = gi_2876 + 710;
                  gd_2944 = gd_2984;
                  gd_2968 = 0;
                  gd_2960 = 0;
                  if (dArb_EXR_TypeOfTakeProfit == 2) 
							gd_2968 = gd_2944 - gd_2560 * gd_2528;
               }
            }
         }
         gi_3056 = FALSE;
         if (dUseGridTracking == 1 && gia_3104[gi_3036] > 0 && (!gi_2912)) 
			{
            if (gi_3036 == gi_3304) 
				{
               gd_3000 = gda_3108[gi_3036];
               gd_3016 = gda_3112[gi_3036] * dGridStep_PR_B / 100.0;
            } 
				else 
				{
               gd_3000 = gda_3112[gi_3036];
               gd_3016 = gda_3108[gi_3036] * dGridStep_PR_S / 100.0;
            }
            if (gi_3036 == gi_3304 && gd_2984 < gd_3000 - gd_3016 && gi_2592 != 0) 
				{
               gi_3056 = TRUE;
               gd_2944 = gd_2984;
               gd_2968 = 0;
               gd_2960 = 0;
               if (dGridTakeProfit_PR_B > 0.0) 
						gd_2968 = gd_2944 + NormalizeDouble(gda_3112[gi_3036] * dGridTakeProfit_PR_B / 100.0, gd_2536);
               if (dGridStopLoss_PR_B > 0.0) 
						gd_2960 = gd_2944 - NormalizeDouble(gda_3112[gi_3036] * dGridStopLoss_PR_B / 100.0, gd_2536);
            } 
				else 
				{
               if (gi_3036 == gi_3308 && gd_2984 > gd_3000 + gd_3016 && gi_2596 != 0) 
					{
                  gi_3056 = TRUE;
                  gd_2944 = gd_2984;
                  gd_2968 = 0;
                  gd_2960 = 0;
                  if (dGridTakeProfit_PR_S > 0.0) 
							gd_2968 = gd_2944 - NormalizeDouble(gda_3108[gi_3036] * dGridTakeProfit_PR_S / 100.0, gd_2536);
                  if (dGridStopLoss_PR_S > 0.0) 
							gd_2960 = gd_2944 + NormalizeDouble(gda_3108[gi_3036] * dGridStopLoss_PR_S / 100.0, gd_2536);
               }
            }
            if (gi_3056) 
				{
               gi_2920 = gi_2876 + 110;
               if (dGridRisk > 0.0) 
						gd_2936 = f0_37(AccountFreeMargin() / 1000.0 * dGridRisk, gda_2496[ai_0]);
               else 
						gd_2936 = gda_2488[ai_0];
               if (gd_2936 < gda_2488[ai_0]) 
						gd_2936 = gda_2488[ai_0];
               if (gd_2936 > gda_2492[ai_0]) 
						gd_2936 = gda_2492[ai_0];
            }
         }
         if (gi_3056) 
				gi_3052 = TRUE;
         if (!gi_3052 && dUseCloseOpeningGAP == 1) 
				f0_48(ai_0);
         if (UsePreventCheckingOrder && (!gi_3056))
            if (!(f0_46(ai_0, gd_2984, gi_3036, gi_2916, gd_2984, 0))) 
					continue;
         if (!gi_3052 && CR_UseCorrection == 1) 
				f0_0();
         if (!gi_3052 && gia_2416[ai_0] == 1) 
				f0_47(ai_0);
         if (!gi_3052 && gi_2780 == 1 && gi_3160) 
				f0_25();
         if (!gi_3052 && gi_2708 == 1 && gi_2724 == 1 && MathAbs(gd_3120) > gd_2728) 
				f0_6();
         if (!gi_3052 && dUseTrendOrders_ParabolicSAR == 1) 
				f0_42();
         if (!gi_3052 && dUseOrders_Stochastic == 1) 
				f0_36();
         if (!gi_3052 && dUseTrendOrders_ADX == 1) 
				f0_51();
         if (!gi_3052 && dUseOrders_CCI == 1) 
				f0_10();
         if (!gi_3052 && dUseEA_SCL == 1) 
				f0_27();
         if (gi_3052) 
			{
            if ((!gi_3056) && !gi_2912) 
				{
               if (gi_2920 == gi_2876 + 210) 
					{
                  if (gd_2820 > 0.0 && gd_2820 != 1.0 && gd_2928 > gda_2488[ai_0]) 
						{
                     gd_2936 = f0_37(gd_2928 * gd_2820, gda_2496[ai_0]);
                     if (gd_2936 > gda_2492[ai_0]) 
								gd_2936 = gda_2492[ai_0];
                  }
               }
               if (gi_2600 > 0) 
					{
                  if (gi_2916 == 0) 
							gd_2968 = gd_2944 + gi_2600 * gd_2528;
                  else
                     if (gi_2916 == 1) 
								gd_2968 = gd_2944 - gi_2600 * gd_2528;
               }
               if (gi_2604 > 0) 
					{
                  if (gi_2916 == 0) 
							gd_2960 = gd_2944 - gi_2604 * gd_2528;
                  else
                     if (gi_2916 == 1) 
								gd_2960 = gd_2944 + gi_2604 * gd_2528;
               }
            }
            if (gi_2916 == 0) 
				{
               if (gd_2968 != 0.0 && gd_2968 - gd_2944 < gd_2568 * gd_2528) 
						gd_2968 = gd_2944 + gd_2568 * gd_2528;
               if (gd_2960 != 0.0 && gd_2944 - gd_2960 < gd_2568 * gd_2528) 
						gd_2960 = gd_2944 - gd_2568 * gd_2528;
            }
            if (gi_2916 == 1) 
				{
               if (gd_2968 != 0.0 && gd_2944 - gd_2968 < gd_2568 * gd_2528) 
						gd_2968 = gd_2944 - gd_2568 * gd_2528;
               if (gd_2960 != 0.0 && gd_2960 - gd_2944 < gd_2568 * gd_2528) 
						gd_2960 = gd_2944 + gd_2568 * gd_2528;
            }
            if (InverseTrading == 1 && (!gi_3056) && (!gi_2912)) 
				{
               ld_16 = gd_2560 * gd_2528;
               if (gi_2916 == 0) 
					{
                  gi_2916 = 1;
                  gi_3036 = gi_3308;
                  if (gd_2960 != 0.0) 
							gd_2960 = gd_2944 - ld_16 + (gd_2944 - gd_2960);
                  if (gd_2968 != 0.0) 
							gd_2968 = gd_2944 - ld_16 - (gd_2968 - gd_2944);
                  gd_2944 -= ld_16;
                  gd_2984 = gd_2544;
               } 
					else 
					{
                  if (gi_2916 == 1) 
						{
                     gi_2916 = 0;
                     gi_3036 = gi_3304;
                     if (gd_2960 != 0.0) 
								gd_2960 = gd_2944 + ld_16 - (gd_2960 - gd_2944);
                     if (gd_2968 != 0.0) 
								gd_2968 = gd_2944 + ld_16 + (gd_2944 - gd_2968);
                     gd_2944 += ld_16;
                     gd_2984 = gd_2552;
                  }
               }
            }
         }
         if (gi_3052) 
			{
            if ((!gi_3056) && !gi_2912) 
				{
               if (gi_3052)
                  if (!f0_46(ai_0, gd_2944, gi_3036, gi_2916, gd_2984, 1)) 
							gi_3052 = FALSE;
               if (gi_3052)
                  if (!f0_32(gd_2944, gi_2916, gd_2984)) 
							gi_3052 = FALSE;
            }
         }
         if (gi_3052) 
			{
            if (gi_504 == 1) 
				{
					// don't do anything
				}
            gs_2976 = "";
            gi_3032 = f0_5(gs_2520, gi_2916, gd_2936, gd_2944, gia_2516[ai_0], gd_2960, gd_2968, gs_2976, gi_2920, 0, Green);
            if (gi_3032 > 0) 
				{
               if (OrderSelect(gi_3032, SELECT_BY_TICKET, MODE_TRADES)) 
					{
                  if (!(f0_13())) 
							break;
                  continue;
               }
            } 
				else 
				{
               if (gi_2920 == gi_2876 + 720) 
					{
                  if (gi_3036 == gi_3304) 
							gia_3296[ai_0] = 0;
                  if (gi_3036 == gi_3308) 
							gia_3300[ai_0] = 0;
               }
            }
         }
      }
      if (gia_2292[ai_0] == 1) 
			f0_19(ai_0);
   }
}

void f0_19(int ai_0) 
{
	int li_4;
	
   for (li_4 = 0; li_4 < 2; li_4++) 
	{
      gi_2920 = gi_2876 + 0;
      if (li_4 == 0) 
		{
         if (gi_3036 == gi_3304) 
			{
            if (gi_2644 < 0) 
					continue;
            gi_2916 = 4;
            gi_3040 = gi_3320;
            if (gd_2984 < gd_2992 + gi_2644 * gd_2528) 
					gd_2944 = gd_2992 + gi_2644 * gd_2528;
            else 
					gd_2944 = gd_2992 + (gi_2644 + 100) * gd_2528;
         } 
			else 
			{
            if (gi_2652 < 0) 
					continue;
            gi_2916 = 5;
            gi_3040 = gi_3324;
            if (gd_2984 < gd_2992 + gi_2652 * gd_2528) 
					gd_2944 = gd_2992 - (100 - gi_2652) * gd_2528;
            else 
					gd_2944 = gd_2992 + gi_2652 * gd_2528;
         }
      } 
		else 
		{
         if (gi_3036 == gi_3304) 
			{
            if (gi_2648 < 0) 
					continue;
            gi_2916 = 2;
            gi_3040 = gi_3312;
            if (gd_2984 < gd_2992 + gi_2648 * gd_2528) 
					gd_2944 = gd_2992 - (100 - gi_2648) * gd_2528;
            else 
					gd_2944 = gd_2992 + gi_2648 * gd_2528;
         } 
			else 
			{
            if (gi_2656 < 0) 
					continue;
            gi_2916 = 3;
            gi_3040 = gi_3316;
            if (gd_2984 < gd_2992 + gi_2656 * gd_2528) 
					gd_2944 = gd_2992 + gi_2656 * gd_2528;
            else 
					gd_2944 = gd_2992 + (gi_2656 + 100) * gd_2528;
         }
      }
      gs_3060 = f0_11(gi_2916);
      if (gi_3036 == gi_3304) 
		{
         gd_2968 = gd_2944 + gi_2608 * gd_2528;
         if (gi_2616 > 0) 
				gd_2960 = gd_2944 - gi_2616 * gd_2528;
         else 
				gd_2960 = 0;
      } 
		else 
		{
         gd_2968 = gd_2944 - gi_2612 * gd_2528;
         if (gi_2620 > 0) 
				gd_2960 = gd_2944 + gi_2620 * gd_2528;
         else 
				gd_2960 = 0;
      }
      gi_3048 = TRUE;
      if (gi_3048)
         if (!f0_46(ai_0, gd_2944, gi_3036, gi_2916, gd_2984, 1)) 
				gi_3048 = FALSE;
      if (gi_3048) 
		{
         if (gi_2860 != 0)
            if (MathAbs(gd_2944 - gd_2984) < gi_2860 * gd_2528) 
					gi_3048 = FALSE;
         if (gi_2864 != 0)
            if (MathAbs(gd_2944 - gd_2984) > gi_2864 * gd_2528) 
					gi_3048 = FALSE;
      }
      if (gi_3048)
         if (gia_3104[gi_3036] > 0 && li_4 == 1) 
				gi_3048 = FALSE;
      if (gi_3048) 
		{
         if (gia_3104[gi_3040] > 0) 
			{
            if (gi_3040 == gi_3320 || gi_3040 == gi_3316) 
					gd_3008 = gda_3108[gi_3040];
            else 
					gd_3008 = gda_3112[gi_3040];
            if (gi_2188 != 0) 
					gd_3016 = gi_2188 * gd_2528;
            else 
					gd_3016 = 1;
            if (gi_3040 == gi_3320 || gi_3040 == gi_3316) 
				{
               if (gd_2944 > gd_3008 - gd_3016) 
						gi_3048 = FALSE;
            } 
				else
               if (gd_2944 < gd_3008 + gd_3016) 
						gi_3048 = FALSE;
         }
      }
      if (gi_3048 && gia_3104[gi_3036] > 0) 
		{
         if (f0_50(gd_2944, gi_3036, gd_3000) == TRUE) 
			{
            if ((gi_3036 == gi_3304 && gi_2684 == 1) || (gi_3036 == gi_3308 && gi_2688 == 1)) 
				{
               gd_2968 = (gd_2944 + gd_3000) / 2.0;
               gi_2920 = gi_2876 + 100;
            }
         } 
			else 
				gi_3048 = FALSE;
      }
      if (gi_3048 && gi_2744 > 0)
         if (!f0_41(gd_2944, gi_3036)) 
				gi_3048 = FALSE;
      if (gi_3048)
         if (!f0_32(gd_2944, gi_2916, gd_2984)) 
				gi_3048 = FALSE;
      if (gi_3048) 
		{
         gd_2936 = gd_2928;
         gs_2976 = "";
         gi_3032 = f0_5(gs_2520, gi_2916, gd_2936, gd_2944, 0, gd_2960, gd_2968, gs_2976, gi_2920, 0, Green);
         if (gi_3032 > 0) 
			{
            if (OrderSelect(gi_3032, SELECT_BY_TICKET, MODE_TRADES))
               if (!(f0_13())) 
						break;
         }
      }
   }
}

void f0_25() 
{
   double ld_0 = gd_2560 * gd_2528;

   if (gi_3036 == gi_3304 && gd_2544 > gd_3164 && gd_2544 <= gd_3164 + (gd_3180 - ld_0) / 4.0) 
	{
      if (iOpen(gs_2520, gia_3328[0], 0) >= iClose(gs_2520, gia_3328[0], 1) && iClose(gs_2520, gia_3328[0], 1) > 
		iClose(gs_2520, gia_3328[0], 2) && iClose(gs_2520, gia_3328[0], 2) > iClose(gs_2520, gia_3328[0], 3)) 
		{
         gi_3052 = TRUE;
         gi_2916 = 0;
         gd_2944 = gd_2984;
         gd_2968 = gd_2944 + NormalizeDouble((gd_3180 - ld_0) / 2.0, gd_2536);
         if (gd_2812 > 0.0) 
				gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * gd_2812 / 100.0, gd_2536);
         else 
			{
            if (diFL_StopLoss_UseSAR == 1 && gd_3204 != 0.0 && gd_3204 < gd_2944) 
					gd_2960 = gd_3204;
            else 
					gd_2960 = 0;
         }
      }
   }
   if (gi_3036 == gi_3308 && gd_2544 < gd_3172 && gd_2544 >= gd_3172 - (gd_3180 - ld_0) / 4.0) 
	{
      if (iOpen(gs_2520, gia_3328[0], 0) <= iClose(gs_2520, gia_3328[0], 1) && iClose(gs_2520, gia_3328[0], 1) < 
		iClose(gs_2520, gia_3328[0], 2) && iClose(gs_2520, gia_3328[0], 2) < iClose(gs_2520, gia_3328[0], 3)) 
		{
         gi_3052 = TRUE;
         gi_2916 = 1;
         gd_2944 = gd_2984;
         gd_2968 = gd_2944 - NormalizeDouble((gd_3180 - ld_0) / 2.0, gd_2536);
         if (gi_2612 > 0)
            if (gd_2968 < gd_2944 - gi_2612 * gd_2528) 
					gd_2968 = gd_2944 - gi_2612 * gd_2528;
         if (gd_2812 > 0.0) 
				gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * gd_2812 / 100.0, gd_2536);
         else 
			{
            if (diFL_StopLoss_UseSAR == 1 && gd_3204 != 0.0 && gd_3204 > gd_2944) 
					gd_2960 = gd_3204;
            else 
					gd_2960 = 0;
         }
      }
   }
   if (gi_3052) 
		gi_2920 = gi_2876 + 210;
}

void f0_0() 
{
	int li_0;
   int li_4;
   int li_8;
   double ld_12;
   double ld_20;
   double ld_28 = 0;
   double ld_36 = 0;
   double ld_44 = 0;
   double ld_52 = 0;

   for (li_0 = 0; li_0 < CR_AnalizMove_CountBars; li_0++) 
	{
      ld_12 = iLow(gs_2520, gia_3328[CR_AnalizMove_Period], li_0);
      ld_20 = iHigh(gs_2520, gia_3328[CR_AnalizMove_Period], li_0);
      if (ld_12 > 0.0) 
		{
         if (ld_28 == 0.0 || ld_12 < ld_28) 
			{
            ld_28 = ld_12;
            li_4 = li_0;
         }
      }
      if (ld_20 > 0.0) 
		{
         if (ld_36 == 0.0 || ld_20 > ld_36) 
			{
            ld_36 = ld_20;
            li_8 = li_0;
         }
      }
   }
   for (li_0 = 0; li_0 < CR_AnalizFlat_CountBars; li_0++) 
	{
      ld_12 = iLow(gs_2520, gia_3328[CR_AnalizFlat_Period], li_0);
      ld_20 = iHigh(gs_2520, gia_3328[CR_AnalizFlat_Period], li_0);
      if (ld_12 > 0.0)
         if (ld_44 == 0.0 || ld_12 < ld_44) 
				ld_44 = ld_12;
      if (ld_20 > 0.0)
         if (ld_52 == 0.0 || ld_20 > ld_52) 
				ld_52 = ld_20;
   }
   if (ld_28 == 0.0 || ld_36 == 0.0 || ld_44 == 0.0 || ld_52 == 0.0) 
		return;
   if (ld_36 - ld_28 >= gd_2984 * CR_WaitCorrectionAfterMove_PR / 100.0) 
	{
      if (ld_52 - ld_44 <= gd_2984 * CR_WaitCorrectionAfterFlat_PR / 100.0) 
		{
         if (gi_3036 == gi_3304 && gd_2984 <= ld_28 + gd_2984 * CR_MaxDistanceFromBottom_PR / 100.0) 
			{
            for (li_0 = 0; li_0 < li_4; li_0++) 
				{
               ld_20 = iHigh(gs_2520, gia_3328[CR_AnalizMove_Period], li_0);
               if (ld_20 > ld_28 + gd_2984 * (CR_MaxDistanceFromBottom_PR + CR_WaitCorrectionAfterMove_PR) / 100.0) 
						return;
            }
            gi_3052 = TRUE;
            gi_2916 = 0;
            gd_2944 = gd_2984;
            gd_2968 = gd_2944 + NormalizeDouble(gd_2984 * CR_SizeCorrection_PR / 100.0, gd_2536);
            if (CR_StopLoss_PR > 0.0) 
					gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * CR_StopLoss_PR / 100.0, gd_2536);
            else 
				{
               if (CR_StopLoss_UseSAR == 1 && gd_3204 != 0.0 && gd_3204 < gd_2944) 
						gd_2960 = gd_3204;
               else 
						gd_2960 = 0;
            }
         }
         if (gi_3036 == gi_3308 && gd_2984 >= ld_36 - gd_2984 * CR_MaxDistanceFromBottom_PR / 100.0) 
			{
            for (li_0 = 0; li_0 < li_8; li_0++) 
				{
               ld_12 = iLow(gs_2520, gia_3328[CR_AnalizMove_Period], li_0);
               if (ld_12 < ld_36 - gd_2984 * (CR_MaxDistanceFromBottom_PR + CR_WaitCorrectionAfterMove_PR) / 100.0) 
						return;
            }
            gi_3052 = TRUE;
            gi_2916 = 1;
            gd_2944 = gd_2984;
            gd_2968 = gd_2944 - NormalizeDouble(gd_2984 * CR_SizeCorrection_PR / 100.0, gd_2536);
            if (CR_StopLoss_PR > 0.0) 
					gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * CR_StopLoss_PR / 100.0, gd_2536);
            else 
				{
               if (CR_StopLoss_UseSAR == 1 && gd_3204 != 0.0 && gd_3204 > gd_2944) 
						gd_2960 = gd_3204;
               else 
						gd_2960 = 0;
            }
         }
         if (gi_3052) 
				gi_2920 = gi_2876 + 410;
      }
   }
}

void f0_47(int ai_0) 
{
	int li_4;
   double lda_56[];
   double lda_60[];
   double ld_128;
   double ld_136;
   int li_16 = gia_2420[ai_0];
   double ld_24 = gda_2428[ai_0];
   double ld_32 = gda_2432[ai_0];
   int li_20 = gia_2436[ai_0];
   double ld_40 = gda_2444[ai_0];
   double ld_48 = gda_2448[ai_0];
   ArrayResize(lda_56, gia_2424[ai_0]);
   ArrayResize(lda_60, gia_2424[ai_0]);
   int li_12 = 0;
   int li_8 = 0;
   double ld_80 = gd_2544;
   double ld_88 = gd_2544;
   double ld_96 = gd_2544;
   double ld_104 = gd_2544;
   double ld_112 = gd_2544;
   double ld_120 = gd_2544;
   double ld_64 = 0;
   double ld_72 = 0;

   for (li_4 = 0; li_4 < gia_2424[ai_0]; li_4++) 
	{
      if (gi_3036 == gi_3304) 
			ld_64 = iLow(gs_2520, gia_3328[li_16], li_4);
      if (gi_3036 == gi_3308) 
			ld_72 = iHigh(gs_2520, gia_3328[li_16], li_4);
      if (ld_64 > 0.0) 
		{
         if (ld_64 < ld_80 || (ld_88 - ld_80) / ld_80 < ld_24 / 100.0) 
			{
            ld_80 = ld_64;
            if (ld_88 < ld_96) 
					ld_88 = ld_96;
            ld_96 = ld_64;
         } 
			else
            if (ld_64 > ld_96) 
					ld_96 = ld_64;
         if ((ld_96 - ld_80) / ld_80 >= ld_24 / 100.0 && (ld_88 - ld_80) / ld_80 >= ld_24 / 100.0) 
			{
            lda_60[li_12] = ld_80;
            li_12++;
            ld_80 = ld_64;
            ld_88 = ld_64;
            ld_96 = ld_64;
         }
      }
      if (ld_72 > 0.0) 
		{
         if (ld_72 > ld_104 || (ld_104 - ld_120) / ld_104 < ld_24 / 100.0) 
			{
            ld_104 = ld_72;
            if (ld_120 > ld_112) 
					ld_120 = ld_112;
            ld_112 = ld_72;
         } 
			else
            if (ld_72 < ld_112) 
					ld_112 = ld_72;
         if ((ld_104 - ld_112) / ld_104 >= ld_24 / 100.0 && (ld_104 - ld_120) / ld_104 >= ld_24 / 100.0) 
			{
            lda_56[li_8] = ld_104;
            li_8++;
            ld_104 = ld_72;
            ld_120 = ld_72;
            ld_112 = ld_72;
         }
      }
   }
   if (gi_3036 == gi_3304) 
	{
      for (li_4 = 0; li_4 < li_12; li_4++) 
		{
         if (gd_2544 > lda_60[li_4] && gd_2544 <= lda_60[li_4] * (ld_32 / 100.0 + 1.0)) 
			{
            if (iLow(gs_2520, gia_3328[li_16], 0) < lda_60[li_4] || iLow(gs_2520, gia_3328[li_16], 1) < lda_60[li_4]) 
					continue;
            gi_3052 = TRUE;
            gi_2916 = 0;
            gd_2944 = gd_2984;
            break;
         }
      }
      if (gi_3052) 
		{
         ArrayResize(lda_56, gia_2440[ai_0]);
         li_8 = 0;
         ld_104 = gd_2544;
         ld_112 = gd_2544;
         ld_120 = gd_2544;
         ld_72 = 0;
         for (li_4 = 0; li_4 < gia_2440[ai_0]; li_4++) 
			{
            ld_72 = iHigh(gs_2520, gia_3328[li_20], li_4);
            if (ld_72 > 0.0) 
				{
               if (ld_72 > ld_104 || (ld_104 - ld_120) / ld_104 < ld_40 / 100.0) 
					{
                  ld_104 = ld_72;
                  if (ld_120 > ld_112) ld_120 = ld_112;
                  ld_112 = ld_72;
               } 
					else
                  if (ld_72 < ld_112) 
							ld_112 = ld_72;
               if ((ld_104 - ld_112) / ld_104 >= ld_40 / 100.0 && (ld_104 - ld_120) / ld_104 >= ld_40 / 100.0) 
					{
                  lda_56[li_8] = ld_104;
                  li_8++;
                  ld_104 = ld_72;
                  ld_120 = ld_72;
                  ld_112 = ld_72;
               }
            }
         }
         ld_128 = 0;
         for (li_4 = 0; li_4 < li_8; li_4++)
            if (gd_2544 < lda_56[li_4] && gd_2544 <= lda_56[li_4] * (1 - 5.0 * ld_48 / 100.0) && lda_56[li_4] < ld_128 || ld_128 == 0.0) 
					ld_128 = lda_56[li_4];
         if (ld_128 > 0.0) 
				gd_2968 = NormalizeDouble(ld_128 * (1 - ld_48 / 100.0), gd_2536);
         else 
				gd_2968 = NormalizeDouble(gd_2944 * (5.0 * ld_48 / 100.0 + 1.0), gd_2536);
         if (gda_2452[ai_0] > 0.0) 
				gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * gda_2452[ai_0] / 100.0, gd_2536);
      }
   }
   if (gi_3036 == gi_3308) 
	{
      for (li_4 = 0; li_4 < li_8; li_4++) 
		{
         if (gd_2544 < lda_56[li_4] && gd_2544 >= lda_56[li_4] * (1 - ld_32 / 100.0)) 
			{
            if (iHigh(gs_2520, gia_3328[li_16], 0) > lda_56[li_4] || iHigh(gs_2520, gia_3328[li_16], 1) > lda_56[li_4]) 
					continue;
            gi_3052 = TRUE;
            gi_2916 = 1;
            gd_2944 = gd_2984;
            break;
         }
      }
      if (gi_3052) 
		{
         ArrayResize(lda_60, gia_2440[ai_0]);
         li_12 = 0;
         ld_80 = gd_2544;
         ld_88 = gd_2544;
         ld_96 = gd_2544;
         ld_64 = 0;
         for (li_4 = 0; li_4 < gia_2440[ai_0]; li_4++) 
			{
            ld_64 = iLow(gs_2520, gia_3328[li_20], li_4);
            if (ld_64 > 0.0) 
				{
               if (ld_64 < ld_80 || (ld_88 - ld_80) / ld_80 < ld_40 / 100.0) 
					{
                  ld_80 = ld_64;
                  if (ld_88 < ld_96) 
							ld_88 = ld_96;
                  ld_96 = ld_64;
               } 
					else
                  if (ld_64 > ld_96) 
							ld_96 = ld_64;
               if ((ld_96 - ld_80) / ld_80 >= ld_40 / 100.0 && (ld_88 - ld_80) / ld_80 >= ld_40 / 100.0) 
					{
                  lda_60[li_12] = ld_80;
                  li_12++;
                  ld_80 = ld_64;
                  ld_88 = ld_64;
                  ld_96 = ld_64;
               }
            }
         }
         ld_136 = 0;
         for (li_4 = 0; li_4 < li_12; li_4++)
            if (gd_2544 > lda_60[li_4] && gd_2544 >= lda_60[li_4] * (5.0 * ld_48 / 100.0 + 1.0) && lda_60[li_4] > ld_136 || ld_136 == 0.0) 
					ld_136 = lda_60[li_4];
         if (ld_136 > 0.0) 
				gd_2968 = NormalizeDouble(ld_136 * (ld_48 / 100.0 + 1.0), gd_2536) + gd_2560 * gd_2528;
         else 
				gd_2968 = NormalizeDouble(gd_2944 * (1 - 5.0 * ld_48 / 100.0), gd_2536);
         if (gda_2452[ai_0] > 0.0) 
				gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * gda_2452[ai_0] / 100.0, gd_2536);
      }
   }
   if (gi_3052) 
		gi_2920 = gi_2876 + 420;
}

void f0_42() 
{
   double ld_0 = iSAR(gs_2520, gia_3328[diSAR_RO_TimeFrame], diSAR_RO_Step, diSAR_RO_Maximum, 0);
   double ld_8 = iSAR(gs_2520, gia_3328[diSAR_RO_TimeFrame], diSAR_RO_Step, diSAR_RO_Maximum, 1);
   double ld_16 = iSAR(gs_2520, gia_3328[diSAR_RO_TimeFrame], diSAR_RO_Step, diSAR_RO_Maximum, 2);
   double ld_24 = iSAR(gs_2520, gia_3328[diSAR_RO_TimeFrame], diSAR_RO_Step, diSAR_RO_Maximum, 3);
   double ld_32 = iClose(gs_2520, gia_3328[diSAR_RO_TimeFrame], 1);
   double ld_40 = iClose(gs_2520, gia_3328[diSAR_RO_TimeFrame], 2);
   double ld_48 = iClose(gs_2520, gia_3328[diSAR_RO_TimeFrame], 3);

   if (gi_3036 == gi_3304 && ld_0 < gd_2984 && ld_8 < ld_32 && ld_16 > ld_40 && ld_24 > ld_48) 
	{
      gi_3052 = TRUE;
      gi_2916 = 0;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
   }
   if (gi_3036 == gi_3308 && ld_0 > gd_2984 && ld_8 > ld_32 && ld_16 < ld_40 && ld_24 < ld_48) 
	{
      gi_3052 = TRUE;
      gi_2916 = 1;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
   }
   if (gi_3052) 
		gi_2920 = gi_2876 + 610;
}

void f0_36() 
{
   double ld_0;
   bool li_8;
   int li_12;
   bool li_16;
   
	if (gi_3036 == gi_3304 && gd_3228 < gd_3220 && gd_3244 < gd_3236 && gd_3260 > gd_3252) 
	{
      gi_3052 = TRUE;
      gi_2916 = 0;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diStoch_RO_TakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 + NormalizeDouble(gd_2984 * diStoch_RO_TakeProfit_PR / 100.0, gd_2536);
      if (diStoch_RO_StopLoss_PR > 0.0) 
			gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * diStoch_RO_StopLoss_PR / 100.0, gd_2536);
      if (diStoch_RO_UseAverageTP == 1 && gia_3104[gi_2916] != 0) 
		{
         ld_0 = gda_3108[gi_2916];
         if (ld_0 > gd_2944) 
				gd_2968 = gd_2944 + (ld_0 - gd_2944) / 2.0;
      }
   }
   if (gi_3036 == gi_3308 && gd_3228 > gd_3220 && gd_3244 > gd_3236 && gd_3260 < gd_3252) 
	{
      gi_3052 = TRUE;
      gi_2916 = 1;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diStoch_RO_TakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 - NormalizeDouble(gd_2984 * diStoch_RO_TakeProfit_PR / 100.0, gd_2536);
      if (diStoch_RO_StopLoss_PR > 0.0) 
			gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * diStoch_RO_StopLoss_PR / 100.0, gd_2536);
      if (diStoch_RO_UseAverageTP == 1 && gia_3104[gi_2916] != 0) 
		{
         ld_0 = gda_3112[gi_2916];
         if (ld_0 < gd_2944) 
				gd_2968 = gd_2944 - (gd_2944 - ld_0) / 2.0;
      }
   }
   if (gi_3052) 
	{
      gi_2920 = gi_2876 + 620;
      if (diStoch_RO_ReverseClose == 1) 
		{
         if (gi_2916 == 0) 
				li_8 = TRUE;
         else
            if (gi_2916 == 1) 
					li_8 = FALSE;
         if (diStoch_RO_RevCloseOnlyProfit == 1) 
				li_16 = TRUE;
         else 
				li_16 = FALSE;
         li_12 = OrdersTotal();
         f0_7(li_8, gs_2520, 1, li_16, gi_2920);
         if (OrdersTotal() != li_12) 
				f0_13();
      }
   }
}

void f0_51() 
{
   double lda_16[3];
   int li_20;
   bool li_24;
   gi_2920 = gi_2876 + 630;
   double ld_0 = iADX(gs_2520, gia_3328[diADX_RO_TimeFrame], diADX_RO_Period, diADX_RO_TypePrice, MODE_PLUSDI, 0);
   double ld_8 = iADX(gs_2520, gia_3328[diADX_RO_TimeFrame], diADX_RO_Period, diADX_RO_TypePrice, MODE_MINUSDI, 0);
	
   lda_16[0] = iADX(gs_2520, gia_3328[diADX_RO_TimeFrame], diADX_RO_Period, diADX_RO_TypePrice, MODE_MAIN, 0);
   lda_16[1] = iADX(gs_2520, gia_3328[diADX_RO_TimeFrame], diADX_RO_Period, diADX_RO_TypePrice, MODE_MAIN, 1);
   lda_16[2] = iADX(gs_2520, gia_3328[diADX_RO_TimeFrame], diADX_RO_Period, diADX_RO_TypePrice, MODE_MAIN, 2);
   if (diADX_RO_CloseOnlyProfit != -1) 
	{
      if (diADX_RO_CloseOnlyProfit == 1) 
			li_24 = TRUE;
      else 
			li_24 = FALSE;
      li_20 = OrdersTotal();
      if (diADX_RO_ValueToCloseOrders != 0.0 && lda_16[1] >= diADX_RO_ValueToCloseOrders && lda_16[0] < lda_16[1] && lda_16[1] < lda_16[2]) 
			f0_7(-1, gs_2520, 1, 1, gi_2920);
      if (lda_16[0] < lda_16[1] && lda_16[1] < lda_16[2] && lda_16[1] < diADX_RO_ValueSignalEndTrend && lda_16[2] >= diADX_RO_ValueSignalEndTrend) 
			f0_7(-1, gs_2520, 1, li_24, gi_2920);
      if (ld_0 < ld_8) 
			f0_7(OP_BUY, gs_2520, 1, li_24, gi_2920);
      if (ld_0 > ld_8) 
			f0_7(OP_SELL, gs_2520, 1, li_24, gi_2920);
      if (OrdersTotal() != li_20) 
			f0_13();
   }
   if (lda_16[0] > lda_16[1] && lda_16[1] > lda_16[2] && lda_16[1] >= diADX_RO_ValueSignalTrend && lda_16[2] < diADX_RO_ValueSignalTrend) 
	{
      if (gi_3036 == gi_3304 && ld_0 > ld_8) 
		{
         gi_3052 = TRUE;
         gi_2916 = 0;
         gd_2944 = gd_2984;
         gd_2968 = 0;
         gd_2960 = 0;
         if (diADX_RO_TakeProfit_PR > 0.0) 
				gd_2968 = gd_2944 + NormalizeDouble(gd_2984 * diADX_RO_TakeProfit_PR / 100.0, gd_2536);
         if (diADX_RO_StopLoss_PR > 0.0) 
				gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * diADX_RO_StopLoss_PR / 100.0, gd_2536);
         if (diADX_RO_UseAverageTP == 1 && gia_3104[gi_2916] != 0) 
			{
            gd_3000 = gda_3108[gi_2916];
            if (gd_3000 > gd_2944) 
				{
               gd_2968 = gd_2944 + (gd_3000 - gd_2944) / 2.0;
               return;
            }
         }
      } 
		else 
		{
         if (gi_3036 == gi_3308 && ld_0 < ld_8) 
			{
            gi_3052 = TRUE;
            gi_2916 = 1;
            gd_2944 = gd_2984;
            gd_2968 = 0;
            gd_2960 = 0;
            if (diADX_RO_TakeProfit_PR > 0.0) 
					gd_2968 = gd_2944 - NormalizeDouble(gd_2984 * diADX_RO_TakeProfit_PR / 100.0, gd_2536);
            if (diADX_RO_StopLoss_PR > 0.0) 
					gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * diADX_RO_StopLoss_PR / 100.0, gd_2536);
            if (diADX_RO_UseAverageTP == 1 && gia_3104[gi_2916] != 0) 
				{
               gd_3000 = gda_3112[gi_2916];
               if (gd_3000 < gd_2944) 
						gd_2968 = gd_2944 - (gd_2944 - gd_3000) / 2.0;
            }
         }
      }
   }
}

void f0_10() 
{
   bool li_24;
   int li_28;
   bool li_32;
   double ld_0 = iCCI(gs_2520, gia_3328[diCCI_RO_TimeFrame], diCCI_RO_Period_Slow, diCCI_RO_TypePrice, 0);
   double ld_8 = iCCI(gs_2520, gia_3328[diCCI_RO_TimeFrame], diCCI_RO_Period_Medium, diCCI_RO_TypePrice, 0);
   double ld_16 = iCCI(gs_2520, gia_3328[diCCI_RO_TimeFrame], diCCI_RO_Period_Fast, diCCI_RO_TypePrice, 0);
	
   if (gi_3036 == gi_3304 && ld_8 <= 0.0 && ld_0 >= 0.0 && ld_16 > 0.0) 
	{
      gi_3052 = TRUE;
      gi_2916 = 0;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diCCI_RO_TakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 + NormalizeDouble(gd_2984 * diCCI_RO_TakeProfit_PR / 100.0, gd_2536);
      if (diCCI_RO_StopLoss_PR > 0.0) 
			gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * diCCI_RO_StopLoss_PR / 100.0, gd_2536);
   }
   if (gi_3036 == gi_3308 && ld_8 >= 0.0 && ld_0 <= 0.0 && ld_16 < 0.0) 
	{
      gi_3052 = TRUE;
      gi_2916 = 1;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diCCI_RO_TakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 - NormalizeDouble(gd_2984 * diCCI_RO_TakeProfit_PR / 100.0, gd_2536);
      if (diCCI_RO_StopLoss_PR > 0.0) 
			gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * diCCI_RO_StopLoss_PR / 100.0, gd_2536);
   }
   if (gi_3052) 
	{
      gi_2920 = gi_2876 + 640;
      if (diCCI_RO_ReverseClose == 1) 
		{
         if (gi_2916 == 0) 
				li_24 = TRUE;
         else
            if (gi_2916 == 1) 
					li_24 = FALSE;
         if (diCCI_RO_RevCloseOnlyProfit == 1) 
				li_32 = TRUE;
         else 
				li_32 = FALSE;
         li_28 = OrdersTotal();
         f0_7(li_24, gs_2520, 1, li_32, gi_2920);
         if (OrdersTotal() != li_28) 
				f0_13();
      }
   }
}

int f0_40() 
{
   int li_0 = 60 * gi_1132 + dSCL_StartWorkMinute;
   int li_4 = 60 * gi_1144 + dSCL_EndWorkMinute;
   int li_8 = 60 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent());

   if (li_0 == li_4) 
		return (1);
   if (li_0 < li_4) 
	{
      if (!(li_8 >= li_0 && li_8 <= li_4)) 
			return (0);
      return (1);
   }
   if (li_8 > li_4 && li_8 < li_0) 
		return (0);
   return (1);
}

void f0_27() 
{
	double ld_0;
	double ld_8;
	double ld_16;
   bool li_24;
   int li_28;
   bool li_32;

   if (dSCL_MaxSpread != 0)
      if (gd_2560 > dSCL_MaxSpread) 
			return;
   if (dSCL_UseTimeWork == 1)
      if (!(f0_40())) 
			return;
   ld_0 = iRSI(gs_2520, gia_3328[diSCL_RSI1_TimeFrame], diSCL_RSI1_Period, PRICE_CLOSE, 0);
   ld_8 = iRSI(gs_2520, gia_3328[diSCL_RSI2_TimeFrame], diSCL_RSI2_Period, PRICE_CLOSE, 0);
   ld_16 = iMA(gs_2520, gia_3328[diSCL_MA_TimeFrame], diSCL_MA_Period, 0, MODE_SMA, PRICE_CLOSE, 1);
   if (gi_3036 == gi_3304 && ld_0 < diSCL_RSI1_Value || ld_8 < diSCL_RSI2_Value && ld_16 >= gd_2544 * (diSCL_MinDistFromMA_PR / 100.0 + 1.0)) 
	{
      gi_3052 = TRUE;
      gi_2916 = 0;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diSCL_ShowTakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 + NormalizeDouble(gd_2984 * diSCL_ShowTakeProfit_PR / 100.0, gd_2536);
      if (diSCL_ShowStopLoss_PR > 0.0) 
			gd_2960 = gd_2944 - NormalizeDouble(gd_2984 * diSCL_ShowStopLoss_PR / 100.0, gd_2536);
   }
   if (gi_3036 == gi_3308 && ld_0 > 100 - diSCL_RSI1_Value || ld_8 > 100 - diSCL_RSI2_Value && ld_16 <= gd_2544 * (1 - diSCL_MinDistFromMA_PR / 100.0)) 
	{
      gi_3052 = TRUE;
      gi_2916 = 1;
      gd_2944 = gd_2984;
      gd_2968 = 0;
      gd_2960 = 0;
      if (diSCL_ShowTakeProfit_PR > 0.0) 
			gd_2968 = gd_2944 - NormalizeDouble(gd_2984 * diSCL_ShowTakeProfit_PR / 100.0, gd_2536);
      if (diSCL_ShowStopLoss_PR > 0.0) 
			gd_2960 = gd_2944 + NormalizeDouble(gd_2984 * diSCL_ShowStopLoss_PR / 100.0, gd_2536);
   }
   if (gi_3052) 
	{
      gi_2920 = gi_2876 + 220;
      if (diSCL_ReverseClose == 1) 
		{
         if (gi_2916 == 0) 
				li_24 = TRUE;
         else
            if (gi_2916 == 1) 
					li_24 = FALSE;
         if (diSCL_RevCloseOnlyProfit == 1) 
				li_32 = TRUE;
         else 
				li_32 = FALSE;
         li_28 = OrdersTotal();
         f0_7(li_24, gs_2520, 1, li_32, gi_2920);
         if (OrdersTotal() != li_28) 
				f0_13();
      }
   }
}

void f0_48(int ai_0) 
{
	int li_8;
   double ld_12;
   double ld_20;
   double ld_28;

   if (dUseCloseOpeningGAP != 1 || !f0_35(gs_2520, CustomNameForCurrencyPair)) 
		return;
   li_8 = TimeCurrent();
   if (gi_3036 == gi_3304 && TimeDayOfYear(li_8) == gia_3296[ai_0]) 
		return;
   if (gi_3036 == gi_3308 && TimeDayOfYear(li_8) == gia_3300[ai_0]) 
		return;
   if (TimeDayOfWeek(li_8) == 1) 
	{
      if (TimeDayOfYear(gd_2576) == TimeDayOfYear(li_8)) 
		{
         if (gi_3036 == gi_3304) 
				gia_3296[ai_0] = TimeDayOfYear(li_8);
         if (gi_3036 == gi_3308) 
				gia_3300[ai_0] = TimeDayOfYear(li_8);
         ld_20 = iClose(gs_2520, PERIOD_D1, 1);
         ld_12 = iOpen(gs_2520, PERIOD_D1, 0);
         if (ld_20 <= 0.0 || ld_12 <= 0.0) 
				return;
         ld_28 = 100.0 * (MathAbs(ld_20 - ld_12) / ld_20);
         if (MathAbs(ld_20 - ld_12) > gd_2560 * gd_2528 && (gi_3036 == gi_3304 && ld_12 < ld_20) || (gi_3036 == gi_3308 && ld_12 > ld_20)) 
				Print("COG:  Close = ", ld_20, "  Open = ", ld_12, "  Abs.GAP = ", MathAbs(ld_20 - ld_12), "  GAP_PR = ", ld_28);
         if (ld_28 >= diCOG_MinSizeGAP_PR) 
			{
            if (diCOG_MaxSizeGAP_PR > 0.0 && ld_28 > diCOG_MaxSizeGAP_PR) 
					return;
            if (gi_3036 == gi_3304 && ld_12 < ld_20 && gd_2544 <= ld_12) 
				{
               gi_3052 = TRUE;
               gi_2916 = 0;
               gd_2944 = gd_2984;
               gd_2968 = 0;
               gd_2960 = 0;
               if (diCOG_TakeProfit_KF_GAP > 0.0) 
						gd_2968 = gd_2944 + NormalizeDouble((ld_20 - ld_12) * diCOG_TakeProfit_KF_GAP, gd_2536);
               if (diCOG_StopLoss_KF_GAP > 0.0) 
						gd_2960 = gd_2944 - NormalizeDouble((ld_20 - ld_12) * diCOG_StopLoss_KF_GAP, gd_2536);
            }
            if (gi_3036 == gi_3308 && ld_12 > ld_20 && gd_2544 >= ld_12) 
				{
               gi_3052 = TRUE;
               gi_2916 = 1;
               gd_2944 = gd_2984;
               gd_2968 = 0;
               gd_2960 = 0;
               if (diCOG_TakeProfit_KF_GAP > 0.0) 
						gd_2968 = gd_2944 - NormalizeDouble((gd_2544 - ld_20) * diCOG_TakeProfit_KF_GAP, gd_2536);
               if (diCOG_StopLoss_KF_GAP > 0.0) 
						gd_2960 = gd_2944 + NormalizeDouble((gd_2544 - ld_20) * diCOG_StopLoss_KF_GAP, gd_2536);
            }
            if (gi_3052) 
					gi_2920 = gi_2876 + 720;
         }
      }
   }
}

void f0_6() 
{
   if (gi_3036 == gi_3304 && gd_3120 > 0.0) 
	{
      gi_3052 = TRUE;
      gi_2916 = 0;
      gd_2944 = gd_2984;
      if (gi_2736 == 1) 
			gd_2968 = gd_2944 + MarketInfo(gs_2520, MODE_STOPLEVEL) * gd_2528;
      if (gi_2740 > 0) 
			gd_2960 = gd_2944 - gi_2740 * gd_2528;
      else 
			gd_2960 = 0;
   }
   if (gi_3036 == gi_3308 && gd_3120 < 0.0) 
	{
      gi_3052 = TRUE;
      gi_2916 = 1;
      gd_2944 = gd_2984;
      if (gi_2736 == 1) 
			gd_2968 = gd_2        

Recommend