From 5e8df132d43cc5ddb6bb9ce11d0489b899daf9e7 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 21 Jun 2024 10:30:01 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.setup.xea.mq5 | 150 ++++++++------------------ Experts/x-saherelm.x121.ea.mq5 | 26 ++--- 2 files changed, 57 insertions(+), 119 deletions(-) diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 848b6b42..cef0c859 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -190,6 +190,12 @@ struct XTradeInfo pivots // ); tSignal.Clean(); + int pivotsCount = ArraySize(pivots); + if (!IsValidSize(pivotsCount)) + { + // + Print("Dangerous Position ..."); + } // return result; @@ -4243,13 +4249,6 @@ public: mTradeHandler.Sync(); } - // - // Orders Changed ... - void OnOrdersChangedHandler(int count) override - { - EQMHandleSupportProtection(count); - } - // void OnPositionClosed( const XPosition &position, @@ -4893,6 +4892,25 @@ private: // // TODO: Implement it ... + + // + XSignal signals[]; + + // + if (isValid) + { + // + AddRef( + signal, + signals // + ); + } + + // + if (ArraySize(signals) > 0) + { + EQMExecuteSignals(signals); + } } // @@ -4951,6 +4969,24 @@ private: continue; } + // + XPosition iParent; + bool hasParent = mTrader.GetPosition( + iParentTicket, + iParent // + ); + if (!hasParent) + { + continue; + } + + // + // Check Parent Has TP or SL ... + if (iParent.tp == 0 && iParent.sl == 0) + { + continue; + } + // // Remove TP and SL of Supported Positions ... string comment = "EQM Remove TPSL ..."; @@ -4970,106 +5006,6 @@ private: } } - // - void EQMHandleSupportProtection(int count) - { - // // - // if (IsValidSize(count)) - // { - // return; - // } - - // // - // // This means on order Executed ... - // ulong ticket = mTrader.GetLastOpenPositionTicket(); - - // // - // XPosition position; - // bool hasPosition = mTrader.GetPosition( - // ticket, - // position // - // ); - // if (!hasPosition) - // { - // return; - // } - - // // - // bool isSupport = IsSupport(position.comment); - // if (!isSupport) - // { - // return; - // } - - // // - // bool isInDirectional = position.provider == XEQMSupportToken + XINDirectionalToken; - // if (!isInDirectional) - // { - // return; - // } - - // // - // XPosition parent; - // ulong parentTicket = ExtractParentTicket(position.comment); - // bool hasParent = mTrader.GetPosition( - // parentTicket, - // parent // - // ); - - // // - // if (!hasParent) - // { - // return; - // } - - // // - // // Remove Parent TP SL ... - // if (parent.tp > 0 || parent.sl > 0) - // { - // // - // string comment = XEQMSupportToken + " Remoove TP/SL due Protect ..."; - // bool isModeified = mTrader.Modify( - // parentTicket, - // 0, - // 0, - // comment // - // ); - // if (isModeified) - // { - // // - // string message = XEQMSupportToken + " Removes Position (" + ToString(parentTicket) + ")' TP/SL Due Start Supporting ..."; - - // // - // Alert(message); - // } - // } - - // // - // XSignal signal; - // X121SignalGenerator signalGenerator; - // bool hasSupport = signalGenerator.PrepareDirectionalSupportSignals( - // position, - // parent, - // signal // - // ); - // if (!hasSupport) - // { - // return; - // } - - // // - // XSignal signals[]; - - // // - // AddRef( - // signal, - // signals // - // ); - - // // - // EQMExecuteSignals(signals); - } - // }; diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index 014fae0b..7a16120c 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -40,13 +40,13 @@ input int x121EASlippage = 10; // Slippgae // EURUSDb,GBPUSDb,XAUUSDb,USDCHFb,USDJPYb input group "Signals"; // EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD -input string x121EASymbols = ""; // 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 = 5; // Required Verifications for Signals -input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames +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 ... @@ -76,7 +76,7 @@ input double x121EANextTrailPoint = 20; // Next Trailling Step // input group "Supporting"; -input bool x121EAAllowSupport = true; // Allow Support Signals +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 @@ -100,8 +100,8 @@ input double x121EAMaxAllowedRecoveryVolume = 0.08; // Max Allowed Recovery Sign // input group "Hedging"; -input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge -input double x121EAMinRequiredProfitPerTrade = 0.4; // Minimum Required Profit for 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 @@ -369,9 +369,11 @@ bool InitialEA() } // -void PreConfigureStyles(X121SetupInputs &inputs) { +void PreConfigureStyles(X121SetupInputs &inputs) +{ // - if (!inputs.IsValid()) { + if (!inputs.IsValid()) + { return; }