/////////////////////////////////////////////////////// // // SaherElm IT Center X121EA MQL5 Expert Advisor // ------------------------------------------------- // Name: X121EA // Description: an Exper Advisor which used RSI and MA // to Analyse Market ... // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // //////////////////////////////////////////////////////x // // Global Properties ... #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm X121EA" #property strict // // Imports ... #include "../Classes/x-saherelm.x121.setup.xea.mq5" // #define ShortName "X121EA" // // Inputs ... // // Common ... input group "Common"; input long x121EAMagicNumber = 78692110; // Magic Number input int x121EASlippage = 10; // Slippgae // // Signals ... // EURUSDb,GBPUSDb,XAUUSDb,USDCHFb,USDJPYb input group "Signals"; // EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD input string x121EASymbols = "EURUSDb,USDCHFb,XAUUSDb,USDJPYb,GBPUSDb"; // Symbols input bool x121EAUseAllSymbols = false; // Use All Available Symbols input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols input bool x121EAAllowLong = true; // Allow Long Trades input bool x121EAAllowShort = true; // Allow Short Trades input int x121EAReuiredSignalVerifications = 2; // Required Verifications for Signals input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames // // Risk Management ... input group "Risk Management"; input double x121EAVolume = 0.01; // Static Volume input double x121EATPPoint = 500; // TP Point input double x121EASLPoint = 500; // SL Point input int x121EAMaxAllowedTrades = 1; // Max Allowed Positions input bool x121EAIgnoreSL = false; // Ignore Calculated SL input bool x121EAIgnoreTP = false; // Ignore Calculated TP // // Protection ... input group "Signalling"; input int x121EAStartSignallingHoure = 3; // Start Signalling at Specific Time input int x121EAEndSignallingHoure = 22; // End Signalling at Specific Time input int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit // input group "Trailling"; input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses input double x121EAFirstTrailDistance = 110; // Start Trailling Distance input double x121EAFirstTrailPoint = 60; // First Stop Trail input double x121EANextTrailDistance = 50; // Next Trailling Distance input double x121EANextTrailPoint = 20; // Next Trailling Step // input group "Supporting"; input bool x121EAAllowSupport = false; // Allow Support Signals double x121EASupportDistance = 50; // Supporting Distance input int x121EAMaxNumberOfSupports = 1; // Max Number of Support Signals input double x121EASupportVolumeMultiplier = 2.0; // Support Signals Volume Multiplier input double x121EAMaxAllowedSupportVolume = 0.04; // Max Allowed Support Signals Volume // input group "Grid"; input bool x121EAAllowGrid = false; // Allow Grid Signals input int x121EAMaxNumberOfGrids = 5; // Max Number of Grid Signals input double x121EAGridDistance = 100; // Grid Distance input double x121EAGridVolumeMultiplier = 2.0; // Grid Volume Multiplier input double x121EAMaxAllowedGridVolume = 0.04; // Max Allowed Grid Signals Volume // input group "Recovery"; input bool x121EAAllowRecovery = false; // Allow Recovery Signals input int x121EAMaxNumberOfRecoveries = 3; // Max Number of Recovery Signals input double x121EARecoveryDistance = 100; // Recovery Distance input double x121EARecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier input double x121EAMaxAllowedRecoveryVolume = 0.08; // Max Allowed Recovery Signals Volume // input group "Hedging"; input int x121EARestingAfterHedge = 0; // Resting Seconds After Hedge input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume input double x121EAForceCloseProfit = 20; // Close All Positions Regardless of Policies when Profit Reached // // Alert ... input group "Alerts"; input bool x121EAEnableAlerts = true; // Enable Alerts input bool x121EALogAlerts = true; // Log Alerts input bool x121EAMailAlerts = false; // Mail Alerts input bool x121EAPushAlerts = false; // Push Alerts input bool x121EATerminalAlerts = false; // Terminal Alerts // // Definitions ... // // Local Variables ... // XSCX121SetupEA *x121EA; // // Event Handlers ... // // Initialization ... int OnInit() { // drawPrefix = ShortName; // if (!InitialEA()) { return INIT_PARAMETERS_INCORRECT; } // // 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 XSampleEA Providers ... delete x121EA; } // // On Tick Handler ... void OnTick() { x121EA.OnTick(); } // // Custom Functions ... // bool InitialEA() { // bool result = false; // TesterHideIndicators(true); // string inputSymbols[]; int inputSymbolsCount = SplitContent( inputSymbols, x121EASymbols // ); // string allSymbols[]; int allSymbolsCount = GetAllSymbols( allSymbols // ); // string watchListSymbols[]; int watchListSymbolsCount = GetAllSymbols( watchListSymbols, true // ); // string symbols[]; if (x121EAUseAllSymbols) { // Copy( allSymbols, symbols // ); } else if (x121EAUseAllWatchListSymbols) { // Copy( watchListSymbols, symbols // ); } else if (IsValidSize(inputSymbolsCount)) { // Copy( inputSymbols, symbols // ); } else { // Add( _Symbol, symbols // ); } int symbolsCount = ArraySize(symbols); result = IsValidSize(symbolsCount); if (!result) { return result; } // x121EA = new XSCX121SetupEA( x121EASlippage, x121EAMagicNumber // ); // // Configure EA Class Instance ... // // Signals ... x121EA.AllowLong(x121EAAllowLong); x121EA.AllowShort(x121EAAllowShort); x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications); x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames); // // Risk Management ... x121EA.Volume(x121EAVolume); x121EA.TPPoint(x121EATPPoint); x121EA.SLPoint(x121EASLPoint); x121EA.IgnoreSL(x121EAIgnoreSL); x121EA.IgnoreTP(x121EAIgnoreTP); x121EA.MaxAllowedTrades(x121EAMaxAllowedTrades); // // Protection ... // // Signalling ... x121EA.CloseOnOpposit(x121EACloseOnOpposit); x121EA.EndSignallingHoure(x121EAEndSignallingHoure); x121EA.CloseOnSpecificTime(x121EACloseOnSpecificTime); x121EA.StartSignallingHoure(x121EAStartSignallingHoure); // // Trailling ... x121EA.AllowTrailStop(x121EAAllowTrailStop); x121EA.NextTrailPoint(x121EANextTrailPoint); x121EA.FirstTrailPoint(x121EAFirstTrailPoint); x121EA.NextTrailDistance(x121EANextTrailDistance); x121EA.FirstTrailDistance(x121EAFirstTrailDistance); // // Supporting ... x121EA.AllowSupport(x121EAAllowSupport); x121EA.SupportDistance(x121EASupportDistance); x121EA.MaxNumberOfSupports(x121EAMaxNumberOfSupports); x121EA.SupportVolumeMultiplier(x121EASupportVolumeMultiplier); x121EA.MaxAllowedSupportVolume(x121EAMaxAllowedSupportVolume); // // Grid ... x121EA.AllowGrid(x121EAAllowGrid); x121EA.GridDistance(x121EAGridDistance); x121EA.MaxNumberOfGrids(x121EAMaxNumberOfGrids); x121EA.GridVolumeMultiplier(x121EAGridVolumeMultiplier); x121EA.MaxAllowedGridVolume(x121EAMaxAllowedGridVolume); // // Recovery ... x121EA.AllowRecovery(x121EAAllowRecovery); x121EA.RecoveryDistance(x121EARecoveryDistance); x121EA.MaxNumberOfRecoveries(x121EAMaxNumberOfRecoveries); x121EA.RecoveryVolumeMultiplier(x121EARecoveryVolumeMultiplier); x121EA.MaxAllowedRecoveryVolume(x121EAMaxAllowedRecoveryVolume); // // Hedging ... x121EA.ForceCloseProfit(x121EAForceCloseProfit); x121EA.RestingAfterHedge(x121EARestingAfterHedge); x121EA.MinRequiredProfitPerTrade(x121EAMinRequiredProfitPerTrade); x121EA.MinRequiredProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor); // // Alert ... x121EA.SetAlertPrefix(ShortName); x121EA.SetAlertEnableAlerts(x121EAEnableAlerts); x121EA.SetAlertLogAlerts(x121EALogAlerts); x121EA.SetAlertMailAlerts(x121EAMailAlerts); x121EA.SetAlertPushAlerts(x121EAPushAlerts); x121EA.SetAlertTerminalAlerts(x121EATerminalAlerts); // // Configure Indicators ... X121SetupInputs setupInputsDefault; setupInputsDefault.Default(); PreConfigureStyles(setupInputsDefault); // // Prepare Providers and Add them into mX121EA class ... for (int i = 0; i < symbolsCount; i++) { // // Requirements ... string iSymbol = symbols[i]; ENUM_TIMEFRAMES iHostPeriod = _Period; // XSCX121SetupCycles *iSetupCycle; iSetupCycle = new XSCX121SetupCycles(); result = iSetupCycle.Init( setupInputsDefault, iSymbol, iHostPeriod // ); if (!result) { break; } // result = x121EA.AddSetup(iSetupCycle); if (!result) { break; } } // return result; } // void PreConfigureStyles(X121SetupInputs &inputs) { // if (!inputs.IsValid()) { return; } // // XPV ... inputs.pvInputs.showPeaksAndVales = true; inputs.pvInputs.showLevels = false; inputs.pvInputs.showConsolidations = false; inputs.pvInputs.showFibo1Levels = true; inputs.pvInputs.showFibo2Levels = true; inputs.pvInputs.showFibo3Levels = true; inputs.pvInputs.showFibo4Levels = true; inputs.pvInputs.showFibo5Levels = true; // // XHK ... inputs.hkInputs.drawHikenAshi = false; inputs.hkInputs.drawSmoothedHikenAshi = false; // // XCHE ... inputs.cheInputs.showLongExit1Line = false; inputs.cheInputs.showShortExit1Line = false; inputs.cheInputs.showLongExit2Line = false; inputs.cheInputs.showShortExit2Line = false; // // XICH ... inputs.ichInputs.showTenkanSen = false; inputs.ichInputs.showKijunSen = false; inputs.ichInputs.showKijunSenPlus = false; inputs.ichInputs.showKijunSenNegative = false; inputs.ichInputs.showChikouSpan = false; inputs.ichInputs.showSenkouSpanA = false; inputs.ichInputs.showSenkouSpanB = false; inputs.ichInputs.showKumo = false; // // XSTR ... inputs.strInputs.showTrends = false; inputs.strInputs.fillTrends = false; // // XMRB ... inputs.mrbInputs.showFastMa = false; inputs.mrbInputs.showSlowMa = false; inputs.mrbInputs.showRibbon = false; // // XASCT ... inputs.asctInputs.showLongs = false; inputs.asctInputs.showShorts = false; // // XSSLC ... inputs.sslcInputs.showUp = false; inputs.sslcInputs.showDown = false; // // XHULL ... inputs.hullInputs.showUpZone = false; inputs.hullInputs.showDownZone = false; } //