diff --git a/X121SMCEA/Signals/x-121.smc.xobs.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xobs.signal.lib.mq5 index 25f50c33..55c3db86 100644 --- a/X121SMCEA/Signals/x-121.smc.xobs.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xobs.signal.lib.mq5 @@ -680,6 +680,79 @@ bool DetectX121SMCXOBSSignalSetup( UpdateTo(conditions.validBullishOBs); UpdateTo(conditions.validBearishOBs); + // + // Lookup for new Order Block ... + // for Clearing Conditions .... + + // + XCOrderBlock *newBullishOB = NULL; + bool hasNewBullishOB = Contains( + X_BULLISH_ORDERBLOCK_DETECTED, + consolidationPoiEvents // + ); + if (hasNewBullishOB) + { + // + int hasOBs = consolidationState.HasBullishOrderBlocks(); + int count = consolidationState.CountBullishOrderBlocks(); + if (hasOBs) + { + // + newBullishOB = consolidationState.bullishOrderBlocks[count - 1]; + } + + // + hasNewBullishOB = newBullishOB != NULL && + newBullishOB.IsValid(); + } + + // + XCOrderBlock *newBearishOB = NULL; + bool hasNewBearishOB = Contains( + X_BEARISH_ORDERBLOCK_DETECTED, + consolidationPoiEvents // + ); + if (hasNewBearishOB) + { + // + int hasOBs = consolidationState.HasBearishOrderBlocks(); + int count = consolidationState.CountBearishOrderBlocks(); + if (hasOBs) + { + newBearishOB = consolidationState.bearishOrderBlocks[count - 1]; + } + + // + hasNewBearishOB = newBearishOB != NULL && + newBearishOB.IsValid(); + } + + // + bool isNewOBDetected = hasNewBullishOB || + hasNewBearishOB; + if (isNewOBDetected) + { + // + if (hasNewBullishOB) + { + // + DrawX121SMCXOBSOrderBlock( + newBullishOB, + consolidationCycleHelper.mPOIDrawer // + ); + } + + // + if (hasNewBearishOB) + { + // + DrawX121SMCXOBSOrderBlock( + newBearishOB, + consolidationCycleHelper.mPOIDrawer // + ); + } + } + // // Extract Youngest Order Blocks ... @@ -1032,66 +1105,10 @@ bool DetectX121SMCXOBSSignalSetup( } // - // Draw ... - - // - mX121SMCXOBSObjects.Clear(); - - // - // Youngests ... - - // - if (hasYoungestBullishOB) - { - // - DrawX121SMCXOBSOrderBlock( - conditions.youngestBullishOB, - visionCycleHelper.mPOIDrawer // - ); - } - - // - if (hasYoungestBearishOB) - { - // - DrawX121SMCXOBSOrderBlock( - conditions.youngestBearishOB, - visionCycleHelper.mPOIDrawer // - ); - } - - // - // Valids ... - if (hasValidOBs) - { - // - for (int i = 0; i < validOBsCount; i++) - { - // - DrawX121SMCXOBSOrderBlock( - validOBs[i], - visionCycleHelper.mPOIDrawer // - ); - } - } - - // - // Trend Line ... - if (hasSwings) - { - // - XCTrendObject *iObj; - bool isCreated = visionCycleHelper - .mPOIDrawer - .CreateTrend( - conditions.swings, - iObj // - ); - if (isCreated) - { - mX121SMCXOBSObjects.Add(iObj); - } - } + DrawX121SMCXOBSConditions( + conditions, + visionCycleHelper.mPOIDrawer // + ); // return false; @@ -1726,3 +1743,115 @@ void DrawX121SMCXOBSOrderBlock( } // +void DrawX121SMCXOBSConditions( + X121SMCStrategyXOBSSignalConditions &conditions, + XCPOIDrawer *drawer, + bool forceClean = true // +) +{ + // + if (drawer == NULL) + { + return; + } + + // + if (forceClean) + { + mX121SMCXOBSObjects.Clear(); + } + + // + // Draw ... + + // + // Youngests ... + + // + bool hasYoungestBullishOB = conditions.HasYoungestBullishOB(); + if (hasYoungestBullishOB) + { + // + DrawX121SMCXOBSOrderBlock( + conditions.youngestBullishOB, + drawer // + ); + } + + // + bool hasYoungestBearishOB = conditions.HasYoungestBearishOB(); + if (hasYoungestBearishOB) + { + // + DrawX121SMCXOBSOrderBlock( + conditions.youngestBearishOB, + drawer // + ); + } + + // + // Order Flow ... + ENUM_X_DIRECTION orderFlowDir; + bool hasOrderFlow = conditions.HasOrderFlow(orderFlowDir); + bool hasBullishOrderFlow = IsBullish(orderFlowDir); + if (hasOrderFlow) + { + // + XCOrderBlock *obs[]; + if (hasBullishOrderFlow) + { + // + Copy( + conditions.validBullishOBs, + obs // + ); + } + else + { + // + Copy( + conditions.validBearishOBs, + obs // + ); + } + + // + int count = ArraySize(obs); + bool hasOBs = IsValidSize(obs); + if (hasOBs) + { + // + for (int i = 0; i < count; i++) + { + // + DrawX121SMCXOBSOrderBlock( + obs[i], + drawer // + ); + } + } + + // + Clean(obs); + } + + // + // Trend Line ... + bool hasSwings = conditions.HasSwings(); + if (hasSwings) + { + // + XCTrendObject *iObj; + bool isCreated = drawer + .CreateTrend( + conditions.swings, + iObj // + ); + if (isCreated) + { + mX121SMCXOBSObjects.Add(iObj); + } + } +} + +//