From f846523f70c80132ebd1c7a0d54e9657477b4831 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 5 Jul 2024 03:12:46 +0330 Subject: [PATCH] last ... --- Experts/x-saherelm.x121.ea.mq5 | 12 +- Helpers/x-saherelm.xchma.helper.mq5 | 377 ++++++++++++++++++++++++++++ 2 files changed, 383 insertions(+), 6 deletions(-) diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index 492e95ee..aa25f1a4 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -53,7 +53,7 @@ input int x121EAStartSignallingHoure = 3; // Start Signalling input int x121EAEndSignallingHoure = 22; // End Signalling at Specific Time input int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals -input int x121EAReuiredSignalVerifications = 1; // Required Verifications for Signals +input int x121EAReuiredSignalVerifications = 3; // Required Verifications for Signals input bool x121EAExecuteSignalsOnBreakout = false; // Execute Signals On Breakouts input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames @@ -75,12 +75,12 @@ input bool x121EAAcceptNextDirectionalSignalsWhenFirstInProfit = true; // Accept // input group "Trailling"; -input bool x121EAAllowTrailStop = false; // Enable Trailling Stop Losses +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 x121EANextTrailPoint = 30; // Next Trailling Step // // input group "Supporting"; @@ -112,7 +112,7 @@ input double x121EAMaxAllowedRecoveryVolume = 0; // Max Allowed Recovery Signals // input group "Hedging"; input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge -input double x121EAMinRequiredProfitPerTrade = 2.5; // Minimum Required Profit for Hedging +input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume // @@ -512,8 +512,8 @@ void X121PreConfigureStyles(X121SetupInputs &inputs) // // XCHMA ... - inputs.chmaInputs.showFast = true; - inputs.chmaInputs.showSlow = true; + inputs.chmaInputs.showFast = false; + inputs.chmaInputs.showSlow = false; inputs.chmaInputs.showCCFast = false; inputs.chmaInputs.showCCSlow = false; inputs.chmaInputs.showSCFast = false; diff --git a/Helpers/x-saherelm.xchma.helper.mq5 b/Helpers/x-saherelm.xchma.helper.mq5 index 30fc2f18..0222cb29 100644 --- a/Helpers/x-saherelm.xchma.helper.mq5 +++ b/Helpers/x-saherelm.xchma.helper.mq5 @@ -307,6 +307,30 @@ struct XCHMAConditions // bool isRetestFastSlow; + // + bool isFastSupport; + bool isSlowSupport; + + // + bool isFastResistance; + bool isSlowResistance; + + // + bool isRejectedFastAsResistance; + bool isRejectedSlowAsResistance; + + // + bool isRejectedFastAsSupport; + bool isRejectedSlowAsSupport; + + // + bool isBreakedFastAsResistance; + bool isBreakedSlowAsResistance; + + // + bool isBreakedFastAsSupport; + bool isBreakedSlowAsSupport; + // bool isFastOverMax; bool isFastUnderMax; @@ -695,6 +719,18 @@ struct XCHMAConditions isCloseUnderSlow = false; isCloseCrossedUnderSlow = false; isRetestFastSlow = false; + isFastSupport = false; + isSlowSupport = false; + isFastResistance = false; + isSlowResistance = false; + isRejectedFastAsResistance = false; + isRejectedSlowAsResistance = false; + isRejectedFastAsSupport = false; + isRejectedSlowAsSupport = false; + isBreakedFastAsResistance = false; + isBreakedSlowAsResistance = false; + isBreakedFastAsSupport = false; + isBreakedSlowAsSupport = false; isFastOverMax = false; isFastUnderMax = false; isFastOverMin = false; @@ -930,6 +966,42 @@ struct XCHMAConditions if (isRetestFastSlow) { } + if (isFastSupport) + { + } + if (isSlowSupport) + { + } + if (isFastResistance) + { + } + if (isSlowResistance) + { + } + if (isRejectedFastAsResistance) + { + } + if (isRejectedSlowAsResistance) + { + } + if (isRejectedFastAsSupport) + { + } + if (isRejectedSlowAsSupport) + { + } + if (isBreakedFastAsResistance) + { + } + if (isBreakedSlowAsResistance) + { + } + if (isBreakedFastAsSupport) + { + } + if (isBreakedSlowAsSupport) + { + } if (isFastOverMax) { } @@ -1485,6 +1557,18 @@ struct XCHMAConditions ToString("isCloseUnderSlow", isCloseUnderSlow, ignoreFalseConditions, separator) + ToString("isCloseCrossedUnderSlow", isCloseCrossedUnderSlow, ignoreFalseConditions, separator) + ToString("isRetestFastSlow", isRetestFastSlow, ignoreFalseConditions, separator) + + ToString("isFastSupport", isFastSupport, ignoreFalseConditions, separator) + + ToString("isSlowSupport", isSlowSupport, ignoreFalseConditions, separator) + + ToString("isFastResistance", isFastResistance, ignoreFalseConditions, separator) + + ToString("isSlowResistance", isSlowResistance, ignoreFalseConditions, separator) + + ToString("isRejectedFastAsResistance", isRejectedFastAsResistance, ignoreFalseConditions, separator) + + ToString("isRejectedSlowAsResistance", isRejectedSlowAsResistance, ignoreFalseConditions, separator) + + ToString("isRejectedFastAsSupport", isRejectedFastAsSupport, ignoreFalseConditions, separator) + + ToString("isRejectedSlowAsSupport", isRejectedSlowAsSupport, ignoreFalseConditions, separator) + + ToString("isBreakedFastAsResistance", isBreakedFastAsResistance, ignoreFalseConditions, separator) + + ToString("isBreakedSlowAsResistance", isBreakedSlowAsResistance, ignoreFalseConditions, separator) + + ToString("isBreakedFastAsSupport", isBreakedFastAsSupport, ignoreFalseConditions, separator) + + ToString("isBreakedSlowAsSupport", isBreakedSlowAsSupport, ignoreFalseConditions, separator) + ToString("isFastOverMax", isFastOverMax, ignoreFalseConditions, separator) + ToString("isFastUnderMax", isFastUnderMax, ignoreFalseConditions, separator) + ToString("isFastOverMin", isFastOverMin, ignoreFalseConditions, separator) + @@ -3066,6 +3150,26 @@ public: MODE_LOW // ); + // + XOHCL ppBar; + result = ppBar.Init( + mSymbol, + mPeriod, + ppIndex // + ); + if (!result) + { + return result; + } + double phhValue = ppBar.FindHighest( + loopback * 2, + MODE_HIGH // + ); + double pllValue = ppBar.FindLowest( + loopback * 2, + MODE_LOW // + ); + // double allValues[]; double maxValue = 0; @@ -3172,6 +3276,267 @@ public: // ); + // + // Calculate Support and Resistance Behaviour for Fast and Slow ... + + // + // Supports Happens when Lowest Low of atleast n Number of Bars + // are above line ... + bool isFastSupport = pllValue > conditions.fast[ppIndex]; + bool isSlowSupport = pllValue > conditions.slow[ppIndex]; + + // + // Resistance Happens when Highest High of atleast n NUmber of Bars + // are below line ... + bool isFastResistance = phhValue < conditions.fast[ppIndex]; + bool isSlowResistance = phhValue < conditions.slow[ppIndex]; + + // + // Rejection occure by Shaddows ... + // this mean Previous Bar Shadows breaked Line but Close doesnt make sense ... + // price rejected ... + + // + bool isRejectedFastAsSupport = + // + !isFastSupport + ? false + : ( + // + // Check Bar State ... + (ppBar.low > conditions.fast[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.high > conditions.fast[pIndex] && + // + // Touch ... + pBar.low < conditions.fast[pIndex]) + // + && + // + // Check Close Bar for Rejection ... + (cBar.close > conditions.fast[cIndex] && + cBar.IsBullish()) + // + ) + // + ; + + // + bool isRejectedSlowAsSupport = + // + !isSlowSupport + ? false + : ( + // + // Check Bar State ... + (ppBar.low > conditions.slow[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.high > conditions.slow[pIndex] && + // + // Touch ... + pBar.low < conditions.slow[pIndex]) + // + && + // + // Check Close Bar for Rejection ... + (cBar.close > conditions.slow[cIndex] && + cBar.IsBullish()) + // + ) + // + ; + + // + bool isRejectedFastAsResistance = + // + !isFastResistance + ? false + : ( + // + // Check Bar State ... + (ppBar.high < conditions.fast[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.low < conditions.fast[pIndex] && + // + // Touch ... + pBar.high > conditions.fast[pIndex]) + // + && + // + // Check Close Bar for Rejection ... + (cBar.close < conditions.fast[cIndex] && + cBar.IsBearish()) + // + ) + // + ; + + // + bool isRejectedSlowAsResistance = + // + !isSlowResistance + ? false + : ( + // + // Check Bar State ... + (ppBar.high < conditions.slow[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.low < conditions.slow[pIndex] && + // + // Touch ... + pBar.high > conditions.slow[pIndex]) + // + && + // + // Check Close Bar for Rejection ... + (cBar.close < conditions.slow[cIndex] && + cBar.IsBearish()) + // + ) + // + ; + + // + // Breakes occures by Price Close ... + // this means Previous Bar Close in One Side of line and next Close on another Side ... + // also Fibo 0.5 of Candle Body appears on opposit side ... + + // + bool isBreakedFastAsSupport = + // + !isFastSupport + ? false + : ( + // + // Check Bar State ... + (ppBar.low > conditions.fast[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.high > conditions.fast[pIndex] && + // + // Touch ... + pBar.low < conditions.fast[pIndex] && + // + // Calculate 50% ... + (conditions.fast[pIndex] - pBar.GetDown() > (pBar.GetBody() / 100) * 50)) + // + && + // + // Check Close Bar for Breakout ... + (cBar.close < conditions.fast[cIndex] && + cBar.IsBearish()) + // + ) + // + ; + + // + bool isBreakedSlowAsSupport = + // + !isSlowSupport + ? false + : ( + // + // Check Bar State ... + (ppBar.low > conditions.slow[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.high > conditions.slow[pIndex] && + // + // Touch ... + pBar.low < conditions.slow[pIndex] && + // + // Calculate 50% ... + (conditions.slow[pIndex] - pBar.GetDown() > (pBar.GetBody() / 100) * 50)) + // + && + // + // Check Close Bar for Breakout ... + (cBar.close < conditions.slow[cIndex] && + cBar.IsBearish()) + // + ) + // + ; + + // + bool isBreakedFastAsResistance = + // + !isFastResistance + ? false + : ( + // + // Check Bar State ... + (ppBar.high < conditions.fast[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.low < conditions.fast[pIndex] && + // + // Touch ... + pBar.high > conditions.fast[pIndex] && + // + // Calculate 50% ... + (pBar.GetUp() - conditions.fast[pIndex] > (pBar.GetBody() / 100) * 50)) + // + && + // + // Check Close Bar for Breakout ... + (cBar.close > conditions.fast[cIndex] && + cBar.IsBullish()) + // + ) + // + ; + + // + bool isBreakedSlowAsResistance = + // + !isSlowResistance + ? false + : ( + // + // Check Bar State ... + (ppBar.high < conditions.slow[ppIndex]) + // + && + // + // Check Shadow Break ... + (pBar.low < conditions.slow[pIndex] && + // + // Touch ... + pBar.high > conditions.slow[pIndex] && + // + // Calculate 50% ... + (pBar.GetUp() - conditions.slow[pIndex] > (pBar.GetBody() / 100) * 50)) + // + && + // + // Check Close Bar for Breakout ... + (cBar.close > conditions.slow[cIndex] && + cBar.IsBullish()) + // + ) + // + ; + // // Current ... @@ -3685,6 +4050,18 @@ public: conditions.isCloseUnderSlow = isCloseUnderSlow; conditions.isCloseCrossedUnderSlow = isCloseCrossedUnderSlow; conditions.isRetestFastSlow = isRetestFastSlow; + conditions.isFastSupport = isFastSupport; + conditions.isSlowSupport = isSlowSupport; + conditions.isFastResistance = isFastResistance; + conditions.isSlowResistance = isSlowResistance; + conditions.isRejectedFastAsResistance = isRejectedFastAsResistance; + conditions.isRejectedSlowAsResistance = isRejectedSlowAsResistance; + conditions.isRejectedFastAsSupport = isRejectedFastAsSupport; + conditions.isRejectedSlowAsSupport = isRejectedSlowAsSupport; + conditions.isBreakedFastAsResistance = isBreakedFastAsResistance; + conditions.isBreakedSlowAsResistance = isBreakedSlowAsResistance; + conditions.isBreakedFastAsSupport = isBreakedFastAsSupport; + conditions.isBreakedSlowAsSupport = isBreakedSlowAsSupport; conditions.isFastOverMax = isFastOverMax; conditions.isFastUnderMax = isFastUnderMax; conditions.isFastOverMin = isFastOverMin;