// // LONG ... // bool isSoImportantLong = iConditions.demandZone.IsValid() && iConditions.bullishFVG.IsValid() && iConditions.bullishOrderBlock.IsValid(); // bool isImportantLong = iConditions.demandZone.IsValid() && (iConditions.bullishFVG.IsValid() || iConditions.bullishOrderBlock.IsValid()); // bool isRiskyLong = iConditions.demandZone.IsValid() && (iConditions.bullishFVG.IsValid() || iConditions.bullishOrderBlock.IsValid()); // bool hasLongConditions = isSoImportantLong || isImportantLong || isRiskyLong; // if (hasLongConditions) { // // Find Trigger for Input Positions ... // - [] Breakout; // - [] Engulf; // - [] Rejection Bar; // - [] Momentum Bar; // type = POSITION_TYPE_BUY; entry = GetEntry(mSymbol, type); sl = iConditions.demandZone.lower - (10 * points); risk = entry - sl; reward = risk * r2r; tp = entry + reward; // bool isSpreadOK = IsSpreadPass(); // // Price Must Breakout the Upper of Demand ... bool isBreakout = // cBar.IsBullish() && zBar.low > conditions.demandZone.upper && cBar.high > conditions.demandZone.upper && cBar.close > conditions.demandZone.upper && (cBar.open < conditions.demandZone.upper || cBar.low < conditions.demandZone.upper) // ; // // Price Must have Bullish Trend and Momentum on Ticks ... bool isTicksBullishMomentum = IsTicksBullish() && IsTicksHasMomentum(); // // Detect momentum / Swing Low / Rejection Bars ... bool hasMomentumBars = false; int swingLowsCount = ArraySize(_5MState.swingLows); int momentumBarsCount = ArraySize(_5MState.momentumBars); int rejectionBarsCount = ArraySize(_5MState.rejectionBars); if (IsValidSize(swingLowsCount) || IsValidSize(momentumBarsCount) || IsValidSize(rejectionBarsCount)) { // int foundedPOIs = 0; // // Check Swing Lows ... if (IsValidSize(swingLowsCount)) { // for (int i = 0; i < swingLowsCount; i++) { // XOHCL iBar = _5MState.swingLows[i]; // if (iBar.time > iConditions.demandZone.from) { // if (iBar.low < entry) { // foundedPOIs++; DrawSwingBar(iBar, true); } } } } // // Check Momentum Bars ... if (IsValidSize(momentumBarsCount)) { // for (int i = 0; i < momentumBarsCount; i++) { // XOHCL iBar = _5MState.momentumBars[i]; // if (iBar.time > iConditions.demandZone.from) { // if (iBar.IsBullish() && iBar.low < entry) { // foundedPOIs++; DrawMomentumBar(iBar); } } } } // // Check Rejection Bars ... if (IsValidSize(rejectionBarsCount)) { // for (int i = 0; i < rejectionBarsCount; i++) { // XOHCL iBar = _5MState.rejectionBars[i]; // if (iBar.time > iConditions.demandZone.from) { // if (iBar.low < entry && iBar.GetLowShadow() > iBar.GetHighShadow()) { // foundedPOIs++; DrawRejectionBar(iBar); } } } } // pushers = foundedPOIs; hasMomentumBars = foundedPOIs > 0; } // hasLongConditions = hasLongConditions && // isSpreadOK && // isBreakout && isTicksBullishMomentum && // hasMomentumBars // ; // if (hasLongConditions) { // removeIDX = i; conditions = iConditions; result = hasLongConditions; // break; } } // // SHORT ... // bool isSoImportantShort = iConditions.supplyZone.IsValid() && iConditions.bearishFVG.IsValid() && iConditions.bearishOrderBlock.IsValid(); // bool isImportantShort = iConditions.supplyZone.IsValid() && (iConditions.bearishFVG.IsValid() || iConditions.bearishOrderBlock.IsValid()); // bool isRiskyShort = iConditions.supplyZone.IsValid() && (!iConditions.bearishFVG.IsValid() && !iConditions.bearishOrderBlock.IsValid()); // bool hasShortConditions = isSoImportantShort || isImportantShort || isRiskyShort; // if (hasShortConditions) { // // Find Trigger for Input Positions ... // - [] Breakout; // - [] Engulf; // - [] Rejection Bar; // - [] Momentum Bar; // // // removeIDX = i; // conditions = iConditions; // // DrawConditions(iConditions); // Print("hasShortConditions"); break; } ////////////////////////////////////////////////////////////////////////////// // XZone iBearishOrderBlock; XZone iBearishFVG; // bool isPassed = false; int orderBlocksCount = ArraySize(orderBlocksState.bearishOrderBlocks); isPassed = IsValidSize(orderBlocksCount); if (!isPassed) { continue; } // // Find Related Order Block ... isPassed = false; for (int j = 0; j < orderBlocksCount; j++) { // XZone jOrderBlock = orderBlocksState.bearishOrderBlocks[j]; // bool isOrderBlockInsideZone = IsSupplyZoneOrderBlock( iSupplyZone, jOrderBlock // ); if (isOrderBlockInsideZone) { // isPassed = true; iBearishOrderBlock = jOrderBlock; conditions.bearishOrderBlock = jOrderBlock; break; } } if (!isPassed) { continue; } // isPassed = false; int fairValueGapsCount = ArraySize(fvgsState.bearishFVGs); isPassed = IsValidSize(fairValueGapsCount); if (!isPassed) { continue; } // // Find Related Fair Value Gaps ... isPassed = false; for (int j = 0; j < fairValueGapsCount; j++) { // XZone jFVG = fvgsState.bearishFVGs[j]; // bool isBelongs = IsBearishOrderBlockFVG( iBearishOrderBlock, jFVG // ); if (isBelongs) { // iBearishFVG = jFVG; conditions.bearishFVG = jFVG; // isPassed = true; break; } } // if (!isPassed) // { // continue; // } // // // if (isPassed) // { // // // DrawSupplyZone(iSupplyZone); // DrawBearishOrderBlock(iBearishOrderBlock); // DrawBearishFVG(iBearishFVG); // } ////////////////////////////////////////////// // XZone iBullishOrderBlock; XZone iBullishFVG; // bool isPassed = false; int orderBlocksCount = ArraySize(orderBlocksState.bullishOrderBlocks); isPassed = IsValidSize(orderBlocksCount); if (!isPassed) { continue; } // // Find Related Order Block ... isPassed = false; for (int j = 0; j < orderBlocksCount; j++) { // XZone jOrderBlock = orderBlocksState.bullishOrderBlocks[j]; // bool isOrderBlockInsideZone = IsDemandZoneOrderBlock( iDemandZone, jOrderBlock // ); if (isOrderBlockInsideZone) { // isPassed = true; iBullishOrderBlock = jOrderBlock; conditions.bullishOrderBlock = jOrderBlock; break; } } if (!isPassed) { continue; } // isPassed = false; int fairValueGapsCount = ArraySize(fvgsState.bullishFVGs); isPassed = IsValidSize(fairValueGapsCount); if (!isPassed) { continue; } // // Find Related Fair Value Gaps ... isPassed = false; for (int j = 0; j < fairValueGapsCount; j++) { // XZone jFVG = fvgsState.bullishFVGs[j]; // bool isBelongs = IsBullishOrderBlockFVG( iBullishOrderBlock, jFVG // ); if (isBelongs) { // iBullishFVG = jFVG; conditions.bullishFVG = jFVG; // isPassed = true; break; } } // if (!isPassed) // { // continue; // } // // // if (isPassed) // { // // // DrawDemandZone(iDemandZone); // DrawBullishOrderBlock(iBullishOrderBlock); // DrawBullishFVG(iBullishFVG); // } ////////////////////////////////////////////// // // Tools Functions ... /** * Check an Order Block belongs to a Supply Zone ... * * @param supply: XZone instance ... * @param orderBlock: XZone instance ... * * @return ( bool ) */ bool IsSupplyZoneOrderBlock( XZone &supply, XZone &orderBlock // ) { // bool result = false; // result = supply.IsValid() && orderBlock.IsValid(); if (!result) { return result; } // result = orderBlock.upper <= supply.upper; // return result; } /** * Check an Order Block belongs to a Demand Zone ... * * @param demand: XZone instance ... * @param orderBlock: XZone instance ... * * @return ( bool ) */ bool IsDemandZoneOrderBlock( XZone &demand, XZone &orderBlock // ) { // bool result = false; // result = demand.IsValid() && orderBlock.IsValid(); if (!result) { return result; } // result = orderBlock.lower >= demand.lower; // return result; } /** * Check a Bearish FVG belongs to a Bearish Order Block ... * * @param orderBlock: XZone instance ... * @param fvg: XZone instance ... * * @return ( bool ) */ bool IsBearishOrderBlockFVG( XZone &orderBlock, XZone &fvg // ) { // bool result = false; // result = fvg.IsValid() && orderBlock.IsValid(); if (!result) { return result; } // result = fvg.upper <= orderBlock.upper && fvg.upper > orderBlock.lower; // return result; } /** * Check a Bullish FVG belongs to a Bullish Order Block ... * * @param orderBlock: XZone instance ... * @param fvg: XZone instance ... * * @return ( bool ) */ bool IsBullishOrderBlockFVG( XZone &orderBlock, XZone &fvg // ) { // bool result = false; // result = fvg.IsValid() && orderBlock.IsValid(); if (!result) { return result; } // result = fvg.lower >= orderBlock.lower && fvg.lower < orderBlock.upper; // return result; }