From 37b9578ba1bce45996a940c232b6109550a00228 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 27 Jul 2024 15:59:01 +0330 Subject: [PATCH] last ... --- .../Strategies/x-saherelm.xchkm.strategy.mq5 | 2234 +++++++++++++++++ Documents/BKP/usefull.mq5 | 1045 ++++++++ Experts/x-test-strategies.ea.mq5 | 43 +- Helpers/x-saherelm.xchhk.helper.mq5 | 8 +- Libraries/x-saherelm.common.lib.mq5 | 132 +- Strategies/x-saherelm.xchkm.strategy.mq5 | 1155 +-------- 6 files changed, 3525 insertions(+), 1092 deletions(-) create mode 100644 Documents/BKP/Old/Strategies/x-saherelm.xchkm.strategy.mq5 diff --git a/Documents/BKP/Old/Strategies/x-saherelm.xchkm.strategy.mq5 b/Documents/BKP/Old/Strategies/x-saherelm.xchkm.strategy.mq5 new file mode 100644 index 00000000..cd292c9e --- /dev/null +++ b/Documents/BKP/Old/Strategies/x-saherelm.xchkm.strategy.mq5 @@ -0,0 +1,2234 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// -------------------------------------- +// Name: XSCXCHKMStrategy +// Description: provides all based classes for use ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... + +// +// Import(s) Helper(s) ... +#include "../Helpers/x-saherelm.xpv.helper.mq5" +#include "../Helpers/x-saherelm.xche.helper.mq5" +#include "../Helpers/x-saherelm.xchm.helper.mq5" +#include "../Helpers/x-saherelm.xchhk.helper.mq5" +#include "../Helpers/x-saherelm.xchstr.helper.mq5" + +// +// Base Classes ... +#include "../Classes/x-saherelm.xstrategy.class.mq5" + +// +// Specific Identifier(s) of XStrategy ... +string XCHKMStartegyToken = "XCHKM"; + +// +// XStrategy Class Implementation(s) ... +class XSCXCHKMStrategy : public XSCBaseStrategy +{ + // + // Public ... +public: + // + // Constructor(s) ... + void XSCXCHKMStrategy( + // + // Base ... + string _symbol, // Trading Symbol + ENUM_TIMEFRAMES _period, // Trading TimeFrame + ENUM_TIMEFRAMES _analizePeriod, // Important Area Detect Time Frame + double _volume, // Voluem + double _r2r, // Risk/Reward Ratio + int _slippage, // Trader Slippage + long _magicNumber, // Trader Magic Number + bool _ignoreSignalExecution = false, // Ignore Signal Execution + bool _useTPSLAsPoint = false, // Converts TP and SL by Provided Points + bool _forceMaxTPSLAsPoint = false, // Force Max TP and SL by Provided Points + double _tpPoint = 0, // TP As Point + double _slPoint = 0, // SL As Point + bool _ignoreTP = false, // TP set to 0 + bool _ignoreSL = false, // SL set to 0 + bool _allowLong = true, + bool _allowShort = true, + int _maxAllowedLongs = 0, + int _maxAllowedShorts = 0 // + ) : XSCBaseStrategy(_symbol, + _period, + _volume, + _r2r, + _slippage, + _magicNumber, + _ignoreSignalExecution, + _useTPSLAsPoint, + _forceMaxTPSLAsPoint, + _tpPoint, + _slPoint, + _ignoreTP, + _ignoreSL, + _allowLong, + _allowShort, + _maxAllowedLongs, + _maxAllowedShorts // + ) + { + // + mAnalizePeriod = _analizePeriod; + + // + SetAlertPrefix(GetTag()); + + // + PrepareRequirements(); + } + + // + // Deconstructor ... + void ~XSCXCHKMStrategy() + { + // + delete pvHelper; + delete cheHelper; + + // + delete chmHelper; + delete chhkHelper; + delete chstrHelper; + } + + // + // Getter / Setter (s) ... + + // + // Overrides ... + + // + // Customize Strategy Identifier ... + string GetTag() override + { + return XCHKMStartegyToken; + } + + // + // Check Conditions For Signal ... + bool HasSignal( + XSignal &signal // + ) override + { + // + bool result = false; + + // + signal.Clean(); + + // + double sl = 0; + double tp = 0; + double risk = 0; + double entry = 0; + double reward = 0; + double r2r = R2R(); + ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; + + // + bool hasLong = false; + bool hasShort = false; + + // + // Draw Support/Resistance/OB(s)/FVG(s) ... + bool drawImportantAreas = false; + + // + // Retrieve Conditions ... + + // + // XPV ... + XPVConditions pvConditions; + result = pvHelper.GetConditions(pvConditions); + if (!result) + { + return result; + } + + // + // XCHE ... + XCHEConditions cheConditions; + result = cheHelper.GetConditions(cheConditions); + if (!result) + { + return result; + } + + // + // XCHM ... + XCHMConditions chmConditions; + result = chmHelper.GetConditions(chmConditions); + if (!result) + { + return result; + } + + // + // XCHHK ... + XCHHKConditions chhkConditions; + result = chhkHelper.GetConditions(chhkConditions); + if (!result) + { + return result; + } + + // + // XCHSTR ... + XCHSTRConditions chstrConditions; + result = chstrHelper.GetConditions(chstrConditions); + if (!result) + { + return result; + } + + // + // Start Calculations ... + + // + double points = GetPoints(mSymbol); + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + // Retrieve Bars ... + + // + // Last Bar ... + XOHCL cBar; + result = cBar.Init( + mSymbol, + mPeriod, + cIndex // + ); + if (!result) + { + return result; + } + + // + // Analyzing Bar ... + XOHCL aBar; + if (IsValid(mAnalizePeriod)) + { + // + result = aBar.Init( + mSymbol, + mAnalizePeriod, + cIndex // + ); + + // + if (!result) + { + return result; + } + } + else + { + aBar = cBar; + } + + // + // Previous Bar of Last Bar ... + XOHCL pBar; + result = cBar.GetPreviousBar(pBar); + if (!result) + { + return result; + } + + // + // Last Swing Low Bar ... + XOHCL lastSwingLow; + result = cBar.FindLastSwingLow(lastSwingLow); + if (!result) + { + return result; + } + + // + // Last Swing High Bar ... + XOHCL lastSwingHigh; + result = cBar.FindLastSwingHigh(lastSwingHigh); + if (!result) + { + return result; + } + + // + // Retrieve Highest High(s) and Lowest Low(s) ... + + // + // Highest High ... + double hh5 = cBar.FindHighest( + 5, + MODE_HIGH // + ); + + // + // Lowest Low ... + double ll5 = cBar.FindLowest( + 5, + MODE_LOW // + ); + + // + // Support nad Resistance ... + + // + // Check Support Exists or Find ... + bool hasSupport = support.IsValid(); + if (!hasSupport) + { + // + hasSupport = + // + aBar.HasSupport(support) + // + ; + + // + if (hasSupport) + { + // + if (drawImportantAreas) + { + // + DrawSupport( + support, + ChartID() // + ); + } + + // + supportTime = aBar.time; + } + } + + // + // Check Resistance Exists or Find ... + bool hasResistance = resistance.IsValid(); + if (!hasResistance) + { + // + hasResistance = + // + aBar.HasResistance(resistance) + // + ; + + // + if (hasResistance) + { + // + if (drawImportantAreas) + { + // + DrawResistance( + resistance, + ChartID() // + ); + } + + // + resistanceTime = aBar.time; + } + } + + // + // Order Blocks ... + + // + bool hasBullishOB = bullishOB.IsValid(); + if (!hasBullishOB) + { + // + hasBullishOB = + // + aBar.HasBullishOrderBlock(bullishOB) + // + ; + + // + if (hasBullishOB) + { + // + if (drawImportantAreas) + { + // + DrawBullishOrderBlock( + bullishOB, + ChartID() // + ); + } + + // + bullishOBTime = aBar.time; + } + } + + // + bool hasBearishOB = bearishOB.IsValid(); + if (!hasBearishOB) + { + // + hasBearishOB = + // + aBar.HasBearishOrderBlock(bearishOB) + // + ; + + // + if (hasBearishOB) + { + // + if (drawImportantAreas) + { + // + DrawBearishOrderBlock( + bearishOB, + ChartID() // + ); + } + + // + bearishOBTime = aBar.time; + } + } + + // + // FVG ... + + // + bool hasBullishFVG = bullishFVG.IsValid(); + if (!hasBullishFVG) + { + // + hasBullishFVG = + // + aBar.HasBullishFVG( + bullishFVGUpper, + bullishFVGLower // + ) + // + ; + + // + if (hasBullishFVG) + { + // + bullishFVG = aBar; + + // + if (drawImportantAreas) + { + // + DrawBullishFVG( + bullishFVG, + bullishFVGUpper, + bullishFVGLower, + ChartID() // + ); + } + + // + bullishFVGTime = aBar.time; + } + } + + // + bool hasBearishFVG = bearishFVG.IsValid(); + if (!hasBearishFVG) + { + // + hasBearishFVG = + // + aBar.HasBearishFVG( + bearishFVGUpper, + bearishFVGLower // + ) + // + ; + + // + if (hasBearishFVG) + { + // + bearishFVG = aBar; + + // + if (drawImportantAreas) + { + // + DrawBearishFVG( + bearishFVG, + bearishFVGUpper, + bearishFVGLower, + ChartID() // + ); + } + + // + bearishFVGTime = aBar.time; + } + } + + // + // For Trend ... + XOHCL tmpHSW[]; + XOHCL tmpLSW[]; + + // + // Detect Bullish/Bearish Patterns and Trends ... + + // + // Bullish ... + bool hasBullishPower = cBar.HasBullishPower(); + bool hasBullishPattern = HasBullishPattern(cBar); + bool hasBullishPressure = cBar.HasBullishPressure(); + bool isBullishTrend = cBar.HasBullishTrend( + tmpHSW, + tmpLSW, + true // + ); + + // + // Bearish ... + bool hasBearishPower = cBar.HasBearishPower(); + bool hasBearishPattern = HasBearishPattern(cBar); + bool hasBearishPressure = cBar.HasBearishPressure(); + bool isBearishTrend = cBar.HasBearishTrend( + tmpHSW, + tmpLSW, + false // + ); + + // + // XCHE ... + + // + if (cheConditions.long1[pIndex] > 0 && + cheConditions.long2[pIndex] > 0 && + cheConditions.long1[pIndex] != EMPTY_VALUE && + cheConditions.long2[pIndex] != EMPTY_VALUE && + !cheConditions.isStrongBullish) + { + // + cheLastLongExitTime = pBar.time; + cheLastLongExit1 = cheConditions.long1[pIndex]; + cheLastLongExit2 = cheConditions.long2[pIndex]; + } + + // + if (cheConditions.short1[pIndex] > 0 && + cheConditions.short2[pIndex] > 0 && + cheConditions.short1[pIndex] != EMPTY_VALUE && + cheConditions.short2[pIndex] != EMPTY_VALUE && + !cheConditions.isStrongBearish) + { + // + cheLastShortExitTime = pBar.time; + cheLastShortExit1 = cheConditions.short1[pIndex]; + cheLastShortExit2 = cheConditions.short2[pIndex]; + } + + // + // XCHM ... + // Detect XCHMbased Conditions ... + + // + // Bullish ... + + // + bool isCHMHSwithedToBullish = + // + ( + // + chmConditions.isHFastCrossedOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMLSwithedToBullish = + // + ( + // + chmConditions.isLFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMMSwithedToBullish = + // + ( + // + chmConditions.isMFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMSSwithedToBullish = + // + ( + // + chmConditions.isSFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMCSwithedToBullish = + // + ( + // + chmConditions.isCFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHMBullish = + // + ( + // + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMSwitchedToBullish = + // + isCHMHSwithedToBullish + // + || + // + isCHMLSwithedToBullish + // + || + // + isCHMMSwithedToBullish + // + || + // + isCHMSSwithedToBullish + // + || + // + isCHMCSwithedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHMCHSwitchedToBearish = + // + ( + // + chmConditions.isHFastCrossedUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCLSwitchedToBearish = + // + ( + // + chmConditions.isLFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCMSwitchedToBearish = + // + ( + // + chmConditions.isMFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCSSwitchedToBearish = + // + ( + // + chmConditions.isSFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCCSwitchedToBearish = + // + ( + // + chmConditions.isCFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHMBearish = + // + ( + // + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMSwitchedToBearish = + // + isCHMCHSwitchedToBearish + // + || + // + isCHMCLSwitchedToBearish + // + || + // + isCHMCMSwitchedToBearish + // + || + // + isCHMCSSwitchedToBearish + // + || + // + isCHMCCSwitchedToBearish + // + ; + + // + // Max ... + double chmMax = MathMax( + chmConditions.cFast[cIndex], + chmConditions.cSlow[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.sFast[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.sSlow[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.mFast[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.mSlow[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.lFast[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.lSlow[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.hFast[cIndex] // + ); + chmMax = MathMax( + chmMax, + chmConditions.hSlow[cIndex] // + ); + + // + // Min ... + double chmMin = MathMin( + chmConditions.cFast[cIndex], + chmConditions.cSlow[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.sFast[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.sSlow[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.mFast[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.mSlow[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.lFast[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.lSlow[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.hFast[cIndex] // + ); + chmMin = MathMin( + chmMin, + chmConditions.hSlow[cIndex] // + ); + + // + double chmDistanceDiffInPoint = + // + (chmMax - chmMin) / points + // + ; + + // + // XCHHK ... + // Detect XCHHK Conditions ... + + // + // Bullish ... + + // + bool isCHHKCSwitchedToBullish = + // + ( + // + chhkConditions.isCSwitchedToBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKSSwitchedToBullish = + // + ( + // + chhkConditions.isSSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKMSwitchedToBullish = + // + ( + // + chhkConditions.isMSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKLSwitchedToBullish = + // + ( + // + chhkConditions.isLSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKHSwitchedToBullish = + // + ( + // + chhkConditions.isHSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHHKBullish = + // + ( + // + chhkConditions.isHBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish + // + ) + // + ; + + // + bool isCHHKSwitchedBullish = + // + isCHHKCSwitchedToBullish + // + || + // + isCHHKSSwitchedToBullish + // + || + // + isCHHKMSwitchedToBullish + // + || + // + isCHHKLSwitchedToBullish + // + || + // + isCHHKHSwitchedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHHKCSwitchedToBearish = + // + ( + // + chhkConditions.isCSwitchedToBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKSSwitchedToBearish = + // + ( + // + chhkConditions.isSSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKMSwitchedToBearish = + // + ( + // + chhkConditions.isMSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKLSwitchedToBearish = + // + ( + // + chhkConditions.isLSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKHSwitchedToBearish = + // + ( + // + chhkConditions.isHSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHHKBearish = + // + ( + // + chhkConditions.isHBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish + // + ) + // + ; + + // + bool isCHHKSwitchedToBearish = + // + isCHHKCSwitchedToBearish + // + || + // + isCHHKSSwitchedToBearish + // + || + // + isCHHKMSwitchedToBearish + // + || + // + isCHHKLSwitchedToBearish + // + || + // + isCHHKHSwitchedToBearish + // + ; + + // + // Max High ... + double chhkHighMax = MathMax( + chhkConditions.cBars[cIndex].high, + chhkConditions.sBars[cIndex].high // + ); + chhkHighMax = MathMax( + chhkHighMax, + chhkConditions.mBars[cIndex].high // + ); + chhkHighMax = MathMax( + chhkHighMax, + chhkConditions.lBars[cIndex].high // + ); + chhkHighMax = MathMax( + chhkHighMax, + chhkConditions.hBars[cIndex].high // + ); + + // + // Min High ... + double chhkHighMin = MathMin( + chhkConditions.cBars[cIndex].high, + chhkConditions.sBars[cIndex].high // + ); + chhkHighMin = MathMin( + chhkHighMin, + chhkConditions.mBars[cIndex].high // + ); + chhkHighMin = MathMin( + chhkHighMin, + chhkConditions.lBars[cIndex].high // + ); + chhkHighMin = MathMin( + chhkHighMin, + chhkConditions.hBars[cIndex].high // + ); + + // + // Max Low ... + double chhkLowMax = MathMax( + chhkConditions.cBars[cIndex].low, + chhkConditions.sBars[cIndex].low // + ); + chhkLowMax = MathMax( + chhkLowMax, + chhkConditions.mBars[cIndex].low // + ); + chhkLowMax = MathMax( + chhkLowMax, + chhkConditions.lBars[cIndex].low // + ); + chhkLowMax = MathMax( + chhkLowMax, + chhkConditions.hBars[cIndex].low // + ); + + // + // Min Low ... + double chhkLowMin = MathMin( + chhkConditions.cBars[cIndex].low, + chhkConditions.sBars[cIndex].low // + ); + chhkLowMin = MathMin( + chhkLowMin, + chhkConditions.mBars[cIndex].low // + ); + chhkLowMin = MathMin( + chhkLowMin, + chhkConditions.lBars[cIndex].low // + ); + chhkLowMin = MathMin( + chhkLowMin, + chhkConditions.hBars[cIndex].low // + ); + + // + double chhkDistanceDiffInPoint = + // + (chhkHighMax - chhkLowMin) / points + // + ; + + // + // XCHSTR ... + // Detect XCHSTR Conditions ... + + // + // Bullish ... + + // + bool isCHSTRHSwitchedToBullish = + // + ( + // + chstrConditions.isHSwitchedToBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRLSwitchedToBullish = + // + ( + // + chstrConditions.isLSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRMSwitchedToBullish = + // + ( + // + chstrConditions.isMSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRSSwitchedToBullish = + // + ( + // + chstrConditions.isSSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRCSwitchedToBullish = + // + ( + // + chstrConditions.isCSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHSTRBullish = + // + ( + // + chstrConditions.isCBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish + // + ) + // + ; + + // + bool isCHMSTRBullish = + // + isCHSTRHSwitchedToBullish + // + || + // + isCHSTRLSwitchedToBullish + // + || + // + isCHSTRMSwitchedToBullish + // + || + // + isCHSTRSSwitchedToBullish + // + || + // + isCHSTRCSwitchedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHSTRHSwitchedToBearish = + // + ( + // + chstrConditions.isHSwitchedToBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRLSwitchedToBearish = + // + ( + // + chstrConditions.isLSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRMSwitchedToBearish = + // + ( + // + chstrConditions.isMSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRSSwitchedToBearish = + // + ( + // + chstrConditions.isSSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRCSwitchedToBearish = + // + ( + // + chstrConditions.isCSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHSTRBearish = + // + ( + // + chstrConditions.isCBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish + // + ) + // + ; + + // + bool isCHSTRSwitchedToBearish = + // + isCHSTRHSwitchedToBearish + // + || + // + isCHSTRLSwitchedToBearish + // + || + // + isCHSTRMSwitchedToBearish + // + || + // + isCHSTRSSwitchedToBearish + // + || + // + isCHSTRCSwitchedToBearish + // + ; + + // + // Max ... + double chstrMax = MathMax( + chstrConditions.cTrend[cIndex], + chstrConditions.sTrend[cIndex] // + ); + chstrMax = MathMax( + chstrMax, + chstrConditions.mTrend[cIndex] // + ); + chstrMax = MathMax( + chstrMax, + chstrConditions.lTrend[cIndex] // + ); + chstrMax = MathMax( + chstrMax, + chstrConditions.hTrend[cIndex] // + ); + + // + // Min ... + double chstrMin = MathMin( + chstrConditions.cTrend[cIndex], + chstrConditions.sTrend[cIndex] // + ); + chstrMin = MathMin( + chstrMin, + chstrConditions.mTrend[cIndex] // + ); + chstrMin = MathMin( + chstrMin, + chstrConditions.lTrend[cIndex] // + ); + chstrMin = MathMin( + chstrMin, + chstrConditions.hTrend[cIndex] // + ); + + // + double chstrDistanceDiffInPoint = + // + (chstrMax - chstrMin) / points + // + ; + + // + // Other Conditions ... + + // + bool isPriceOveralBullish = + // + cBar.low > chhkConditions.hBars[cIndex].high + // + ; + + // + bool isPriceOveralBullishPrev = + // + pBar.low > chhkConditions.hBars[pIndex].high + // + ; + + // + bool isPriceOveralSwitchedToBullish = + // + isPriceOveralBullish && + !isPriceOveralBullishPrev + // + ; + + // + bool isPriceOveralBearish = + // + cBar.high < chhkConditions.hBars[cIndex].low + // + ; + + // + bool isPriceOveralBearishPrev = + // + pBar.high < chhkConditions.hBars[pIndex].low + // + ; + + // + bool isPriceOveralSwitchedToBearish = + // + isPriceOveralBearish && + !isPriceOveralBearishPrev + // + ; + + // + // Signalling ... + // Looking for Signals Based on Conditions ... + + // + // Checking Long Conditions ... + if (isPriceOveralSwitchedToBullish) + { + // + hasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPressure && + chhkConditions.isHBullish && + chstrConditions.isHBullish && + cheConditions.isStrongBullish && + cBar.low > pvConditions.fib2s[cIndex] + // + ; + + // + if (hasLong) + { + // + type = POSITION_TYPE_BUY; + sl = pvConditions.fib2s[cIndex]; + } + } + + // + // Checking Short Conditions ... + if (isPriceOveralSwitchedToBearish) + { + // + hasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPressure && + chhkConditions.isHBearish && + chstrConditions.isHBearish && + cheConditions.isStrongBearish && + cBar.high < pvConditions.fib4s[cIndex] + // + ; + + // + if (hasShort) + { + // + type = POSITION_TYPE_SELL; + sl = pvConditions.fib4s[cIndex]; + } + } + + // + result = hasLong || hasShort; + if (!result) + { + // + CheckSupportValidation(); + CheckResistanceValidation(); + + // + CheckBullishOBValidation(); + CheckBearishOBValidation(); + + // + CheckBullishFVGValidation(); + CheckBearishFVgValidation(); + + // + return result; + } + + // + if (hasSupport) + { + // + supportTime = NULL; + isSupportTested = false; + RemoveSupport(support); + support.Clean(); + } + + // + if (hasResistance) + { + // + resistanceTime = NULL; + isResistanceTested = false; + RemoveResistance(resistance); + resistance.Clean(); + } + + // + if (hasBullishOB) + { + // + bullishOBTime = NULL; + RemoveBullishOrderBlock(bullishOB); + bullishOB.Clean(); + } + + // + if (hasBearishOB) + { + // + bearishOBTime = NULL; + RemoveBearishOrderBlock(bearishOB); + bearishOB.Clean(); + } + + // + if (hasBullishFVG) + { + // + bullishFVGUpper = 0; + bullishFVGLower = 0; + bullishFVGTime = NULL; + RemoveBullishFVG(bullishFVG); + bullishFVG.Clean(); + } + + // + if (hasBearishFVG) + { + // + bearishFVGUpper = 0; + bearishFVGLower = 0; + bearishFVGTime = NULL; + RemoveBullishFVG(bearishFVG); + bearishFVG.Clean(); + } + + // + // Retrieve Entry Price based on Position Type ... + entry = GetEntry(mSymbol, type); + + // + // Calculate TP and SL ... + // based on Strategy ... + // only when on of TP or SL Provides, using provided R2R ... + if ((tp <= 0 && sl > 0) || (tp > 0 && sl <= 0)) + { + CalculateTPSLByPrice( + sl, + tp, + type, + entry, + r2r // + ); + } + + // + // Preparing Signal ... + result = signal.Prepare( + mSymbol, + GetTag(), + mPeriod, + type, + mode, + entry, + mVolume, + sl, + tp // + ); + + // + return result; + } + + // + // Protected ... +protected: + // + // Props ... + + // + ENUM_TIMEFRAMES mAnalizePeriod; // Important Area Detect Time Frame + + // + XOHCL support; + XOHCL resistance; + XOHCL bullishOB; + XOHCL bearishOB; + + // + double bullishFVGUpper; + double bullishFVGLower; + XOHCL bullishFVG; + + // + double bearishFVGUpper; + double bearishFVGLower; + XOHCL bearishFVG; + + // + // XPV ... + XPVInputs pvInputs; + XSCXPVHelper *pvHelper; + + // + // XSTR ... + XCHSTRInputs chstrInputs; + XSCXCHSTRHelper *chstrHelper; + + // + // XCHE ... + XCHEInputs cheInputs; + XSCXCHEHelper *cheHelper; + + // + // XHK ... + XCHHKInputs chhkInputs; + XSCXCHHKHelper *chhkHelper; + + // + // XCHMA ... + XCHMInputs chmInputs; + XSCXCHMHelper *chmHelper; + + // + // Private ... +private: + // + // Props ... + + // + // Install all Helpers and Prepare all + // Configurations for required Indicators ... + void PrepareRequirements() + { + // + support.Clean(); + supportTime = NULL; + isSupportTested = false; + + // + resistance.Clean(); + resistanceTime = NULL; + isResistanceTested = false; + + // + // Short ... + ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period + ENUM_TIMEFRAMES scPeriod = NULL; // PERIOD_M20; // Time Period + + // + // Medium ... + ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period + ENUM_TIMEFRAMES mcPeriod = NULL; // PERIOD_M30; // Time Period + + // + // Long ... + ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period + ENUM_TIMEFRAMES lcPeriod = NULL; // PERIOD_H1; // Time Period + + // + // Hind ... + ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period + ENUM_TIMEFRAMES hcPeriod = NULL; // PERIOD_H2; // Time Period + + // + // XPV ... + + // + pvInputs.Default(); + + // + pvInputs.scMethod = scMethod; + pvInputs.scPeriod = scPeriod; + pvInputs.mcMethod = mcMethod; + pvInputs.mcPeriod = mcPeriod; + pvInputs.lcMethod = lcMethod; + pvInputs.lcPeriod = lcPeriod; + pvInputs.hcMethod = hcMethod; + pvInputs.hcPeriod = hcPeriod; + + // + pvInputs.showPeaksAndVales = true; + pvInputs.showLevels = false; + pvInputs.showConsolidations = false; + pvInputs.showFibo1Levels = false; + pvInputs.showFibo2Levels = true; + pvInputs.showFibo3Levels = true; + pvInputs.showFibo4Levels = true; + pvInputs.showFibo5Levels = false; + + // + pvHelper = new XSCXPVHelper(); + pvHelper.Init( + mSymbol, + mPeriod, + pvInputs // + ); + + // + // XCHE ... + + // + cheInputs.Default(); + + // + cheInputs.showLongExit1Line = true; + cheInputs.showShortExit1Line = true; + cheInputs.showLongExit2Line = true; + cheInputs.showShortExit2Line = true; + + // + cheHelper = new XSCXCHEHelper(); + cheHelper.Init( + mSymbol, + mPeriod, + cheInputs // + ); + + // + // XCHM ... + + // + chmInputs.Default(); + + // + chmInputs.scMethod = scMethod; + chmInputs.scPeriod = scPeriod; + chmInputs.mcMethod = mcMethod; + chmInputs.mcPeriod = mcPeriod; + chmInputs.lcMethod = lcMethod; + chmInputs.lcPeriod = lcPeriod; + chmInputs.hcMethod = hcMethod; + chmInputs.hcPeriod = hcPeriod; + + // + chmInputs.showFast = false; + chmInputs.showSlow = false; + chmInputs.showCCFast = false; + chmInputs.showCCSlow = false; + chmInputs.showSCFast = false; + chmInputs.showSCSlow = false; + chmInputs.showMCFast = false; + chmInputs.showMCSlow = false; + chmInputs.showLCFast = false; + chmInputs.showLCSlow = false; + chmInputs.showHCFast = true; + chmInputs.showHCSlow = true; + + // + chmHelper = new XSCXCHMHelper(); + chmHelper.Init( + mSymbol, + mPeriod, + chmInputs // + ); + + // + // XCHHK ... + + // + chhkInputs.Default(); + + // + chhkInputs.scMethod = scMethod; + chhkInputs.scPeriod = scPeriod; + chhkInputs.mcMethod = mcMethod; + chhkInputs.mcPeriod = mcPeriod; + chhkInputs.lcMethod = lcMethod; + chhkInputs.lcPeriod = lcPeriod; + chhkInputs.hcMethod = hcMethod; + chhkInputs.hcPeriod = hcPeriod; + + // + chhkInputs.ignoreShadows = true; + chhkInputs.showCurrent = false; + chhkInputs.showShort = false; + chhkInputs.showMedium = false; + chhkInputs.showLong = false; + chhkInputs.showHind = true; + + // + chhkHelper = new XSCXCHHKHelper(); + chhkHelper.Init( + mSymbol, + mPeriod, + chhkInputs // + ); + + // + // XCHSTR ... + + // + chstrInputs.Default(); + + // + chstrInputs.scMethod = scMethod; + chstrInputs.scPeriod = scPeriod; + chstrInputs.mcMethod = mcMethod; + chstrInputs.mcPeriod = mcPeriod; + chstrInputs.lcMethod = lcMethod; + chstrInputs.lcPeriod = lcPeriod; + chstrInputs.hcMethod = hcMethod; + chstrInputs.hcPeriod = hcPeriod; + + // + chstrInputs.showCurrent = false; + chstrInputs.showShort = false; + chstrInputs.showMedium = false; + chstrInputs.showLong = false; + chstrInputs.showHind = true; + + // + chstrHelper = new XSCXCHSTRHelper(); + chstrHelper.Init( + mSymbol, + mPeriod, + chstrInputs // + ); + } + + // + bool isSupportTested; + datetime supportTime; + void CheckSupportValidation() + { + // + if (!isSupportTested) + { + // + if (support.IsValid() && IsValid(supportTime)) + { + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(supportTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + isSupportTested = false; + supportTime = NULL; + RemoveSupport(support); + support.Clean(); + } + } + return; + } + + // + XOHCL cBar; + bool isInited = cBar.Init( + mSymbol, + mPeriod, + 1 // + ); + if (!isInited) + { + return; + } + + // + double points = GetPoints(mSymbol); + + // + // Find Price Distance ... + double highDiff = MathAbs(cBar.high - support.high); + double lowDiff = MathAbs(cBar.low - support.high); + + // + bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; + if (!isBreaked) + { + return; + } + + // + isSupportTested = false; + RemoveSupport(support); + supportTime = NULL; + support.Clean(); + } + + // + bool isResistanceTested; + datetime resistanceTime; + void CheckResistanceValidation() + { + // + if (!isResistanceTested) + { + // + if (resistance.IsValid() && IsValid(resistanceTime)) + { + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(resistanceTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + isResistanceTested = false; + resistanceTime = NULL; + RemoveResistance(resistance); + resistance.Clean(); + } + } + return; + } + + // + XOHCL cBar; + bool isInited = cBar.Init( + mSymbol, + mPeriod, + 1 // + ); + if (!isInited) + { + return; + } + + // + double points = GetPoints(mSymbol); + + // + // Find Price Distance ... + double highDiff = MathAbs(cBar.high - resistance.low); + double lowDiff = MathAbs(cBar.low - resistance.low); + + // + bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; + if (!isBreaked) + { + return; + } + + // + isResistanceTested = false; + RemoveResistance(resistance); + resistanceTime = NULL; + resistance.Clean(); + } + + // + datetime bullishOBTime; + void CheckBullishOBValidation() + { + // + if (!IsValid(bullishOBTime)) + { + return; + } + + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bullishOBTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + bullishOBTime = NULL; + RemoveBullishOrderBlock(bullishOB); + bullishOB.Clean(); + } + } + + // + datetime bearishOBTime; + void CheckBearishOBValidation() + { + // + if (!IsValid(bearishOBTime)) + { + return; + } + + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bearishOBTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + bearishOBTime = NULL; + RemoveBearishOrderBlock(bearishOB); + bearishOB.Clean(); + } + } + + // + datetime bullishFVGTime; + void CheckBullishFVGValidation() + { + // + if (!IsValid(bullishFVGTime)) + { + return; + } + + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bullishFVGTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + bullishFVGTime = NULL; + RemoveBullishFVG(bullishFVG); + bullishFVG.Clean(); + } + } + + // + datetime bearishFVGTime; + void CheckBearishFVgValidation() + { + // + if (!IsValid(bearishFVGTime)) + { + return; + } + + // + int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bearishFVGTime))) / PeriodSeconds(mPeriod)); + if (age >= 50) + { + // + bearishFVGTime = NULL; + RemoveBearishFVG(bearishFVG); + bearishFVG.Clean(); + } + } + + // + // XCHE Custom Data ... + + // + double cheLastLongExit1; + double cheLastLongExit2; + datetime cheLastLongExitTime; + double GetMaxCHELastLong() + { + // + return MathMax( + cheLastLongExit1, + cheLastLongExit2 // + ); + } + double GetMinCHELastLong() + { + // + return MathMin( + cheLastLongExit1, + cheLastLongExit2 // + ); + } + + // + double cheLastShortExit1; + double cheLastShortExit2; + datetime cheLastShortExitTime; + double GetMaxCHELastShort() + { + // + return MathMax( + cheLastShortExit1, + cheLastShortExit2 // + ); + } + double GetMinCHELastShort() + { + // + return MathMin( + cheLastShortExit1, + cheLastShortExit2 // + ); + } + + // + double GetMaxCHELast() + { + // + return MathMax( + GetMaxCHELastLong(), + GetMaxCHELastShort() // + ); + } + double GetMinCHELast() + { + // + return MathMin( + GetMinCHELastLong(), + GetMinCHELastShort() // + ); + } + + // +}; + +// \ No newline at end of file diff --git a/Documents/BKP/usefull.mq5 b/Documents/BKP/usefull.mq5 index e5c3ed41..0d185993 100644 --- a/Documents/BKP/usefull.mq5 +++ b/Documents/BKP/usefull.mq5 @@ -6973,3 +6973,1048 @@ void HandleStrategiesOnTick() isCHHKHBearishBreaked // ; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + // + // XCHM ... + // Detect XCHMbased Conditions ... + + // + // Bullish ... + + // + bool isCHMHSwithedToBullish = + // + ( + // + chmConditions.isHFastCrossedOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMLSwithedToBullish = + // + ( + // + chmConditions.isLFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMMSwithedToBullish = + // + ( + // + chmConditions.isMFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMSSwithedToBullish = + // + ( + // + chmConditions.isSFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMCSwithedToBullish = + // + ( + // + chmConditions.isCFastCrossedOverSlow && + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHMBullish = + // + ( + // + chmConditions.isHFastOverSlow && + chmConditions.isLFastOverSlow && + chmConditions.isMFastOverSlow && + chmConditions.isSFastOverSlow && + chmConditions.isCFastOverSlow + // + ) + // + ; + + // + bool isCHMSwitchedToBullish = + // + isCHMHSwithedToBullish + // + || + // + isCHMLSwithedToBullish + // + || + // + isCHMMSwithedToBullish + // + || + // + isCHMSSwithedToBullish + // + || + // + isCHMCSwithedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHMCHSwitchedToBearish = + // + ( + // + chmConditions.isHFastCrossedUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCLSwitchedToBearish = + // + ( + // + chmConditions.isLFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCMSwitchedToBearish = + // + ( + // + chmConditions.isMFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCSSwitchedToBearish = + // + ( + // + chmConditions.isSFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMCCSwitchedToBearish = + // + ( + // + chmConditions.isCFastCrossedUnderSlow && + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHMBearish = + // + ( + // + chmConditions.isHFastUnderSlow && + chmConditions.isLFastUnderSlow && + chmConditions.isMFastUnderSlow && + chmConditions.isSFastUnderSlow && + chmConditions.isCFastUnderSlow + // + ) + // + ; + + // + bool isCHMSwitchedToBearish = + // + isCHMCHSwitchedToBearish + // + || + // + isCHMCLSwitchedToBearish + // + || + // + isCHMCMSwitchedToBearish + // + || + // + isCHMCSSwitchedToBearish + // + || + // + isCHMCCSwitchedToBearish + // + ; + + // // + // // Max ... + // double chmMax = MathMax( + // chmConditions.cFast[cIndex], + // chmConditions.cSlow[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.sFast[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.sSlow[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.mFast[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.mSlow[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.lFast[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.lSlow[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.hFast[cIndex] // + // ); + // chmMax = MathMax( + // chmMax, + // chmConditions.hSlow[cIndex] // + // ); + + // // + // // Min ... + // double chmMin = MathMin( + // chmConditions.cFast[cIndex], + // chmConditions.cSlow[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.sFast[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.sSlow[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.mFast[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.mSlow[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.lFast[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.lSlow[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.hFast[cIndex] // + // ); + // chmMin = MathMin( + // chmMin, + // chmConditions.hSlow[cIndex] // + // ); + + // + double chmDistanceDiffInPoint = + // + (chmMax - chmMin) / points + // + ; + + // + // XCHHK ... + // Detect XCHHK Conditions ... + + // + // Bullish ... + + // + bool isCHHKCSwitchedToBullish = + // + ( + // + chhkConditions.isCSwitchedToBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKSSwitchedToBullish = + // + ( + // + chhkConditions.isSSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKMSwitchedToBullish = + // + ( + // + chhkConditions.isMSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isLBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKLSwitchedToBullish = + // + ( + // + chhkConditions.isLSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isHBullish + // + ) + // + ; + + // + bool isCHHKHSwitchedToBullish = + // + ( + // + chhkConditions.isHSwitchedToBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHHKBullish = + // + ( + // + chhkConditions.isHBullish && + chhkConditions.isCBullish && + chhkConditions.isSBullish && + chhkConditions.isMBullish && + chhkConditions.isLBullish + // + ) + // + ; + + // + bool isCHHKSwitchedBullish = + // + isCHHKCSwitchedToBullish + // + || + // + isCHHKSSwitchedToBullish + // + || + // + isCHHKMSwitchedToBullish + // + || + // + isCHHKLSwitchedToBullish + // + || + // + isCHHKHSwitchedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHHKCSwitchedToBearish = + // + ( + // + chhkConditions.isCSwitchedToBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKSSwitchedToBearish = + // + ( + // + chhkConditions.isSSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKMSwitchedToBearish = + // + ( + // + chhkConditions.isMSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isLBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKLSwitchedToBearish = + // + ( + // + chhkConditions.isLSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isHBearish + // + ) + // + ; + + // + bool isCHHKHSwitchedToBearish = + // + ( + // + chhkConditions.isHSwitchedToBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHHKBearish = + // + ( + // + chhkConditions.isHBearish && + chhkConditions.isCBearish && + chhkConditions.isSBearish && + chhkConditions.isMBearish && + chhkConditions.isLBearish + // + ) + // + ; + + // + bool isCHHKSwitchedToBearish = + // + isCHHKCSwitchedToBearish + // + || + // + isCHHKSSwitchedToBearish + // + || + // + isCHHKMSwitchedToBearish + // + || + // + isCHHKLSwitchedToBearish + // + || + // + isCHHKHSwitchedToBearish + // + ; + + // // + // // Max High ... + // double chhkHighMax = MathMax( + // chhkConditions.cBars[cIndex].high, + // chhkConditions.sBars[cIndex].high // + // ); + // chhkHighMax = MathMax( + // chhkHighMax, + // chhkConditions.mBars[cIndex].high // + // ); + // chhkHighMax = MathMax( + // chhkHighMax, + // chhkConditions.lBars[cIndex].high // + // ); + // chhkHighMax = MathMax( + // chhkHighMax, + // chhkConditions.hBars[cIndex].high // + // ); + + // // + // // Min High ... + // double chhkHighMin = MathMin( + // chhkConditions.cBars[cIndex].high, + // chhkConditions.sBars[cIndex].high // + // ); + // chhkHighMin = MathMin( + // chhkHighMin, + // chhkConditions.mBars[cIndex].high // + // ); + // chhkHighMin = MathMin( + // chhkHighMin, + // chhkConditions.lBars[cIndex].high // + // ); + // chhkHighMin = MathMin( + // chhkHighMin, + // chhkConditions.hBars[cIndex].high // + // ); + + // // + // // Max Low ... + // double chhkLowMax = MathMax( + // chhkConditions.cBars[cIndex].low, + // chhkConditions.sBars[cIndex].low // + // ); + // chhkLowMax = MathMax( + // chhkLowMax, + // chhkConditions.mBars[cIndex].low // + // ); + // chhkLowMax = MathMax( + // chhkLowMax, + // chhkConditions.lBars[cIndex].low // + // ); + // chhkLowMax = MathMax( + // chhkLowMax, + // chhkConditions.hBars[cIndex].low // + // ); + + // // + // // Min Low ... + // double chhkLowMin = MathMin( + // chhkConditions.cBars[cIndex].low, + // chhkConditions.sBars[cIndex].low // + // ); + // chhkLowMin = MathMin( + // chhkLowMin, + // chhkConditions.mBars[cIndex].low // + // ); + // chhkLowMin = MathMin( + // chhkLowMin, + // chhkConditions.lBars[cIndex].low // + // ); + // chhkLowMin = MathMin( + // chhkLowMin, + // chhkConditions.hBars[cIndex].low // + // ); + + // + double chhkDistanceDiffInPoint = + // + (chhkHighMax - chhkLowMin) / points + // + ; + + // + // XCHSTR ... + // Detect XCHSTR Conditions ... + + // + // Bullish ... + + // + bool isCHSTRHSwitchedToBullish = + // + ( + // + chstrConditions.isHSwitchedToBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRLSwitchedToBullish = + // + ( + // + chstrConditions.isLSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRMSwitchedToBullish = + // + ( + // + chstrConditions.isMSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isSBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRSSwitchedToBullish = + // + ( + // + chstrConditions.isSSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isCBullish + // + ) + // + ; + + // + bool isCHSTRCSwitchedToBullish = + // + ( + // + chstrConditions.isCSwitchedToBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish + // + ) + // + ; + + // + // Bullish Conclusion ... + + // + bool isCHSTRBullish = + // + ( + // + chstrConditions.isCBullish && + chstrConditions.isHBullish && + chstrConditions.isLBullish && + chstrConditions.isMBullish && + chstrConditions.isSBullish + // + ) + // + ; + + // + bool isCHMSTRBullish = + // + isCHSTRHSwitchedToBullish + // + || + // + isCHSTRLSwitchedToBullish + // + || + // + isCHSTRMSwitchedToBullish + // + || + // + isCHSTRSSwitchedToBullish + // + || + // + isCHSTRCSwitchedToBullish + // + ; + + // + // Bearish ... + + // + bool isCHSTRHSwitchedToBearish = + // + ( + // + chstrConditions.isHSwitchedToBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRLSwitchedToBearish = + // + ( + // + chstrConditions.isLSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRMSwitchedToBearish = + // + ( + // + chstrConditions.isMSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isSBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRSSwitchedToBearish = + // + ( + // + chstrConditions.isSSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isCBearish + // + ) + // + ; + + // + bool isCHSTRCSwitchedToBearish = + // + ( + // + chstrConditions.isCSwitchedToBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish + // + ) + // + ; + + // + // Bearish Conclusion ... + + // + bool isCHSTRBearish = + // + ( + // + chstrConditions.isCBearish && + chstrConditions.isHBearish && + chstrConditions.isLBearish && + chstrConditions.isMBearish && + chstrConditions.isSBearish + // + ) + // + ; + + // + bool isCHSTRSwitchedToBearish = + // + isCHSTRHSwitchedToBearish + // + || + // + isCHSTRLSwitchedToBearish + // + || + // + isCHSTRMSwitchedToBearish + // + || + // + isCHSTRSSwitchedToBearish + // + || + // + isCHSTRCSwitchedToBearish + // + ; + + // // + // // Max ... + // double chstrMax = MathMax( + // chstrConditions.cTrend[cIndex], + // chstrConditions.sTrend[cIndex] // + // ); + // chstrMax = MathMax( + // chstrMax, + // chstrConditions.mTrend[cIndex] // + // ); + // chstrMax = MathMax( + // chstrMax, + // chstrConditions.lTrend[cIndex] // + // ); + // chstrMax = MathMax( + // chstrMax, + // chstrConditions.hTrend[cIndex] // + // ); + + // // + // // Min ... + // double chstrMin = MathMin( + // chstrConditions.cTrend[cIndex], + // chstrConditions.sTrend[cIndex] // + // ); + // chstrMin = MathMin( + // chstrMin, + // chstrConditions.mTrend[cIndex] // + // ); + // chstrMin = MathMin( + // chstrMin, + // chstrConditions.lTrend[cIndex] // + // ); + // chstrMin = MathMin( + // chstrMin, + // chstrConditions.hTrend[cIndex] // + // ); + + // + double chstrDistanceDiffInPoint = + // + (chstrMax - chstrMin) / points + // + ; + + // + // Other Conditions ... + + // + bool isPriceOveralBullish = + // + cBar.low > chhkConditions.hBars[cIndex].high + // + ; + + // + bool isPriceOveralBullishPrev = + // + pBar.low > chhkConditions.hBars[pIndex].high + // + ; + + // + bool isPriceOveralSwitchedToBullish = + // + isPriceOveralBullish && + !isPriceOveralBullishPrev + // + ; + + // + bool isPriceOveralBearish = + // + cBar.high < chhkConditions.hBars[cIndex].low + // + ; + + // + bool isPriceOveralBearishPrev = + // + pBar.high < chhkConditions.hBars[pIndex].low + // + ; + + // + bool isPriceOveralSwitchedToBearish = + // + isPriceOveralBearish && + !isPriceOveralBearishPrev + // + ; + + // + // Signalling ... + // Looking for Signals Based on Conditions ... + + // // + // // Checking Long Conditions ... + // if (isPriceOveralSwitchedToBullish) + // { + // // + // hasLong = + // // + // hasBullishPower && + // cBar.IsBullish() && + // hasBullishPressure && + // chhkConditions.isHBullish && + // chstrConditions.isHBullish && + // cheConditions.isStrongBullish && + // cBar.low > pvConditions.fib2s[cIndex] + // // + // ; + + // // + // if (hasLong) + // { + // // + // type = POSITION_TYPE_BUY; + // sl = pvConditions.fib2s[cIndex]; + // } + // } + + // // + // // Checking Short Conditions ... + // if (isPriceOveralSwitchedToBearish) + // { + // // + // hasShort = + // // + // hasBearishPower && + // cBar.IsBearish() && + // hasBearishPressure && + // chhkConditions.isHBearish && + // chstrConditions.isHBearish && + // cheConditions.isStrongBearish && + // cBar.high < pvConditions.fib4s[cIndex] + // // + // ; + + // // + // if (hasShort) + // { + // // + // type = POSITION_TYPE_SELL; + // sl = pvConditions.fib4s[cIndex]; + // } + // } diff --git a/Experts/x-test-strategies.ea.mq5 b/Experts/x-test-strategies.ea.mq5 index f2b61392..0a60a901 100644 --- a/Experts/x-test-strategies.ea.mq5 +++ b/Experts/x-test-strategies.ea.mq5 @@ -43,23 +43,29 @@ double eaAllowLong = true; // Allow Long Positions double eaAllowShort = true; // Allow Short Positions // -int eaMaxAllowedLongs = 0; // Max Allowed Long Positions -int eaMaxAllowedShorts = 0; // Max Allowed Short Positions +int eaMaxAllowedLongs = 1; // Max Allowed Long Positions +int eaMaxAllowedShorts = 1; // Max Allowed Short Positions // -input double eaTPPoint = 200; // Static TP Point +input double eaTPPoint = 100; // Static TP Point input double eaSLPoint = 100; // Static SL Point // bool eaIgnoreTP = false; // Ignore TP bool eaIgnoreSL = false; // Ignore SL +// +int eaMaxAllowedSLsInDay = 2; + // double eaR2R = 1.5; // Risk to Reward Ratio // // Variables ... +// +int mNumberOfSLs = 0; + // // Bar Style nad Time Instances ... XSCXCTHelper *mCTHelper; @@ -73,6 +79,9 @@ XSCBaseStrategy *strategies[]; // Trader Instance Class ... XSCTrade *eaTrader; +// +XTimeTracker eaTimeTracker; + // // Alert Class ... XSCAlert *eaAlert; @@ -167,7 +176,14 @@ void OnTrade() // On Timer ... void OnTimer() { + // HandleTradeState(); + + // + if (eaTimeTracker.IsNewDay()) + { + mNumberOfSLs = 0; + } } // @@ -359,6 +375,7 @@ bool InitialEA() eurusdXCHKMStrategy = new XSCXCHKMStrategy( eurusdSymbol, PERIOD_M5, + PERIOD_H1, // Analyzing Period eaVolume, eaR2R, // R2R ... eaSlippage, @@ -387,17 +404,18 @@ bool InitialEA() xchmStrategy = new XSCXCHKMStrategy( _Symbol, _Period, + PERIOD_H1, // Analyzing Period eaVolume, eaR2R, // R2R ... eaSlippage, eaMagicNumber, true, // Ignore Signal Execution - false, // Use TP SL Point + true, // Use TP SL Point false, // Use Max eaTPPoint, // TP eaSLPoint, // SL eaIgnoreTP, - false, // eaIgnoreSL, + true, // eaIgnoreSL, eaAllowLong, eaAllowShort, eaMaxAllowedLongs, // Max Longs @@ -503,6 +521,13 @@ void OnSignalRecieved(XSignal &signal) return; } + // + if (eaMaxAllowedSLsInDay > 0 && + mNumberOfSLs >= eaMaxAllowedSLsInDay) + { + return; + } + // ENUM_X_SIGNAL_EXECUTION_RESULT state; bool isExecuted = eaTrader.ExecuteSignal( @@ -564,13 +589,21 @@ void OnSignalRecieved(XSignal &signal) // void OnStopLossTriggered(const XDeal &deal) { + // // Finish ... eaTradeHandler.Finish(deal); + + // + if (deal.profit < 0) + { + mNumberOfSLs++; + } } // void OnTakeProfitTriggered(const XDeal &deal) { + // // Finish ... eaTradeHandler.Finish(deal); } diff --git a/Helpers/x-saherelm.xchhk.helper.mq5 b/Helpers/x-saherelm.xchhk.helper.mq5 index 84d3a28b..f9dadbb8 100644 --- a/Helpers/x-saherelm.xchhk.helper.mq5 +++ b/Helpers/x-saherelm.xchhk.helper.mq5 @@ -4055,7 +4055,7 @@ public: // for (int i = 0; i < barsCount; i++) { - result = bars[i].GetBody(); + result += bars[i].GetBody(); } // @@ -4084,7 +4084,7 @@ public: // for (int i = 0; i < barsCount; i++) { - result = bars[i].GetBody(); + result += bars[i].GetBody(); } // @@ -4115,7 +4115,7 @@ public: // for (int i = 0; i < barsCount; i++) { - result = bars[i].GetBody(); + result += bars[i].GetBody(); } // @@ -4146,7 +4146,7 @@ public: // for (int i = 0; i < barsCount; i++) { - result = bars[i].GetBody(); + result += bars[i].GetBody(); } // diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 7f96e8a3..9a2e1f36 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -1165,7 +1165,7 @@ struct XOHCL // bool IsSharpBullish( - int _loopback = 2, + int __loopback = 2, double _sharpRatio = 2.5 // ) { @@ -1180,9 +1180,9 @@ struct XOHCL } // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 2; + __loopback = 2; } // @@ -1193,11 +1193,11 @@ struct XOHCL // int hIDX = FindHighestIndex( - _loopback, + __loopback, MODE_HIGH // ); int lIDX = FindLowestIndex( - _loopback, + __loopback, MODE_LOW // ); @@ -1245,13 +1245,13 @@ struct XOHCL // int hhIDX = hBar.FindHighestIndex( - _loopback, + __loopback, MODE_HIGH // ); // int llIDX = lBar.FindLowestIndex( - _loopback, + __loopback, MODE_LOW // ); @@ -1297,7 +1297,7 @@ struct XOHCL // bool IsSharpBearish( - int _loopback = 2, + int __loopback = 2, double _sharpRatio = 2.5 // ) { @@ -1312,9 +1312,9 @@ struct XOHCL } // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 2; + __loopback = 2; } // @@ -1325,11 +1325,11 @@ struct XOHCL // int hIDX = FindHighestIndex( - _loopback, + __loopback, MODE_HIGH // ); int lIDX = FindLowestIndex( - _loopback, + __loopback, MODE_LOW // ); @@ -1377,13 +1377,13 @@ struct XOHCL // int hhIDX = hBar.FindHighestIndex( - _loopback, + __loopback, MODE_HIGH // ); // int llIDX = lBar.FindLowestIndex( - _loopback, + __loopback, MODE_LOW // ); @@ -1588,7 +1588,7 @@ struct XOHCL // // Retrieve Bullish Pressure ... double GetBullishPressure( - int _loopback = 7 // + int __loopback = 7 // ) { // @@ -1607,7 +1607,7 @@ struct XOHCL symbol, period, Index(), - _loopback // + __loopback // ); if (!IsValidSize(barsCount)) { @@ -1627,7 +1627,7 @@ struct XOHCL // // Retrieve Bearish Pressure ... double GetBearishPressure( - int _loopback = 7 // + int __loopback = 7 // ) { // @@ -1646,7 +1646,7 @@ struct XOHCL symbol, period, Index(), - _loopback // + __loopback // ); if (!IsValidSize(barsCount)) { @@ -1665,21 +1665,21 @@ struct XOHCL // bool HasBullishPressure( - int _loopback = 7 // + int __loopback = 7 // ) { // bool result = false; // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 7; + __loopback = 7; } // - double bullishPressure = GetBullishPressure(_loopback); - double bearishPressure = GetBearishPressure(_loopback); + double bullishPressure = GetBullishPressure(__loopback); + double bearishPressure = GetBearishPressure(__loopback); // result = @@ -1696,21 +1696,21 @@ struct XOHCL // bool HasBearishPressure( - int _loopback = 7 // + int __loopback = 7 // ) { // bool result = false; // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 7; + __loopback = 7; } // - double bullishPressure = GetBullishPressure(_loopback); - double bearishPressure = GetBearishPressure(_loopback); + double bullishPressure = GetBullishPressure(__loopback); + double bearishPressure = GetBearishPressure(__loopback); // result = @@ -1728,7 +1728,7 @@ struct XOHCL // // Retrieve Bullish Power ... double GetBullishPower( - int _loopback = 7 // + int __loopback = 7 // ) { // @@ -1747,7 +1747,7 @@ struct XOHCL symbol, period, Index(), - _loopback // + __loopback // ); if (!IsValidSize(barsCount)) { @@ -1771,7 +1771,7 @@ struct XOHCL // // Retrieve Bearish Pressure ... double GetBearishPower( - int _loopback = 7 // + int __loopback = 7 // ) { // @@ -1790,7 +1790,7 @@ struct XOHCL symbol, period, Index(), - _loopback // + __loopback // ); if (!IsValidSize(barsCount)) { @@ -1813,21 +1813,21 @@ struct XOHCL // bool HasBullishPower( - int _loopback = 7 // + int __loopback = 7 // ) { // bool result = false; // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 7; + __loopback = 7; } // - double bullishPressure = GetBullishPower(_loopback); - double bearishPressure = GetBearishPower(_loopback); + double bullishPressure = GetBullishPower(__loopback); + double bearishPressure = GetBearishPower(__loopback); // result = @@ -1844,21 +1844,21 @@ struct XOHCL // bool HasBearishPower( - int _loopback = 7 // + int __loopback = 7 // ) { // bool result = false; // - if (_loopback < 0) + if (__loopback < 0) { - _loopback = 7; + __loopback = 7; } // - double bullishPressure = GetBullishPower(_loopback); - double bearishPressure = GetBearishPower(_loopback); + double bullishPressure = GetBullishPower(__loopback); + double bearishPressure = GetBearishPower(__loopback); // result = @@ -3114,7 +3114,7 @@ struct XOHCL bool HasSupport( XOHCL &bar, ENUM_X_PRICE type = X_PRICE_CLOSE, - int loopback = 21, + int _loopback = 21, int tries = 100 // ) { @@ -3125,9 +3125,9 @@ struct XOHCL bar.Clean(); // - if (loopback < 0) + if (_loopback < 0) { - loopback = 21; + _loopback = 21; } // @@ -3150,11 +3150,11 @@ struct XOHCL for (int i = 1; i < tries; i++) { // - int length = loopback * i; + int _length = _loopback * i; // int lowestIDX = FindLowestIndex( - length, + _length, MODE_LOW // ); result = IsValidSize(lowestIDX); @@ -3198,7 +3198,7 @@ struct XOHCL bool HasResistance( XOHCL &bar, ENUM_X_PRICE type = X_PRICE_CLOSE, - int loopback = 21, + int _loopback = 21, int tries = 100 // ) { @@ -3209,9 +3209,9 @@ struct XOHCL bar.Clean(); // - if (loopback < 0) + if (_loopback < 0) { - loopback = 21; + _loopback = 21; } // @@ -3234,11 +3234,11 @@ struct XOHCL for (int i = 1; i < tries; i++) { // - int length = loopback * i; + int _length = _loopback * i; // int highestIDX = FindHighestIndex( - length, + _length, MODE_LOW // ); result = IsValidSize(highestIDX); @@ -3286,7 +3286,7 @@ struct XOHCL XOHCL &highSwingBars[], XOHCL &lowSwingBars[], bool forceMethod2 = false, - int loopback = 3, + int _loopback = 3, int tries = 3, ENUM_X_PRICE type = X_PRICE_CLOSE // ) @@ -3323,7 +3323,7 @@ struct XOHCL symbol, period, X_SWING_HIGH, - loopback, + _loopback, lastIDX // ); result = IsValidIndex(iHIDX); @@ -3376,7 +3376,7 @@ struct XOHCL symbol, period, X_SWING_LOW, - loopback, + _loopback, lastIDX // ); result = IsValidIndex(iLIDX); @@ -3429,12 +3429,12 @@ struct XOHCL else { // - int length = i * loopback; + int _length = i * _loopback; int start = // i == 1 ? 1 - : length - loopback + : _length - _loopback // ; @@ -3443,7 +3443,7 @@ struct XOHCL symbol, period, MODE_HIGH, - loopback, + _loopback, start // ); result = IsValidIndex(iHIDX); @@ -3496,7 +3496,7 @@ struct XOHCL symbol, period, MODE_LOW, - loopback, + _loopback, start // ); result = IsValidIndex(iLIDX); @@ -3576,7 +3576,7 @@ struct XOHCL XOHCL &highSwingBars[], XOHCL &lowSwingBars[], bool forceMethod2 = false, - int loopback = 3, + int _loopback = 3, int tries = 3, ENUM_X_PRICE type = X_PRICE_CLOSE // ) @@ -3613,7 +3613,7 @@ struct XOHCL symbol, period, X_SWING_HIGH, - loopback, + _loopback, lastIDX // ); result = IsValidIndex(iHIDX); @@ -3666,7 +3666,7 @@ struct XOHCL symbol, period, X_SWING_LOW, - loopback, + _loopback, lastIDX // ); result = IsValidIndex(iLIDX); @@ -3719,12 +3719,12 @@ struct XOHCL else { // - int length = i * loopback; + int _length = i * _loopback; int start = // i == 1 ? 1 - : length - loopback + : _length - _loopback // ; @@ -3733,7 +3733,7 @@ struct XOHCL symbol, period, MODE_HIGH, - loopback, + _loopback, start // ); result = IsValidIndex(iHIDX); @@ -3786,7 +3786,7 @@ struct XOHCL symbol, period, MODE_LOW, - loopback, + _loopback, start // ); result = IsValidIndex(iLIDX); diff --git a/Strategies/x-saherelm.xchkm.strategy.mq5 b/Strategies/x-saherelm.xchkm.strategy.mq5 index f7476f09..831bf0e4 100644 --- a/Strategies/x-saherelm.xchkm.strategy.mq5 +++ b/Strategies/x-saherelm.xchkm.strategy.mq5 @@ -52,6 +52,7 @@ public: // Base ... string _symbol, // Trading Symbol ENUM_TIMEFRAMES _period, // Trading TimeFrame + ENUM_TIMEFRAMES _analizePeriod, // Important Area Detect Time Frame double _volume, // Voluem double _r2r, // Risk/Reward Ratio int _slippage, // Trader Slippage @@ -86,6 +87,9 @@ public: _maxAllowedShorts // ) { + // + mAnalizePeriod = _analizePeriod; + // SetAlertPrefix(GetTag()); @@ -148,7 +152,7 @@ public: // // Draw Support/Resistance/OB(s)/FVG(s) ... - bool drawImportantAreas = false; + bool drawImportantAreas = true; // // Retrieve Conditions ... @@ -226,6 +230,29 @@ public: return result; } + // + // Analyzing Bar ... + XOHCL aBar; + if (IsValid(mAnalizePeriod)) + { + // + result = aBar.Init( + mSymbol, + mAnalizePeriod, + cIndex // + ); + + // + if (!result) + { + return result; + } + } + else + { + aBar = cBar; + } + // // Previous Bar of Last Bar ... XOHCL pBar; @@ -281,7 +308,7 @@ public: // hasSupport = // - cBar.HasSupport(support) + aBar.HasSupport(support) // ; @@ -299,7 +326,7 @@ public: } // - supportTime = cBar.time; + supportTime = aBar.time; } } @@ -311,7 +338,7 @@ public: // hasResistance = // - cBar.HasResistance(resistance) + aBar.HasResistance(resistance) // ; @@ -329,7 +356,7 @@ public: } // - resistanceTime = cBar.time; + resistanceTime = aBar.time; } } @@ -343,7 +370,7 @@ public: // hasBullishOB = // - cBar.HasBullishOrderBlock(bullishOB) + aBar.HasBullishOrderBlock(bullishOB) // ; @@ -361,7 +388,7 @@ public: } // - bullishOBTime = cBar.time; + bullishOBTime = aBar.time; } } @@ -372,7 +399,7 @@ public: // hasBearishOB = // - cBar.HasBearishOrderBlock(bearishOB) + aBar.HasBearishOrderBlock(bearishOB) // ; @@ -390,7 +417,7 @@ public: } // - bearishOBTime = cBar.time; + bearishOBTime = aBar.time; } } @@ -404,7 +431,10 @@ public: // hasBullishFVG = // - cBar.HasBullishFVG(bullishFVGUpper, bullishFVGLower) + aBar.HasBullishFVG( + bullishFVGUpper, + bullishFVGLower // + ) // ; @@ -412,7 +442,7 @@ public: if (hasBullishFVG) { // - bullishFVG = cBar; + bullishFVG = aBar; // if (drawImportantAreas) @@ -427,7 +457,7 @@ public: } // - bullishFVGTime = cBar.time; + bullishFVGTime = aBar.time; } } @@ -438,7 +468,10 @@ public: // hasBearishFVG = // - cBar.HasBearishFVG(bearishFVGUpper, bearishFVGLower) + aBar.HasBearishFVG( + bearishFVGUpper, + bearishFVGLower // + ) // ; @@ -446,7 +479,7 @@ public: if (hasBearishFVG) { // - bearishFVG = cBar; + bearishFVG = aBar; // if (drawImportantAreas) @@ -461,7 +494,7 @@ public: } // - bearishFVGTime = cBar.time; + bearishFVGTime = aBar.time; } } @@ -525,1009 +558,37 @@ public: } // - // XCHM ... - // Detect XCHMbased Conditions ... + double chhkBullishPower = chhkHelper.GetBullishPower(cIndex); + double chhkBearishPower = chhkHelper.GetBearishPower(cIndex); // - // Bullish ... - - // - bool isCHMHSwithedToBullish = - // - ( - // - chmConditions.isHFastCrossedOverSlow && - chmConditions.isLFastOverSlow && - chmConditions.isMFastOverSlow && - chmConditions.isSFastOverSlow && - chmConditions.isCFastOverSlow - // - ) - // - ; - - // - bool isCHMLSwithedToBullish = - // - ( - // - chmConditions.isLFastCrossedOverSlow && - chmConditions.isHFastOverSlow && - chmConditions.isMFastOverSlow && - chmConditions.isSFastOverSlow && - chmConditions.isCFastOverSlow - // - ) - // - ; - - // - bool isCHMMSwithedToBullish = - // - ( - // - chmConditions.isMFastCrossedOverSlow && - chmConditions.isHFastOverSlow && - chmConditions.isLFastOverSlow && - chmConditions.isSFastOverSlow && - chmConditions.isCFastOverSlow - // - ) - // - ; - - // - bool isCHMSSwithedToBullish = - // - ( - // - chmConditions.isSFastCrossedOverSlow && - chmConditions.isHFastOverSlow && - chmConditions.isLFastOverSlow && - chmConditions.isMFastOverSlow && - chmConditions.isCFastOverSlow - // - ) - // - ; - - // - bool isCHMCSwithedToBullish = - // - ( - // - chmConditions.isCFastCrossedOverSlow && - chmConditions.isHFastOverSlow && - chmConditions.isLFastOverSlow && - chmConditions.isMFastOverSlow && - chmConditions.isSFastOverSlow - // - ) - // - ; - - // - // Bullish Conclusion ... - - // - bool isCHMBullish = - // - ( - // - chmConditions.isHFastOverSlow && - chmConditions.isLFastOverSlow && - chmConditions.isMFastOverSlow && - chmConditions.isSFastOverSlow && - chmConditions.isCFastOverSlow - // - ) - // - ; - - // - bool isCHMSwitchedToBullish = - // - isCHMHSwithedToBullish - // - || - // - isCHMLSwithedToBullish - // - || - // - isCHMMSwithedToBullish - // - || - // - isCHMSSwithedToBullish - // - || - // - isCHMCSwithedToBullish - // - ; - - // - // Bearish ... - - // - bool isCHMCHSwitchedToBearish = - // - ( - // - chmConditions.isHFastCrossedUnderSlow && - chmConditions.isLFastUnderSlow && - chmConditions.isMFastUnderSlow && - chmConditions.isSFastUnderSlow && - chmConditions.isCFastUnderSlow - // - ) - // - ; - - // - bool isCHMCLSwitchedToBearish = - // - ( - // - chmConditions.isLFastCrossedUnderSlow && - chmConditions.isHFastUnderSlow && - chmConditions.isMFastUnderSlow && - chmConditions.isSFastUnderSlow && - chmConditions.isCFastUnderSlow - // - ) - // - ; - - // - bool isCHMCMSwitchedToBearish = - // - ( - // - chmConditions.isMFastCrossedUnderSlow && - chmConditions.isHFastUnderSlow && - chmConditions.isLFastUnderSlow && - chmConditions.isSFastUnderSlow && - chmConditions.isCFastUnderSlow - // - ) - // - ; - - // - bool isCHMCSSwitchedToBearish = - // - ( - // - chmConditions.isSFastCrossedUnderSlow && - chmConditions.isHFastUnderSlow && - chmConditions.isLFastUnderSlow && - chmConditions.isMFastUnderSlow && - chmConditions.isCFastUnderSlow - // - ) - // - ; - - // - bool isCHMCCSwitchedToBearish = - // - ( - // - chmConditions.isCFastCrossedUnderSlow && - chmConditions.isHFastUnderSlow && - chmConditions.isLFastUnderSlow && - chmConditions.isMFastUnderSlow && - chmConditions.isSFastUnderSlow - // - ) - // - ; - - // - // Bearish Conclusion ... - - // - bool isCHMBearish = - // - ( - // - chmConditions.isHFastUnderSlow && - chmConditions.isLFastUnderSlow && - chmConditions.isMFastUnderSlow && - chmConditions.isSFastUnderSlow && - chmConditions.isCFastUnderSlow - // - ) - // - ; - - // - bool isCHMSwitchedToBearish = - // - isCHMCHSwitchedToBearish - // - || - // - isCHMCLSwitchedToBearish - // - || - // - isCHMCMSwitchedToBearish - // - || - // - isCHMCSSwitchedToBearish - // - || - // - isCHMCCSwitchedToBearish - // - ; - - // - // Max ... - double chmMax = MathMax( - chmConditions.cFast[cIndex], - chmConditions.cSlow[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.sFast[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.sSlow[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.mFast[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.mSlow[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.lFast[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.lSlow[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.hFast[cIndex] // - ); - chmMax = MathMax( - chmMax, - chmConditions.hSlow[cIndex] // - ); - - // - // Min ... - double chmMin = MathMin( - chmConditions.cFast[cIndex], - chmConditions.cSlow[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.sFast[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.sSlow[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.mFast[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.mSlow[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.lFast[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.lSlow[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.hFast[cIndex] // - ); - chmMin = MathMin( - chmMin, - chmConditions.hSlow[cIndex] // - ); - - // - double chmDistanceDiffInPoint = - // - (chmMax - chmMin) / points - // - ; + double chhkMinBearishHigh = chhkHelper.GetMinBearishHigh(cIndex); + double chhkMaxBearishHigh = chhkHelper.GetMaxBearishHigh(cIndex); + double chhkMinBearishLow = chhkHelper.GetMinBearishLow(cIndex); + double chhkMaxBearishLow = chhkHelper.GetMaxBearishLow(cIndex); + double chhkMaxBullishHigh = chhkHelper.GetMaxBullishHigh(cIndex); + double chhkMinBullishHigh = chhkHelper.GetMinBullishHigh(cIndex); + double chhkMaxBullishLow = chhkHelper.GetMaxBullishLow(cIndex); + double chhkMinBullishLow = chhkHelper.GetMinBullishLow(cIndex); // // XCHHK ... - // Detect XCHHK Conditions ... // - // Bullish ... - - // - bool isCHHKCSwitchedToBullish = - // - ( - // - chhkConditions.isCSwitchedToBullish && - chhkConditions.isSBullish && - chhkConditions.isMBullish && - chhkConditions.isLBullish && - chhkConditions.isHBullish - // - ) - // - ; - - // - bool isCHHKSSwitchedToBullish = - // - ( - // - chhkConditions.isSSwitchedToBullish && - chhkConditions.isCBullish && - chhkConditions.isMBullish && - chhkConditions.isLBullish && - chhkConditions.isHBullish - // - ) - // - ; - - // - bool isCHHKMSwitchedToBullish = - // - ( - // - chhkConditions.isMSwitchedToBullish && - chhkConditions.isCBullish && - chhkConditions.isSBullish && - chhkConditions.isLBullish && - chhkConditions.isHBullish - // - ) - // - ; - - // - bool isCHHKLSwitchedToBullish = - // - ( - // - chhkConditions.isLSwitchedToBullish && - chhkConditions.isCBullish && - chhkConditions.isSBullish && - chhkConditions.isMBullish && - chhkConditions.isHBullish - // - ) - // - ; - - // - bool isCHHKHSwitchedToBullish = - // - ( - // - chhkConditions.isHSwitchedToBullish && - chhkConditions.isCBullish && - chhkConditions.isSBullish && - chhkConditions.isMBullish && - chhkConditions.isLBullish - // - ) - // - ; - - // - // Bullish Conclusion ... - - // - bool isCHHKBullish = - // - ( - // - chhkConditions.isHBullish && - chhkConditions.isCBullish && - chhkConditions.isSBullish && - chhkConditions.isMBullish && - chhkConditions.isLBullish - // - ) - // - ; - - // - bool isCHHKSwitchedBullish = - // - isCHHKCSwitchedToBullish - // - || - // - isCHHKSSwitchedToBullish - // - || - // - isCHHKMSwitchedToBullish - // - || - // - isCHHKLSwitchedToBullish - // - || - // - isCHHKHSwitchedToBullish - // - ; - - // - // Bearish ... - - // - bool isCHHKCSwitchedToBearish = - // - ( - // - chhkConditions.isCSwitchedToBearish && - chhkConditions.isSBearish && - chhkConditions.isMBearish && - chhkConditions.isLBearish && - chhkConditions.isHBearish - // - ) - // - ; - - // - bool isCHHKSSwitchedToBearish = - // - ( - // - chhkConditions.isSSwitchedToBearish && - chhkConditions.isCBearish && - chhkConditions.isMBearish && - chhkConditions.isLBearish && - chhkConditions.isHBearish - // - ) - // - ; - - // - bool isCHHKMSwitchedToBearish = - // - ( - // - chhkConditions.isMSwitchedToBearish && - chhkConditions.isCBearish && - chhkConditions.isSBearish && - chhkConditions.isLBearish && - chhkConditions.isHBearish - // - ) - // - ; - - // - bool isCHHKLSwitchedToBearish = - // - ( - // - chhkConditions.isLSwitchedToBearish && - chhkConditions.isCBearish && - chhkConditions.isSBearish && - chhkConditions.isMBearish && - chhkConditions.isHBearish - // - ) - // - ; - - // - bool isCHHKHSwitchedToBearish = - // - ( - // - chhkConditions.isHSwitchedToBearish && - chhkConditions.isCBearish && - chhkConditions.isSBearish && - chhkConditions.isMBearish && - chhkConditions.isLBearish - // - ) - // - ; - - // - // Bearish Conclusion ... - - // - bool isCHHKBearish = - // - ( - // - chhkConditions.isHBearish && - chhkConditions.isCBearish && - chhkConditions.isSBearish && - chhkConditions.isMBearish && - chhkConditions.isLBearish - // - ) - // - ; - - // - bool isCHHKSwitchedToBearish = - // - isCHHKCSwitchedToBearish - // - || - // - isCHHKSSwitchedToBearish - // - || - // - isCHHKMSwitchedToBearish - // - || - // - isCHHKLSwitchedToBearish - // - || - // - isCHHKHSwitchedToBearish - // - ; - - // - // Max High ... - double chhkHighMax = MathMax( - chhkConditions.cBars[cIndex].high, - chhkConditions.sBars[cIndex].high // - ); - chhkHighMax = MathMax( - chhkHighMax, - chhkConditions.mBars[cIndex].high // - ); - chhkHighMax = MathMax( - chhkHighMax, - chhkConditions.lBars[cIndex].high // - ); - chhkHighMax = MathMax( - chhkHighMax, - chhkConditions.hBars[cIndex].high // - ); - - // - // Min High ... - double chhkHighMin = MathMin( - chhkConditions.cBars[cIndex].high, - chhkConditions.sBars[cIndex].high // - ); - chhkHighMin = MathMin( - chhkHighMin, - chhkConditions.mBars[cIndex].high // - ); - chhkHighMin = MathMin( - chhkHighMin, - chhkConditions.lBars[cIndex].high // - ); - chhkHighMin = MathMin( - chhkHighMin, - chhkConditions.hBars[cIndex].high // - ); - - // - // Max Low ... - double chhkLowMax = MathMax( - chhkConditions.cBars[cIndex].low, - chhkConditions.sBars[cIndex].low // - ); - chhkLowMax = MathMax( - chhkLowMax, - chhkConditions.mBars[cIndex].low // - ); - chhkLowMax = MathMax( - chhkLowMax, - chhkConditions.lBars[cIndex].low // - ); - chhkLowMax = MathMax( - chhkLowMax, - chhkConditions.hBars[cIndex].low // - ); - - // - // Min Low ... - double chhkLowMin = MathMin( - chhkConditions.cBars[cIndex].low, - chhkConditions.sBars[cIndex].low // - ); - chhkLowMin = MathMin( - chhkLowMin, - chhkConditions.mBars[cIndex].low // - ); - chhkLowMin = MathMin( - chhkLowMin, - chhkConditions.lBars[cIndex].low // - ); - chhkLowMin = MathMin( - chhkLowMin, - chhkConditions.hBars[cIndex].low // - ); - - // - double chhkDistanceDiffInPoint = - // - (chhkHighMax - chhkLowMin) / points - // - ; - - // - // XCHSTR ... - // Detect XCHSTR Conditions ... - - // - // Bullish ... - - // - bool isCHSTRHSwitchedToBullish = - // - ( - // - chstrConditions.isHSwitchedToBullish && - chstrConditions.isLBullish && - chstrConditions.isMBullish && - chstrConditions.isSBullish && - chstrConditions.isCBullish - // - ) - // - ; - - // - bool isCHSTRLSwitchedToBullish = - // - ( - // - chstrConditions.isLSwitchedToBullish && - chstrConditions.isHBullish && - chstrConditions.isMBullish && - chstrConditions.isSBullish && - chstrConditions.isCBullish - // - ) - // - ; - - // - bool isCHSTRMSwitchedToBullish = - // - ( - // - chstrConditions.isMSwitchedToBullish && - chstrConditions.isHBullish && - chstrConditions.isLBullish && - chstrConditions.isSBullish && - chstrConditions.isCBullish - // - ) - // - ; - - // - bool isCHSTRSSwitchedToBullish = - // - ( - // - chstrConditions.isSSwitchedToBullish && - chstrConditions.isHBullish && - chstrConditions.isLBullish && - chstrConditions.isMBullish && - chstrConditions.isCBullish - // - ) - // - ; - - // - bool isCHSTRCSwitchedToBullish = - // - ( - // - chstrConditions.isCSwitchedToBullish && - chstrConditions.isHBullish && - chstrConditions.isLBullish && - chstrConditions.isMBullish && - chstrConditions.isSBullish - // - ) - // - ; - - // - // Bullish Conclusion ... - - // - bool isCHSTRBullish = - // - ( - // - chstrConditions.isCBullish && - chstrConditions.isHBullish && - chstrConditions.isLBullish && - chstrConditions.isMBullish && - chstrConditions.isSBullish - // - ) - // - ; - - // - bool isCHMSTRBullish = - // - isCHSTRHSwitchedToBullish - // - || - // - isCHSTRLSwitchedToBullish - // - || - // - isCHSTRMSwitchedToBullish - // - || - // - isCHSTRSSwitchedToBullish - // - || - // - isCHSTRCSwitchedToBullish - // - ; - - // - // Bearish ... - - // - bool isCHSTRHSwitchedToBearish = - // - ( - // - chstrConditions.isHSwitchedToBearish && - chstrConditions.isLBearish && - chstrConditions.isMBearish && - chstrConditions.isSBearish && - chstrConditions.isCBearish - // - ) - // - ; - - // - bool isCHSTRLSwitchedToBearish = - // - ( - // - chstrConditions.isLSwitchedToBearish && - chstrConditions.isHBearish && - chstrConditions.isMBearish && - chstrConditions.isSBearish && - chstrConditions.isCBearish - // - ) - // - ; - - // - bool isCHSTRMSwitchedToBearish = - // - ( - // - chstrConditions.isMSwitchedToBearish && - chstrConditions.isHBearish && - chstrConditions.isLBearish && - chstrConditions.isSBearish && - chstrConditions.isCBearish - // - ) - // - ; - - // - bool isCHSTRSSwitchedToBearish = - // - ( - // - chstrConditions.isSSwitchedToBearish && - chstrConditions.isHBearish && - chstrConditions.isLBearish && - chstrConditions.isMBearish && - chstrConditions.isCBearish - // - ) - // - ; - - // - bool isCHSTRCSwitchedToBearish = - // - ( - // - chstrConditions.isCSwitchedToBearish && - chstrConditions.isHBearish && - chstrConditions.isLBearish && - chstrConditions.isMBearish && - chstrConditions.isSBearish - // - ) - // - ; - - // - // Bearish Conclusion ... - - // - bool isCHSTRBearish = - // - ( - // - chstrConditions.isCBearish && - chstrConditions.isHBearish && - chstrConditions.isLBearish && - chstrConditions.isMBearish && - chstrConditions.isSBearish - // - ) - // - ; - - // - bool isCHSTRSwitchedToBearish = - // - isCHSTRHSwitchedToBearish - // - || - // - isCHSTRLSwitchedToBearish - // - || - // - isCHSTRMSwitchedToBearish - // - || - // - isCHSTRSSwitchedToBearish - // - || - // - isCHSTRCSwitchedToBearish - // - ; - - // - // Max ... - double chstrMax = MathMax( - chstrConditions.cTrend[cIndex], - chstrConditions.sTrend[cIndex] // - ); - chstrMax = MathMax( - chstrMax, - chstrConditions.mTrend[cIndex] // - ); - chstrMax = MathMax( - chstrMax, - chstrConditions.lTrend[cIndex] // - ); - chstrMax = MathMax( - chstrMax, - chstrConditions.hTrend[cIndex] // - ); - - // - // Min ... - double chstrMin = MathMin( - chstrConditions.cTrend[cIndex], - chstrConditions.sTrend[cIndex] // - ); - chstrMin = MathMin( - chstrMin, - chstrConditions.mTrend[cIndex] // - ); - chstrMin = MathMin( - chstrMin, - chstrConditions.lTrend[cIndex] // - ); - chstrMin = MathMin( - chstrMin, - chstrConditions.hTrend[cIndex] // - ); - - // - double chstrDistanceDiffInPoint = - // - (chstrMax - chstrMin) / points - // - ; - - // - // Other Conditions ... - - // - bool isPriceOveralBullish = - // - cBar.low > chhkConditions.hBars[cIndex].high - // - ; - - // - bool isPriceOveralBullishPrev = - // - pBar.low > chhkConditions.hBars[pIndex].high - // - ; - - // - bool isPriceOveralSwitchedToBullish = - // - isPriceOveralBullish && - !isPriceOveralBullishPrev - // - ; - - // - bool isPriceOveralBearish = - // - cBar.high < chhkConditions.hBars[cIndex].low - // - ; - - // - bool isPriceOveralBearishPrev = - // - pBar.high < chhkConditions.hBars[pIndex].low - // - ; - - // - bool isPriceOveralSwitchedToBearish = - // - isPriceOveralBearish && - !isPriceOveralBearishPrev - // - ; - - // - // Signalling ... - // Looking for Signals Based on Conditions ... - - // - // Checking Long Conditions ... - if (isPriceOveralSwitchedToBullish) + if (chhkConditions.isBullishPowerUp) { // hasLong = // hasBullishPower && cBar.IsBullish() && + // hasBullishPattern && hasBullishPressure && - chhkConditions.isHBullish && - chstrConditions.isHBullish && cheConditions.isStrongBullish && - cBar.low > pvConditions.fib2s[cIndex] + cBar.low > chhkMinBullishHigh && + chhkConditions.isBullishPowerUp // && + // chhkConditions.isBullishPowerIncreasing && + // chhkConditions.isBearishPowerDecreasing // ; @@ -1535,25 +596,26 @@ public: if (hasLong) { // + sl = chhkMaxBullishLow; type = POSITION_TYPE_BUY; - sl = pvConditions.fib2s[cIndex]; } } // - // Checking Short Conditions ... - if (isPriceOveralSwitchedToBearish) + if (chhkConditions.isBearishPowerUp) { // hasShort = // hasBearishPower && cBar.IsBearish() && + // hasBearishPattern && hasBearishPressure && - chhkConditions.isHBearish && - chstrConditions.isHBearish && cheConditions.isStrongBearish && - cBar.high < pvConditions.fib4s[cIndex] + cBar.high < chhkMaxBearishLow && + chhkConditions.isBearishPowerUp // && + // chhkConditions.isBearishPowerIncreasing && + // chhkConditions.isBullishPowerDecreasing // ; @@ -1561,11 +623,65 @@ public: if (hasShort) { // + sl = chhkMinBearishHigh; type = POSITION_TYPE_SELL; - sl = pvConditions.fib4s[cIndex]; } } + // + // XCHM ... + + // + // if (chmConditions.isBullishPowerUp) + // { + // // + // hasLong = + // // + // false && + // hasBullishPower && + // cBar.IsBullish() && + // hasBullishPattern && + // cheConditions.isStrongBullish && + // chmConditions.isBullishPowerUp + // // + // ; + + // // + // if (hasLong) + // { + // // + // sl = 0; + // type = POSITION_TYPE_BUY; + // } + // } + + // // + // if (chmConditions.isBearishPowerUp) + // { + // // + // hasShort = + // // + // false && + // hasBearishPower && + // cBar.IsBearish() && + // hasBearishPattern && + // cheConditions.isStrongBearish && + // chmConditions.isBearishPowerUp + // // + // ; + + // // + // if (hasShort) + // { + // // + // sl = 0; + // type = POSITION_TYPE_SELL; + // } + // } + + // + // XCHSTR ... + // result = hasLong || hasShort; if (!result) @@ -1689,6 +805,9 @@ protected: // // Props ... + // + ENUM_TIMEFRAMES mAnalizePeriod; // Important Area Detect Time Frame + // XOHCL support; XOHCL resistance; @@ -1737,6 +856,8 @@ private: // Props ... // + // Install all Helpers and Prepare all + // Configurations for required Indicators ... void PrepareRequirements() { // @@ -1850,8 +971,8 @@ private: chmInputs.showMCSlow = false; chmInputs.showLCFast = false; chmInputs.showLCSlow = false; - chmInputs.showHCFast = true; - chmInputs.showHCSlow = true; + chmInputs.showHCFast = false; + chmInputs.showHCSlow = false; // chmHelper = new XSCXCHMHelper(); @@ -1879,10 +1000,10 @@ private: // chhkInputs.ignoreShadows = true; - chhkInputs.showCurrent = false; - chhkInputs.showShort = false; - chhkInputs.showMedium = false; - chhkInputs.showLong = false; + chhkInputs.showCurrent = true; + chhkInputs.showShort = true; + chhkInputs.showMedium = true; + chhkInputs.showLong = true; chhkInputs.showHind = true; // @@ -1914,7 +1035,7 @@ private: chstrInputs.showShort = false; chstrInputs.showMedium = false; chstrInputs.showLong = false; - chstrInputs.showHind = true; + chstrInputs.showHind = false; // chstrHelper = new XSCXCHSTRHelper();