From fe54432fa2c650a7ace6a3e691929d0ffbfce276 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 13 Dec 2024 05:47:05 +0330 Subject: [PATCH] last preparation ... --- .../BKP/Indicators}/x-saherelm.x3ma.mq5 | 0 .../BKP/Indicators}/x-saherelm.x3vwap.mq5 | 0 .../BKP/Indicators}/x-saherelm.xchsar.mq5 | 0 .../BKP/Indicators}/x-saherelm.xpv.mq5 | 0 .../BKP/Indicators}/x-saherelm.xtick.osc.mq5 | 0 Experts/x-saherelm.x-121.smc.ea.mq5 | 4 +- Indicators/x-saherelm.x121.mq5 | 12 ++-- Libraries/x-saherelm.common.lib.mq5 | 42 +++++++++++++ .../x-121.smc.test.strategy.class.mq5 | 59 ++++++++++++++++--- 9 files changed, 104 insertions(+), 13 deletions(-) rename {Indicators => Documents/BKP/Indicators}/x-saherelm.x3ma.mq5 (100%) rename {Indicators => Documents/BKP/Indicators}/x-saherelm.x3vwap.mq5 (100%) rename {Indicators => Documents/BKP/Indicators}/x-saherelm.xchsar.mq5 (100%) rename {Indicators => Documents/BKP/Indicators}/x-saherelm.xpv.mq5 (100%) rename {Indicators => Documents/BKP/Indicators}/x-saherelm.xtick.osc.mq5 (100%) diff --git a/Indicators/x-saherelm.x3ma.mq5 b/Documents/BKP/Indicators/x-saherelm.x3ma.mq5 similarity index 100% rename from Indicators/x-saherelm.x3ma.mq5 rename to Documents/BKP/Indicators/x-saherelm.x3ma.mq5 diff --git a/Indicators/x-saherelm.x3vwap.mq5 b/Documents/BKP/Indicators/x-saherelm.x3vwap.mq5 similarity index 100% rename from Indicators/x-saherelm.x3vwap.mq5 rename to Documents/BKP/Indicators/x-saherelm.x3vwap.mq5 diff --git a/Indicators/x-saherelm.xchsar.mq5 b/Documents/BKP/Indicators/x-saherelm.xchsar.mq5 similarity index 100% rename from Indicators/x-saherelm.xchsar.mq5 rename to Documents/BKP/Indicators/x-saherelm.xchsar.mq5 diff --git a/Indicators/x-saherelm.xpv.mq5 b/Documents/BKP/Indicators/x-saherelm.xpv.mq5 similarity index 100% rename from Indicators/x-saherelm.xpv.mq5 rename to Documents/BKP/Indicators/x-saherelm.xpv.mq5 diff --git a/Indicators/x-saherelm.xtick.osc.mq5 b/Documents/BKP/Indicators/x-saherelm.xtick.osc.mq5 similarity index 100% rename from Indicators/x-saherelm.xtick.osc.mq5 rename to Documents/BKP/Indicators/x-saherelm.xtick.osc.mq5 diff --git a/Experts/x-saherelm.x-121.smc.ea.mq5 b/Experts/x-saherelm.x-121.smc.ea.mq5 index 329aa265..bc7b4b72 100644 --- a/Experts/x-saherelm.x-121.smc.ea.mq5 +++ b/Experts/x-saherelm.x-121.smc.ea.mq5 @@ -49,8 +49,8 @@ input bool eaUseDynamicVolume = false; // Use Dynamic Volume input double eaDynamicVolumeStep = 0.01; // Increase Volume Step input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume input double eaVolume = 0.05; // Static Volume -input bool eaDynamicRiskManagement = true; // Dynamic Risk Management -input double eaRiskPercentPerBalance = 0.5; // Risk Percent Per Balance on Each Trade +input bool eaDynamicRiskManagement = false; // Dynamic Risk Management +input double eaRiskPercentPerBalance = 0; // Risk Percent Per Balance on Each Trade // // Signalling ... diff --git a/Indicators/x-saherelm.x121.mq5 b/Indicators/x-saherelm.x121.mq5 index ef5e1e75..0cae13df 100644 --- a/Indicators/x-saherelm.x121.mq5 +++ b/Indicators/x-saherelm.x121.mq5 @@ -1192,10 +1192,14 @@ void CalculateBuffers( ); // - CalculateValidPeaksAndVales( - bar_index, - prevCalculated // - ); + // if (bar_index <= barsLimit + 576) + // { + // // + // CalculateValidPeaksAndVales( + // bar_index, + // prevCalculated // + // ); + // } // CalculateFibonacci( diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 654860e6..3d02a126 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -7722,6 +7722,27 @@ double GetEntry( // return result; } +double GetEntry( + string mSymbol = NULL, // Trading Symbol + ENUM_X_DIRECTION type = X_DIRECTION_BULLISH // Get entry price for Which direction trade ... +) +{ + // + double result = 0; + + // + mSymbol = NormalizeSymbol(mSymbol); + + // + result = + IsBullish(type) + ? GetAsk(mSymbol) + : GetBid(mSymbol); + result = NormalizePrice(result, mSymbol); + + // + return result; +} // // Retrieve Exit Price ... @@ -7746,6 +7767,27 @@ double GetExit( // return result; } +double GetExit( + string mSymbol = NULL, // Trading Symbol + ENUM_X_DIRECTION type = X_DIRECTION_BULLISH // Get entry price for Which direction trade ... +) +{ + // + double result = 0; + + // + mSymbol = NormalizeSymbol(mSymbol); + + // + result = + IsBullish(type) + ? GetBid(mSymbol) + : GetAsk(mSymbol); + result = NormalizePrice(result, mSymbol); + + // + return result; +} // // Get 1 Pip in Price Value ... diff --git a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 index 9dfd1808..de9c5de0 100644 --- a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 @@ -242,12 +242,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // result = PrepareSignal(signal); - if (result) - { - // - // Print("PRV: ", provider); - // DrawSignal(signal); - } + // if (result) + // { + // // + // // Print("PRV: ", provider); + // // DrawSignal(signal); + // } // hasLong = false; @@ -678,11 +678,56 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Selectiong SL ... - selectedSL = SelectSL( + double selectedSLRJ = SelectSL( + conditions, + conditions.signalDir, + X_121_SMC_SL_TYPE_REJECTION // + ); + double selectedSLMN = SelectSL( + conditions, + conditions.signalDir, + X_121_SMC_SL_TYPE_MOMENTUM // + ); + double selectedSLSW = SelectSL( conditions, conditions.signalDir, X_121_SMC_SL_TYPE_SWING // ); + double selectedSLSR = SelectSL( + conditions, + conditions.signalDir, + X_121_SMC_SL_TYPE_CURRENT_SAR // + ); + + // + double slCandidates[4] = { + selectedSLRJ, + selectedSLMN, + selectedSLSW, + selectedSLSR // + }; + selectedSL = isBullish + ? GetMin(slCandidates) + : GetMax(slCandidates); + + // + // Normalizing SL ... + double entry = GetEntry( + symbol, + conditions.signalDir // + ); + double spread = GetSpread(symbol); + double pip = GetPipPrice(symbol); + + // + if (isBullish && selectedSL <= entry) + { + selectedSL -= (pip * 3) - spread; + } + else if (isBearish && selectedSL >= entry) + { + selectedSL += pip * 3 + spread; + } // // Detect SL and TP ...