Fix Order Blocks ...

This commit is contained in:
2025-03-17 23:02:12 +03:30
parent 48c78e1256
commit 3f26a75e2e
4 changed files with 146 additions and 56 deletions
+101 -4
View File
@@ -1336,6 +1336,24 @@ class XCBarAnalyser : public XCBase
return result;
}
//
XOHCL sBar;
if (bar.Index() == 0)
{
//
result = bar.GetPreviousBar(sBar);
if (!result)
{
//
sBar.Clean();
return result;
}
}
else
{
sBar = bar;
}
//
// First Step We Have to Check Same Bars ...
int spikeRootIDX = -1;
@@ -1365,7 +1383,7 @@ class XCBarAnalyser : public XCBase
spikeRootIDX, // Spike Root Index ...
X_PRICE_CLOSE, // Price Type ...
true, // Force Body ...
1.0, // Range Extend Multiplier ...
1.5, // Range Extend Multiplier ...
sameBars //
);
result =
@@ -1380,12 +1398,69 @@ class XCBarAnalyser : public XCBase
}
//
// Select Order Block Bar ...
result = ob.Init(
// Select OB Candidate Bars ...
XOHCL sameBar;
XOHCL rootBar;
XOHCL rootPBar;
result = sameBar.Init(
bar.symbol,
bar.period,
sameBarsIndex + 1 //
);
if (!result)
{
//
sBar.Clean();
sameBar.Clean();
return result;
}
result = rootBar.Init(
bar.symbol,
bar.period,
spikeRootIDX //
);
if (!result)
{
//
sBar.Clean();
rootBar.Clean();
sameBar.Clean();
return result;
}
result = rootBar.GetPreviousBar(rootPBar);
if (!result)
{
//
sBar.Clean();
rootBar.Clean();
sameBar.Clean();
rootPBar.Clean();
return result;
}
//
// Select ob Bar ...
if (rootBar.GetDirection() == Opposit(dir))
{
ob = rootBar;
}
else if (rootPBar.GetDirection() == Opposit(dir))
{
ob = rootPBar;
}
else if (sameBar.GetDirection() == Opposit(dir))
{
ob = sameBar;
}
else
{
ob.Clean();
}
//
// Select Order Block Bar ...
result = ob.IsValid();
ENUM_X_DIRECTION obDir = ob.GetDirection();
result =
result &&
@@ -1393,7 +1468,12 @@ class XCBarAnalyser : public XCBase
if (!result)
{
//
ob.Clean();
sBar.Clean();
rootBar.Clean();
sameBar.Clean();
rootPBar.Clean();
//
return result;
}
@@ -1432,7 +1512,15 @@ class XCBarAnalyser : public XCBase
//
if (!result)
{
//
ob.Clean();
sBar.Clean();
rootBar.Clean();
sameBar.Clean();
rootPBar.Clean();
//
return result;
}
}
@@ -1463,6 +1551,15 @@ class XCBarAnalyser : public XCBase
fromBar.Clean();
}
//
// Cleanup Resource ...
//
sBar.Clean();
rootBar.Clean();
sameBar.Clean();
rootPBar.Clean();
//
return result;
}
+33 -33
View File
@@ -717,7 +717,7 @@ class XCPOIDetector : public XCBaseAlert
OrderBlockSameBars(3);
OrderBlockForceSpike(true);
OrderBlockForceFairValueGap(true);
OrderBlockForceSupportResistance(true);
OrderBlockForceSupportResistance(false);
}
/**
@@ -846,31 +846,31 @@ class XCPOIDetector : public XCBaseAlert
//
// Supply ...
// DetectSupplyZone(
// iBar,
// iEvent //
// );
DetectSupplyZone(
iBar,
iEvent //
);
//
// Demand ...
// DetectDemandZone(
// iBar,
// iEvent //
// );
DetectDemandZone(
iBar,
iEvent //
);
//
// FairValueGap ...
// DetectFairValueGap(
// iBar,
// iEvent //
// );
DetectFairValueGap(
iBar,
iEvent //
);
//
// OrderBlock ...
// DetectOrderBlock(
// iBar,
// iEvent //
// );
DetectOrderBlock(
iBar,
iEvent //
);
//
canContinue =
@@ -1081,10 +1081,10 @@ class XCPOIDetector : public XCBaseAlert
//
// Supply ...
// has = DetectSupplyZone(
// iBar,
// iEvent //
// );
has = DetectSupplyZone(
iBar,
iEvent //
);
if (has)
{
//
@@ -1096,10 +1096,10 @@ class XCPOIDetector : public XCBaseAlert
//
// Demand ...
// has = DetectDemandZone(
// iBar,
// iEvent //
// );
has = DetectDemandZone(
iBar,
iEvent //
);
if (has)
{
//
@@ -1111,10 +1111,10 @@ class XCPOIDetector : public XCBaseAlert
//
// FairValueGap ...
// has = DetectFairValueGap(
// iBar,
// iEvent //
// );
has = DetectFairValueGap(
iBar,
iEvent //
);
if (has)
{
//
@@ -1126,10 +1126,10 @@ class XCPOIDetector : public XCBaseAlert
//
// OrderBlock ...
// has = DetectOrderBlock(
// iBar,
// iEvent //
// );
has = DetectOrderBlock(
iBar,
iEvent //
);
if (has)
{
//
+4 -11
View File
@@ -344,37 +344,30 @@ void DetectPOIState()
// Bullish ...
showBullishPOIs && true, // SwingLows
showBullishPOIs && true, // DemandZones
showBullishPOIs && false, // SupportZones
showBullishPOIs && true, // SupportZones
showBullishPOIs && true, // BullishSharps
showBullishPOIs && true, // BullishSpikes
showBullishPOIs && true, // BullishPullbacks
showBullishPOIs && true, // BullishMomentums
showBullishPOIs && true, // BullishRejections
showBullishPOIs && true, // BullishOrderBlocks
showBullishPOIs && false, // BullishOrderBlocks
showBullishPOIs && true, // BullishFairValueGaps
showBullishPOIs && true, // BullishConsolidationZones
//
// Bearish ...
showBearishPOIs && true, // SwingHighs
showBearishPOIs && true, // SupplyZones
showBearishPOIs && false, // ResistanceZones
showBearishPOIs && true, // ResistanceZones
showBearishPOIs && true, // BearishSharps
showBearishPOIs && true, // BearishSpikes
showBearishPOIs && true, // BearishPullbacks
showBearishPOIs && true, // BearishMomentums
showBearishPOIs && true, // BearishRejections
showBearishPOIs && true, // BearishOrderBlocks
showBearishPOIs && false, // BearishOrderBlocks
showBearishPOIs && true, // BearishFairValueGaps
showBearishPOIs && true // BearishConsolidationZones
);
//
if (poiEventNotifier.hasNewSupportZone ||
poiEventNotifier.hasNewResistanceZone)
{
Print("Support/Resistance ...");
}
//
Clean(poiEvents);
poiEventNotifier.Clean();
+8 -8
View File
@@ -680,8 +680,8 @@ struct XPOIStateEvents
//
// Supply/Demand (s) ...
bool hasSupplyZone;
bool hasDemandZone;
bool hasNewSupplyZone;
bool hasNewDemandZone;
//
// Fair Value Gaps ...
@@ -748,8 +748,8 @@ struct XPOIStateEvents
hasNewResistanceZone = false;
//
hasSupplyZone = false;
hasDemandZone = false;
hasNewSupplyZone = false;
hasNewDemandZone = false;
//
hasNewFairValueGap = false;
@@ -812,8 +812,8 @@ struct XPOIStateEvents
hasNewResistanceZone = HasNewResistanceZone(events);
//
hasSupplyZone = HasSupplyZone(events);
hasDemandZone = HasDemandZone(events);
hasNewSupplyZone = HasNewSupplyZone(events);
hasNewDemandZone = HasNewDemandZone(events);
//
hasNewFairValueGap = HasNewFairValueGap(events);
@@ -4981,7 +4981,7 @@ bool HasNewResistanceZone(ENUM_XPOI_EVENTS &events[])
// Supply / Demand Zones ...
//
bool HasSupplyZone(ENUM_XPOI_EVENTS &events[])
bool HasNewSupplyZone(ENUM_XPOI_EVENTS &events[])
{
return Contains(
X_SUPPLY_ZONE_DETECTED,
@@ -4990,7 +4990,7 @@ bool HasSupplyZone(ENUM_XPOI_EVENTS &events[])
}
//
bool HasDemandZone(ENUM_XPOI_EVENTS &events[])
bool HasNewDemandZone(ENUM_XPOI_EVENTS &events[])
{
return Contains(
X_DEMAND_ZONE_DETECTED,