# Market Conditions we study market and retrieve it's sense in an specific time by Capturing Market Conditions, which it is a Data Model based on Combination of Oscillators and Indicators in our Provider. ## Market Condition Model ```MQ5 // // Represent Market Conditions ... struct XEU5MarketConditions { // // XTM ... bool isXTMPeak; bool isXTMVale; bool isXTMBullish; bool isXTMBearish; bool isXTMNeutural; bool isXTMEndBullish; bool isXTMEndBearish; bool isXTMStartBullish; bool isXTMStartBearish; bool isXTMEndBullishByNeutural; bool isXTMEndBearishByNeutural; bool isXTMStartBullishAfterNeutural; bool isXTMStartBearishAfterNeutural; // // XAMA ... bool isXAMAPeak; bool isXAMAVale; bool isXAMABullish; bool isXAMABearish; bool isXAMANeutural; bool isXAMAEndBullish; bool isXAMAEndBearish; bool isXAMAStartBullish; bool isXAMAStartBearish; bool isXAMAEndBullishByNeutural; bool isXAMAEndBearishByNeutural; bool isXAMAStartBullishAfterNeutural; bool isXAMAStartBearishAfterNeutural; // // XLH ... bool isXLHHHIncreased; bool isXLHHHDecreased; bool isXLHLLIncreased; bool isXLHLLDecreased; bool isXLHLowAttachedLL; bool isXLHHighAttachedHH; bool isXLHHHSameInLength; bool isXLHLLSameInLength; bool isXLHPriceOverSignal; bool isXLHPriceUnderSignal; bool isXLHPriceInSignalRange; bool isXLHPriceCrossedOverSignal; bool isXLHPriceCrossedUnderSignal; // // XTD ... bool isXTDSignalPeak; bool isXTDSignalVale; bool isXTDBullishPeak; bool isXTDBullishVale; bool isXTDBearishPeak; bool isXTDBearishVale; bool isXTDBullOverBear; bool isXTDBullUnderBear; bool isXTDSignalOverBear; bool isXTDSignalUnderBear; bool isXTDBullCrossedOverBear; bool isXTDBullCrossedUnderBear; bool isXTDSignalCrossedOverBear; bool isXTDSignalCrossedUnderBear; // // XFI ... bool isXFIPeak; bool isXFIVale; bool isXFICrossedOverZero; bool isXFIOverZero; bool isXFICrossedUnderZero; bool isXFIUnderZero; // // XTS ... bool isXTSAllSame; bool isXTSCurrentMin; bool isXTSCurrentMax; bool isXTSCurrentOverFarest; bool isXTSCurrentOverNearest; bool isXTSCurrentOverMediest; bool isXTSCurrentUnderFarest; bool isXTSCurrentUnderNearest; bool isXTSCurrentUnderMediest; bool isXTSCurrentCrossedOverFarest; bool isXTSCurrentCrossedOverNearest; bool isXTSCurrentCrossedOverMediest; bool isXTSCurrentCrossedUnderFarest; bool isXTSCurrentCrossedUnderNearest; bool isXTSCurrentCrossedUnderMediest; // // XRSI ... bool isXRSIPeak; bool isXRSIVale; bool isXRSICrossedOverLongExit; bool isXRSICrossedOverLongEntry; bool isXRSICrossedUnderShortExit; bool isXRSICrossedUnderShortEntry; // // XOBD ... bool isXOBDSwingLow; bool isXOBDSwingHigh; // // XCHLH ... // bool isXCHLHSameHHs; bool isXCHLHSameLLs; // bool isXCHLHSCMCHHSame; bool isXCHLHSCMCLLSame; // bool isXCHLHSCLCHHSame; bool isXCHLHSCLCLLSame; // bool isXCHLHMCLCHHSame; bool isXCHLHMCLCLLSame; // bool isXCHLHMCOnTopOfLC; bool isXCHLHMCInBottomOfLC; // // XCHMA ... // bool isXCHMASCOverMax; bool isXCHMASCOverMin; bool isXCHMASCUnderMax; bool isXCHMASCUnderMin; // bool isXCHMASCCrossedOverMax; bool isXCHMASCCrossedUnderMax; bool isXCHMASCCrossedOverMin; bool isXCHMASCCrossedUnderMin; // bool isXCHMASCPeak; bool isXCHMASCVale; bool isXCHMASCTrendsUp; bool isXCHMASCTrendsDown; bool isXCHMASCFastOverSlow; bool isXCHMASCFastUnderSlow; bool isXCHMASCFastCrossedOverSlow; bool isXCHMASCFastCrossedUnderSlow; // bool isXCHMAMCPeak; bool isXCHMAMCVale; bool isXCHMAMCTrendsUp; bool isXCHMAMCTrendsDown; bool isXCHMAMCFastOverSlow; bool isXCHMAMCFastUnderSlow; bool isXCHMAMCFastCrossedOverSlow; bool isXCHMAMCFastCrossedUnderSlow; // bool isXCHMALCPeak; bool isXCHMALCVale; bool isXCHMALCTrendsUp; bool isXCHMALCTrendsDown; bool isXCHMALCFastOverSlow; bool isXCHMALCFastUnderSlow; bool isXCHMALCFastCrossedOverSlow; bool isXCHMALCFastCrossedUnderSlow; }; ``` ## Used Cases for each Strategy we have some sort of Conditions, which i try to describe it here ```MQ5 // // Define a Function based on Strategy and Signal Type ... bool XStrategyHasLongSignal() { // // Define a result Variable to determines there is a Signal // on Specific Time or not ... bool result = false; // // Start Analysing Market based On Conditions ... result = // // Base Condition: // each Strategy must has a Base Conditions, which they are usually common combinations // of Market Properties that must be happens to lookup for signals ... ( // false // ) // && // // Next Step is combine sorts of Conditions which make our choice // so Exact in Market ... ( // false // ) // && // // Exceptions: // there some commonly Exceptions which makes our choice incorrect, // here we are combined knownly Exceptions ... !( // // for Exception we used XLH Conditions as follow ... // // Check Conditions if Price In Signal Range ... (xAU5Conditions.isXLHPriceInSignalRange && // ( // // Next Step is to Check LL and HH Same Style ... // // Check if Both LL and HH Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If LL Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && !xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If HH is Same In Length ... ((xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // || // // Not Same LL or HH in Lenght ... ((!xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // ) // ) // || // // Check Conditions if Price is Under Signal ... ( // ((xAU5Conditions.isXLHPriceUnderSignal || xAU5Conditions.isXLHPriceCrossedUnderSignal) && ( // // Next Step is to Check LL and HH Same Style ... // // Check if Both LL and HH Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If LL Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && !xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If HH is Same In Length ... ((xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // || // // Not Same LL or HH in Lenght ... ((!xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // ) // ) // ) // || // // Check Conditions if Price is Over Signal ... ( // ((xAU5Conditions.isXLHPriceOverSignal || xAU5Conditions.isXLHPriceCrossedOverSignal) && ( // // Next Step is to Check LL and HH Same Style ... // // Check if Both LL and HH Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If LL Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && !xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If HH is Same In Length ... ((xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // || // // Not Same LL or HH in Lenght ... ((!xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // ) // ) // ) // || // // Check Conditions if Price is not has clear state ... ( // ((!xAU5Conditions.isXLHPriceOverSignal && !xAU5Conditions.isXLHPriceUnderSignal && !xAU5Conditions.isXLHPriceInSignalRange && !xAU5Conditions.isXLHPriceCrossedOverSignal && !xAU5Conditions.isXLHPriceCrossedUnderSignal) && ( // // Next Step is to Check LL and HH Same Style ... // // Check if Both LL and HH Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If LL Same In Length ... ((xAU5Conditions.isXLHLLSameInLength && !xAU5Conditions.isXLHHHSameInLength) && // ( false) // ) // || // // Check If HH is Same In Length ... ((xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // || // // Not Same LL or HH in Lenght ... ((!xAU5Conditions.isXLHHHSameInLength && !xAU5Conditions.isXLHLLSameInLength) && // ( false) // ) // ) // ) // ) // ) // ; // // return the result ... return result; } ``` ## Common Cases there are many conditions which contains a combination of one or more condition and they are most commonly used. here i described them and document them for prevent time spending to write them in each used case ... ### Resolve Stop Outs in this step just focused on Peaks and Vales; ```MQ5 // // Peaks ... // Use Trends Down ... // (mConditions.isXCHMASCPeak && (mConditions.isXCHMASCFastOverSlow || mConditions.isXCHMASCFastCrossedOverSlow)) // // (mConditions.isXCHMAMCPeak && (mConditions.isXCHMAMCFastOverSlow || mConditions.isXCHMAMCFastCrossedOverSlow)) // // (mConditions.isXCHMALCPeak && (mConditions.isXCHMALCFastOverSlow || mConditions.isXCHMALCFastCrossedOverSlow)) // // Vales ... // Use Trends Up ... // (mConditions.isXCHMASCVale && (mConditions.isXCHMASCFastUnderSlow || mConditions.isXCHMASCFastCrossedUnderSlow)) // // (mConditions.isXCHMAMCVale && (mConditions.isXCHMAMCFastUnderSlow || mConditions.isXCHMAMCFastCrossedUnderSlow)) // // (mConditions.isXCHMALCVale && (mConditions.isXCHMALCFastUnderSlow || mConditions.isXCHMALCFastCrossedUnderSlow)) ``` ```MQ5 // // Unders ... // ((mConditions.isXCHMASCFastUnderSlow || mConditions.isXCHMASCFastCrossedUnderSlow) && ( // () // ) // ) // // ((mConditions.isXCHMAMCFastUnderSlow || mConditions.isXCHMAMCFastCrossedUnderSlow) && ( // () // ) // ) // // ((mConditions.isXCHMALCFastUnderSlow || mConditions.isXCHMALCFastCrossedUnderSlow) && ( // () // ) // ) // // // Overs ... // ((mConditions.isXCHMASCFastOverSlow || mConditions.isXCHMASCFastCrossedOverSlow) && ( // () // ) // ) // // ((mConditions.isXCHMAMCFastOverSlow || mConditions.isXCHMAMCFastCrossedOverSlow) && ( // () // ) // ) // // ((mConditions.isXCHMALCFastOverSlow || mConditions.isXCHMALCFastCrossedOverSlow) && ( // () // ) // ) // ``` ### Resolve Old Guard Attacks in this step complete conditions; ### Resolve DrawDown Guard Attacks in this step complete conditions; ### XCHMA Max Min Exceptions ```MQ5 // // Exception Cases for XCHMA Min or Max ... ( // // XCHMA MAX ... ( // (mConditions.isXCHMASCOverMax || mConditions.isXCHMASCCrossedOverMax) && (mConditions.isXCHMASCUnderMax || mConditions.isXCHMASCCrossedUnderMax) // ) // || // // XCHMA MIN ... ( // (mConditions.isXCHMASCOverMin || mConditions.isXCHMASCCrossedOverMin) && (mConditions.isXCHMASCUnderMin || mConditions.isXCHMASCCrossedUnderMin) // ) ) ``` ### XCHMA Cycles State #### Short Cycle ```MQ5 // // Check Bullish ... bool isXCHMASCBullish = // (mConditions.isXCHMASCFastOverSlow || mConditions.isXCHMASCFastCrossedOverSlow) // ; // // Check Full Bullish ... bool isXCHMASCFullBullish = // (isXCHMASCBullish && !isXCHMASCTrendsDown) // ; ``` ```MQ5 // // Check Bearish ... bool isXCHMASCBearish = // (mConditions.isXCHMASCFastUnderSlow || mConditions.isXCHMASCFastCrossedUnderSlow) // ; // // Check Full Bearish ... bool isXCHMASCFullBearish = // (isXCHMASCBearish && !isXCHMASCTrendsDown) // ; ``` ```MQ5 // // Check Not Vale and Peak ... bool isXCHMASCNormal = // (!mConditions.isXCHMASCPeak && !mConditions.isXCHMASCVale) // ; ``` #### Medium Cycle ```MQ5 // // Check Bullish ... bool isXCHMAMCBullish = // (mConditions.isXCHMAMCFastOverSlow || mConditions.isXCHMAMCFastCrossedOverSlow) // ; // // Check Full Bullish ... bool isXCHMAMCFullBullish = // (isXCHMAMCBullish && !isXCHMAMCTrendsDown) // ; ``` ```MQ5 // // Check Bearish ... bool isXCHMAMCBearish = // (mConditions.isXCHMAMCFastUnderSlow || mConditions.isXCHMAMCFastCrossedUnderSlow) // ; // // Check Full Bearish ... bool isXCHMAMCFullBearish = // (isXCHMAMCBearish && !isXCHMAMCTrendsDown) // ; ``` ```MQ5 // // Check Not Vale and Peak ... bool isXCHMAMCNormal = // (!mConditions.isXCHMAMCPeak && !mConditions.isXCHMAMCVale) // ; ``` #### Long Cycle ```MQ5 // // Check Bullish ... bool isXCHMALCBullish = // (mConditions.isXCHMALCFastOverSlow || mConditions.isXCHMALCFastCrossedOverSlow) // ; // // Check Full Bullish ... bool isXCHMALCFullBullish = // (isXCHMALCBullish && !isXCHMALCTrendsDown) // ; ``` ```MQ5 // // Check Bearish ... bool isXCHMALCBearish = // (mConditions.isXCHMALCFastUnderSlow || mConditions.isXCHMALCFastCrossedUnderSlow) // ; // // Check Full Bearish ... bool isXCHMALCFullBearish = // (isXCHMALCBearish && !isXCHMALCTrendsDown) // ; ``` ```MQ5 // // Check Not Vale and Peak ... bool isXCHMALCNormal = // (!mConditions.isXCHMALCPeak && !mConditions.isXCHMALCVale) // ; ``` ### XCHMA Bullish Trend ```MQ5 // // XCHMA Bullish Trend ... bool isXCHMABullish = // ( // // All of Cycles Bullish ... (isXCHMASCBullish && isXCHMAMCBullish && isXCHMALCBullish) // || // // Two of Cycles Bullish ... ( // (isXCHMASCBullish && isXCHMAMCBullish) // || // (isXCHMASCBullish && isXCHMALCBullish) // || // (isXCHMAMCBullish && isXCHMALCBullish) // ) ) // ; // // XCHMA Full Bullish Trend ... bool isXCHMAFullBullish = // ( // // All of Cycles Fully Bullish ... (isXCHMASCFullBullish && isXCHMAMCFullBullish && isXCHMALCFullBullish) // || // // Two Of Cycles Fully Bullish ... ( // (isXCHMASCFullBullish && isXCHMAMCFullBullish) // || // (isXCHMASCFullBullish && isXCHMALCFullBullish) // || // (isXCHMAMCFullBullish && isXCHMALCFullBullish) // ) // ) // ; ``` ### XCHMA Bearish Trend ```MQ5 // // XCHMA Bearish Trend ... bool isXCHMABearish = // ( // // All of Cycles Bearish ... (isXCHMASCBearish && isXCHMAMCBearish && isXCHMALCBearish) // || // // Two of Cycles Bearish ... ( // (isXCHMASCBearish && isXCHMAMCBearish) // || // (isXCHMASCBearish && isXCHMALCBearish) // || // (isXCHMAMCBearish && isXCHMALCBearish) // ) ) // ; // // XCHMA Full Bearish Trend ... bool isXCHMAFullBearish = // ( // // All of Cycles Fully Bearish ... (isXCHMASCFullBearish && isXCHMAMCFullBearish && isXCHMALCFullBearish) // || // // Two Of Cycles Fully Bearish ... ( // (isXCHMASCFullBearish && isXCHMAMCFullBearish) // || // (isXCHMASCFullBearish && isXCHMALCFullBearish) // || // (isXCHMAMCFullBearish && isXCHMALCFullBearish) // ) // ) // ; ```