This commit is contained in:
2025-10-25 21:38:17 +03:30
parent 5dbf2d52dc
commit de338d8916
@@ -284,6 +284,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
{
//
// Configure ...
drawLeg = true;
drawOrderFlow = true;
structureConfig.Default();
structureDrawConfig.Default();
}
@@ -344,8 +346,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Manage Leg ...
ManageLeg(iBar);
// Manage ...
Manage(iBar);
//
// Strategy X ...
@@ -514,6 +516,49 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
return result;
}
//
// Protected ...
protected:
//
//
void Manage(XOHCL &bar)
{
//
bool has = bar.IsValid();
if (!has)
{
return;
}
//
XOHCL pBar;
XOHCL p2Bar;
XOHCL p3Bar;
has = bar.GetPreviousBar(pBar);
has = has &&
pBar.GetPreviousBar(p2Bar);
has = has &&
p2Bar.GetPreviousBar(p3Bar);
if (!has)
{
//
pBar.Clean();
p2Bar.Clean();
p3Bar.Clean();
}
//
ManageLeg(bar);
ManageOrderFlow(p3Bar);
//
// Cleanup ...
pBar.Clean();
p2Bar.Clean();
p3Bar.Clean();
}
//
// Private ...
private:
@@ -521,7 +566,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// Props ...
//
XLeg leg; // Exists Leg ...
// Leg ...
XLeg leg; // Exists Leg ...
bool drawLeg; // Draw Leg ...
//
bool HasLeg()
@@ -536,7 +584,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
bool result = false;
//
result = HasLeg() && bar.IsValid();
result = HasLeg() &&
bar.IsValid();
if (!result)
{
return result;
@@ -557,6 +606,12 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
void DrawLeg()
{
//
if (!drawLeg)
{
return;
}
//
if (!HasLeg())
{
@@ -601,6 +656,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
void ManageLeg(XOHCL &bar)
{
//
// Validate Exists ...
if (HasLeg())
{
//
@@ -613,14 +669,14 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Detect New Leg ...
// Detect New ...
if (!HasLeg())
{
poiDetector.IsLegPattern(bar, leg);
}
//
// Update Exists Leg ...
// Update Exists ...
if (HasLeg())
{
//
@@ -632,6 +688,185 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
}
//
// Order Flow ...
//
bool drawOrderFlow;
XBoxZone orderFlow[];
ENUM_X_DIRECTION orderFlowDir;
//
bool HasOrderFlow()
{
//
return HasChild(orderFlow) &&
HasDirection(orderFlowDir);
}
bool HasBullishOrderFlow()
{
return HasOrderFlow() &&
IsXBullish(orderFlowDir);
}
bool HasBearishOrderFlow()
{
return HasOrderFlow() &&
IsXBearish(orderFlowDir);
}
bool GetOrderFlowBoundary(
double &upper,
double &lower //
)
{
//
bool result = false;
//
// Prepare ...
upper = EMPTY_VALUE;
lower = EMPTY_VALUE;
//
// Validate ...
result = HasOrderFlow();
if (!result)
{
return result;
}
//
int idx = -1;
//
// Upper ...
idx = GetHighest(orderFlow);
if (IsValidIndex(idx))
{
upper = orderFlow[idx].upper;
}
//
// Lower ...
idx = GetLowest(orderFlow);
if (IsValidIndex(idx))
{
lower = orderFlow[idx].lower;
}
//
result = NotEmptyZero(upper) &&
NotEmptyZero(lower) &&
upper > lower;
//
// Cleanup ...
if (!result)
{
//
upper = EMPTY_VALUE;
lower = EMPTY_VALUE;
}
//
return result;
}
bool ValidateOrderFlow(XOHCL &bar)
{
//
bool result = false;
//
// Validate ...
result = bar.IsValid() &&
HasOrderFlow();
if (!result)
{
return result;
}
//
double upper = EMPTY_VALUE;
double lower = EMPTY_VALUE;
result = GetOrderFlowBoundary(upper, lower);
result = result &&
HasBullishOrderFlow()
? bar.low > lower
: bar.high < upper;
//
return result;
}
void DrawOrderFlow()
{
//
if (!drawOrderFlow || !HasOrderFlow())
{
return;
}
//
poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
}
void ManageOrderFlow(XOHCL &bar)
{
//
// Validate Exists ...
if (HasOrderFlow())
{
//
if (!ValidateOrderFlow(bar))
{
//
// Invalidate OrderFlow ...
XClean(orderFlow);
orderFlowDir = X_DIRECTION_NONE;
}
}
//
// Detect New ...
if (!HasOrderFlow())
{
//
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
// patternConfig.Default();
// patternConfig.supportAndResistanceLoopbackLength = 21;
// patternConfig.supportAndResistanceValidationLength = 7;
//
poiDetector.HasOrderFlow(
bar,
orderFlowDir,
orderFlow,
structureConfig.orderFlowValidation,
structureConfig.orderFlowUseOB,
structureConfig.orderFlowUseFVG,
structureConfig.orderFlowUseSupportAndResistance,
patternConfig.supportAndResistanceLoopbackLength,
patternConfig.supportAndResistanceValidationLength,
structureConfig.loopback //
);
}
//
// Update Exists ...
if (HasOrderFlow())
{
//
// Update to Times ...
UpdateToTime(orderFlow, TimeCurrent());
//
DrawOrderFlow();
}
}
//
// Implementing Strategies ...
@@ -690,6 +925,18 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// Analyse Market Strucutre ...
XFIMAMarketStructure marketStructure;
//
// Check Market ...
result = HasLeg() &&
HasOrderFlow() &&
orderFlowDir == leg.dir;
if (result)
{
//
result = false;
DebugBreak();
}
//
// Signaller 1 ...
if (!result && useSignaller1)
@@ -1850,27 +2097,21 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
// Retrieve pBar Patterns ...
XPatternAnalysis pBarPatterns;
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
// patternConfig.Default();
// patternConfig.supportAndResistanceLoopbackLength = 21;
// patternConfig.supportAndResistanceValidationLength = 7;
//
poiDetector.AnalyseBarPatterns(
pBar,
pBarPatterns,
structureConfig.barsAnalysisConfig //
patternConfig //
);
//
// Detecting OrderFlow ...
XBoxZone orderFlow[];
bool hasOrderFlow = poiDetector.HasOrderFlow(
p3Bar,
dir,
orderFlow,
structureConfig.orderFlowValidation,
structureConfig.orderFlowUseOB,
structureConfig.orderFlowUseFVG,
structureConfig.orderFlowUseSupportAndResistance,
structureConfig.barsAnalysisConfig.supportAndResistanceLoopbackLength,
structureConfig.barsAnalysisConfig.supportAndResistanceValidationLength,
structureConfig.loopback //
);
bool hasOrderFlow = HasOrderFlow();
//
double atrBandUpper = EMPTY_VALUE;
@@ -1916,6 +2157,15 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
(isBullish
? p2Bar.low < orderFlowUpper
: p2Bar.high > orderFlowLower);
//
// Reset Flags ...
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
@@ -1971,6 +2221,15 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
// Summarize Result ...
result = isBullish || isBearish;
//
// Reset Flags ...
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
@@ -1999,6 +2258,15 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
// Summarize Result ...
result = isBullish || isBearish;
//
// Reset Flags ...
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
@@ -2016,9 +2284,21 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
(isBullish
? pBar.close > atrBandLower
: pBar.close < atrBandUpper);
//
// Reset Flags ...
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
result = false;
isBullish = false;
isBearish = false;
if (result)
{
// //
@@ -2055,61 +2335,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// //
// Print("OrderFlow ...");
// DebugBreak();
}
// //
// XLeg leg;
// result = poiDetector.IsLegPattern(pBar, leg);
// if (result)
// {
// //
// // Update to Times ...
// leg.UpdateTimes(bar.time);
// //
// // Draw Leg Box ...
// XBoxZone legZone;
// leg.ToBox(legZone);
// if (legZone.IsValid())
// {
// poiDrawer.DrawZone(legZone, structureDrawConfig.drawConfig);
// }
// //
// // Draw Legs Other Stufs ...
// //
// // FVGs ...
// poiDrawer.DrawZones(leg.bullishFVGs, structureDrawConfig.drawConfig);
// poiDrawer.DrawZones(leg.bearishFVGs, structureDrawConfig.drawConfig);
// //
// // Support and Resistances ...
// poiDrawer.DrawZones(leg.supports, structureDrawConfig.drawConfig);
// poiDrawer.DrawZones(leg.resistances, structureDrawConfig.drawConfig);
// //
// // Patterns ...
// poiDrawer.DrawPatternAnalysises(leg.patterns, structureDrawConfig.barAnalysisDrawConfig);
// //
// Print("Leg Pattern Detected ...");
// }
//
isBullish =
//
false
//
;
//
isBearish =
//
false
//
;
//
// Validate ...
result = isBullish ||
@@ -2139,6 +2367,12 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
X_BAR_PATTERN_PINNED //
);
//
// Refine Zone ...
zone.to = bar.time;
zone.upper = MathMax(zone.upper, atrBandMiddle);
zone.lower = MathMin(zone.lower, atrBandMiddle);
//
// Manage Stops ...
if (result)