/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Expert Advisor // ---------------------------------------- // Name: X121EA // Description: this is an expert controller // advisors which provides a mechanism for use them ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm X121EA" #property strict // // START Definitions ... // // // Common Library ... #include "../Classes/x-saherelm.x121.xea.class.mq5" // #define ShortName "X121EA" // // END Definitions ... // // // START Inputs ... // // // EA ... input group "Common"; input bool xEAEnable = true; // Enable EA input int xEASlippage = 10; // Slippgae input ulong xEAMagicNumber = 1604056; // Magic Number // // Signals ... input group "Signals"; input bool xEAEnableLongs = true; // Enable Long Trades input bool xEAEnableShorts = true; // Enable Short Trades // // Risk Management ... input group "Risk Management"; input int xEAMaxOpenPositions = 15; // Max Allowed Open Positions input double xEAMaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor // // Alerts ... input group "Alerts"; input bool xEAEnableAlerts = true; // Enable Events Alert input bool xEAEnableHourlyAlerts = false; // Send Alert on each new Hour input bool xEAEnableDailyAlerts = false; // Send Alert on each new Day input bool xEAEnableWeeklyAlerts = false; // Send Alert on each new Week input bool xEAEnableMonthlyAlerts = false; // Send Alert on each new Month // // END Inputs ... // // // START Including Providers ... // // // Logger Library ... #include "../Libraries/x-saherelm.log.lib.mq5" // // END Including Providers ... // // // START Global Definitions: Variables, Properties and etc ... // // XSCX121EA *mX121EA; // // END Global Definitions: Variables, Properties and etc ... // // // START Event Handlers ... // // // Initialization ... int OnInit() { // logTag = ShortName; drawPrefix = logTag; alertPrefix = logTag; // // Validate Inputs ... if (!ValidateInputs()) { return INIT_PARAMETERS_INCORRECT; } // InitEAInstance(); // // Init Succeed ... return INIT_SUCCEEDED; } // // DeInitialization ... void OnDeinit(const int reason) { // // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function // REASON_REMOVE 1 Program removed from a chart // REASON_RECOMPILE 2 Program recompiled // REASON_CHARTCHANGE 3 A symbol or a chart period is changed // REASON_CHARTCLOSE 4 Chart closed // REASON_PARAMETERS 5 Inputs changed by a user // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings // REASON_TEMPLATE 7 Another chart template applied // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value // REASON_CLOSE 9 Terminal closed // // De Initialize XEA Providers ... delete mX121EA; } // // On Tick Handler ... void OnTick() { // // Prevent Going Forward if user Disable it ... if (xEAEnable) { mX121EA.OnTick(); } } // // Handle Trade Events ... void OnTrade() { mX121EA.OnTrade(); } // // Handle Signal Event ... void OnSignalConditionsRecieved(X121MarketConditions &info) { } // // Handle StopLoss Event ... void OnStopLossTriggered(const XDeal &deal) { } // // Handle TakeProfit Event ... void OnTakeProfitTriggered(const XDeal &deal) { } // // Handle Deals Changed Event ... void OnDealsChangedHandler(int count) { } // // Handle Order Changed Event ... void OnOrdersChangedHandler(int count) { } // // Handle Position Changed Event ... void OnPositionsChangedHandler(int count) { } // // Handle Trade State Changed ... void OnTradeStateChangedHandler(const XOnTradeHandlerState &state) { } // // END Event Handlers ... // // // START Functions ... // // // Validate Input Args for Initialization ... bool ValidateInputs() { // bool result = true; // // Validate Args ... result = // xEASlippage > 0 && xEAMagicNumber > 0 // // TODO: add new validations here ... // ; // // Logging State ... string message = "Validation of (" + logTag + ") Inputs " + (result ? "Succeeded" : "Failed") + " ..."; LogMessage(message); // return result; } // // Initialize X121EA Class Instances ... void InitEAInstance() { // mX121EA = new XSCX121EA( _Symbol, _Period, xEAMagicNumber, xEASlippage, OnStopLossTriggered, OnTakeProfitTriggered, OnDealsChangedHandler, OnOrdersChangedHandler, OnPositionsChangedHandler, OnTradeStateChangedHandler, OnSignalConditionsRecieved); } // // END Functions ... //