From 94fb860aabb26351602a3ca4194205c553b7c702 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 28 Jun 2024 17:30:41 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.setup.xea.mq5 | 131 ++++++++++++++++++-------- Experts/x-saherelm.x121.ea.mq5 | 34 ++++--- 2 files changed, 110 insertions(+), 55 deletions(-) diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 16ec695f..a7b37669 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -3289,6 +3289,49 @@ public: mIgnoreSL = value; } + // + bool IncreaseNextSignalsVolume() + { + return mIncreaseNextSignalsVolume; + } + + // + void IncreaseNextSignalsVolume(bool value) + { + mIncreaseNextSignalsVolume = value; + } + + // + double IncreaseNextSignalsVolumeMultiplier() + { + return mIncreaseNextSignalsVolumeMultiplier; + } + + // + void IncreaseNextSignalsVolumeMultiplier(double value) + { + // + if (value <= 0) + { + value = 0; + } + + // + mIncreaseNextSignalsVolumeMultiplier = value; + } + + // + bool AcceptNextDirectionalSignalsWhenFirstInProfit() + { + return mAcceptNextDirectionalSignalsWhenFirstInProfit; + } + + // + void AcceptNextDirectionalSignalsWhenFirstInProfit(bool value) + { + mAcceptNextDirectionalSignalsWhenFirstInProfit = value; + } + // // Signalling ... @@ -4456,6 +4499,7 @@ public: // // Only Accept Next Same Type when Previous in Profit ... + bool isSameTypeExists = false; if (isSignalValid) { // @@ -4523,7 +4567,9 @@ public: } // - if (IsValidSize(iSymbolsPositionsCount)) + bool acceptNewOnlyWhenLastInProfit = AcceptNextDirectionalSignalsWhenFirstInProfit(); + isSameTypeExists = IsValidSize(iSymbolsPositionsCount); + if (isSameTypeExists && acceptNewOnlyWhenLastInProfit) { // XPosition youngest; @@ -4543,7 +4589,7 @@ public: } } - // + // // Multiply Signal Volume ... if (isSignalValid) { @@ -4586,11 +4632,13 @@ public: } // - IncreaseNextSignalsVolume - - // - // Ignore ... - iSignal.volume = iSignal.volume * multiplier; + bool canIncreaseVolume = IncreaseNextSignalsVolume(); + if (canIncreaseVolume) + { + // + double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier(); + iSignal.volume = iSignal.volume * (multiplier * volumeMultiplier); + } } // @@ -4606,11 +4654,14 @@ public: } // - // Cutom Signal Execution ... - HandleSignals(eSignals); + result = ArraySize(eSignals); // - result = ArraySize(signals); + // Cutom Signal Execution ... + if (IsValidSize(result)) + { + HandleSignals(eSignals); + } // return result; @@ -4948,14 +4999,16 @@ private: // // Risk Management ... - double mVolume; // Volume - double mTPPoint; // TP Point - double mSLPoint; // SL Point - int mMaxAllowedTrades; // Max Alloed Positions - bool mIncreaseNextSignalsVolume; // Increase Next Signals Volume - bool mUseMaxAllowedPerDirection; // Use Max Allowed Positions Per Direction - bool mIgnoreTP; // Ignore Calculated TP - bool mIgnoreSL; // Ignore Calculated SL + double mVolume; // Volume + double mTPPoint; // TP Point + double mSLPoint; // SL Point + bool mIgnoreTP; // Ignore Calculated TP + bool mIgnoreSL; // Ignore Calculated SL + int mMaxAllowedTrades; // Max Alloed Positions + bool mUseMaxAllowedPerDirection; // Use Max Allowed Positions Per Direction + bool mIncreaseNextSignalsVolume; // Increase Next Signals Volume + double mIncreaseNextSignalsVolumeMultiplier; // Increase Next Signals Volume Multiplier + bool mAcceptNextDirectionalSignalsWhenFirstInProfit; // Accept Same Symbol/Type Signal when Last in Profit // // Signalling ... @@ -4972,10 +5025,8 @@ private: // - Increase Volume Size of in Profit Positions; // - etc ... // bool mForceState; // Determine in Force State or not - int mDelayBetweenTwoSignal; // Delay between two same signal - int mMaxPositionsForce; // Max Number of Positions For Guard Handling double mMaxDrawdownForce; // Force Handling State on Drawdown for Guard - bool mAllowSymbolHedgeOnForce; // Allow Symbol Hedging on Force States + int mDelayBetweenTwoSignal; // Delay between two same signal double mMinFreeMargingForOpenTrades; // Min Free Margin for Open Trades // @@ -5394,26 +5445,26 @@ private: // ; - // - AddRef( - signal, - signals // - ); + // + AddRef( + signal, + signals // + ); - // - // Add new Signal Info ... - mTradeHandler.Add( - signal, - pushers, - canGrid, - canRecover, - canSupport, - conditions[0], - conditions[1], - conditions[2], - conditions[3], - conditions[4] // - ); + // + // Add new Signal Info ... + mTradeHandler.Add( + signal, + pushers, + canGrid, + canRecover, + canSupport, + conditions[0], + conditions[1], + conditions[2], + conditions[3], + conditions[4] // + ); } // diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index a291d92e..49468ecc 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -57,15 +57,17 @@ input bool x121EAGetVerificationFromOtherTimeFrames = true; // // Risk Management ... input group "Risk Management"; -input double x121EAVolume = 0.01; // Static Volume -input double x121EATPPoint = 1000; // TP Point -input double x121EASLPoint = 1000; // SL Point -input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol -input bool x121EAIncreaseNextSignalsVolume = false; // Increase Next Signals Volume -input int x121EAMinFreeMargingForOpenTrades = 900; // Min Margin For Opening Trades -input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction -input bool x121EAIgnoreSL = false; // Ignore Calculated SL -input bool x121EAIgnoreTP = false; // Ignore Calculated TP +input double x121EAVolume = 0.01; // Static Volume +input double x121EATPPoint = 1000; // TP Point +input double x121EASLPoint = 1000; // SL Point +input bool x121EAIgnoreSL = false; // Ignore Calculated SL +input bool x121EAIgnoreTP = false; // Ignore Calculated TP +input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol +input int x121EAMinFreeMargingForOpenTrades = 900; // Min Margin For Opening Trades +input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction +input bool x121EAIncreaseNextSignalsVolume = false; // Increase Next Signals Volume +input double x121EAIncreaseNextSignalsVolumeMultiplier = 1; // Increase Next Signals Volume Multiplier +input bool x121EAAcceptNextDirectionalSignalsWhenFirstInProfit = true; // Accept Same Symbol/Type Signal when Last in Profit // // Protection ... @@ -79,10 +81,10 @@ input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit input group "Trailling"; input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses input bool x121EADisableTrailingWhenOpposit = true; // Disable Trailling When has Opposite In Drawdown -input double x121EAFirstTrailDistance = 100; // Start Trailling Distance -input double x121EAFirstTrailPoint = 60; // First Stop Trail -input double x121EANextTrailDistance = 50; // Next Trailling Distance -input double x121EANextTrailPoint = 25; // Next Trailling Step +input double x121EAFirstTrailDistance = 100; // Start Trailling Distance +input double x121EAFirstTrailPoint = 60; // First Stop Trail +input double x121EANextTrailDistance = 50; // Next Trailling Distance +input double x121EANextTrailPoint = 25; // Next Trailling Step // input group "Supporting"; @@ -95,8 +97,8 @@ input double x121EAMaxAllowedSupportVolume = 0; // Max Allowed Support Signals V // input group "Grid"; -input bool x121EAAllowGrid = false; // Allow Grid Signals -input bool x121EAGridOnlyForces = false; // Grid Only Force Signals +input bool x121EAAllowGrid = false; // Allow Grid Signals +input bool x121EAGridOnlyForces = false; // Grid Only Force Signals input int x121EAMaxNumberOfGrids = 0; // Max Number of Grid Signals input double x121EAGridDistance = 200; // Grid Distance input double x121EAGridVolumeMultiplier = 2; // Grid Volume Multiplier @@ -329,6 +331,8 @@ bool InitialEA() x121EA.IncreaseNextSignalsVolume(x121EAIncreaseNextSignalsVolume); x121EA.UseMaxAllowedPerDirection(x121EAUseMaxAllowedPerDirection); x121EA.MinFreeMargingForOpenTrades(x121EAMinFreeMargingForOpenTrades); + x121EA.IncreaseNextSignalsVolumeMultiplier(x121EAIncreaseNextSignalsVolumeMultiplier); + x121EA.AcceptNextDirectionalSignalsWhenFirstInProfit(x121EAAcceptNextDirectionalSignalsWhenFirstInProfit); // // Protection ...