Add support for Detect and Draw Market Structure ...

This commit is contained in:
2025-10-09 04:22:44 +03:30
parent 430d822d3e
commit fc318b5c19
8 changed files with 2199 additions and 2174 deletions
+1 -68
View File
@@ -1975,20 +1975,7 @@ class XCMarketPatternDetector : public XCBase
* *
* @param bar: XOHCL, reference to Specified Bar ... * @param bar: XOHCL, reference to Specified Bar ...
* @param analysis: XPatternAnalysis, reference to holds Analysis result ... * @param analysis: XPatternAnalysis, reference to holds Analysis result ...
* @param pvValidationLength: int, Validation Length for Peak and Vale Detection ... * @param config: XPatternAnalysisConfig, reference to Provides Detector Configs ...
* @param peakPriceType: ENUM_X_PRICE, Specified Price for Peak (High) Detection ...
* @param valePriceType: ENUM_X_PRICE, Specified Price for Vale (Low) Detection ...
* @param momentumBarValidationLength: int, bar range for approve Momentum ...
* @param momentumBarApprovedMultiplier: double, a Multipler for approve Momentum ...
* @param trueGapApprovedStrength: double, Gap Validation Multiplier in Point ...
* @param pinBarShadowApprovedMultiplier: double, PinBar Shadow Size Approve Multiplier ...
* @param pinBarRangeMultiplier: doubble, PinBar Range Size Approve Multiplier in Point ...
* @param pinBarForceDirection: bool, PinBar Apply Force Bar Type ...
* @param flagPatternPullbackLength: int, Minimum Shoulders of FlagPattern's Swing Bar ...
* @param fvgForceType: bool, Force FVG to Have Same type Bars ...
* @param obForceTwoBar: bool, Force OB to has atleast two indirectional Bars ...
* @param supportAndResistanceValidationLength: int, Support and Resistance Validation Length ...
* @param supportAndResistanceLoopbackLength: int, Support and Resistance Detection Loopback ...
* *
* @return ( bool ) * @return ( bool )
*/ */
@@ -1996,37 +1983,6 @@ class XCMarketPatternDetector : public XCBase
XOHCL &bar, XOHCL &bar,
XPatternAnalysis &analysis, XPatternAnalysis &analysis,
XPatternAnalysisConfig &config // XPatternAnalysisConfig &config //
// //
// // PV ...
// int pvValidationLength = 7,
// ENUM_X_PRICE peakPriceType = X_PRICE_HIGH,
// ENUM_X_PRICE valePriceType = X_PRICE_LOW,
// //
// // Momentum ...
// int momentumBarValidationLength = 3,
// double momentumBarApprovedMultiplier = 3,
// //
// // TrueGap ...
// double trueGapApprovedStrength = 1,
// //
// // Pin ...
// double pinBarShadowApprovedMultiplier = 3,
// double pinBarRangeMultiplier = 4,
// bool pinBarForceDirection = false,
// //
// // Flag ...
// int flagPatternPullbackLength = 3,
// //
// // FVG ...
// bool fvgForceType = false,
// //
// // OB ...
// bool obForceTwoBar = false,
// //
// // Support and Resistance ...
// int supportAndResistanceValidationLength = 21,
// int supportAndResistanceLoopbackLength = 50 //
//
) )
{ {
// //
@@ -2036,29 +1992,6 @@ class XCMarketPatternDetector : public XCBase
// Prepare ... // Prepare ...
analysis.Clean(); analysis.Clean();
// //
// // Normalize ...
// //
// config.pvValidationLength = NormalizeInt(config.pvValidationLength, 2);
// //
// config.momentumBarValidationLength = NormalizeInt(config.momentumBarValidationLength, 2);
// momentumBarApprovedMultiplier = NormalizeDouble(momentumBarApprovedMultiplier, 1);
// //
// trueGapApprovedStrength = NormalizeDouble(trueGapApprovedStrength, 1);
// //
// pinBarRangeMultiplier = NormalizeDouble(pinBarRangeMultiplier, 4);
// pinBarShadowApprovedMultiplier = NormalizeDouble(pinBarShadowApprovedMultiplier, 3);
// //
// flagPatternPullbackLength = NormalizeInt(flagPatternPullbackLength, 3);
// //
// supportAndResistanceLoopbackLength = NormalizeInt(supportAndResistanceLoopbackLength, 10);
// supportAndResistanceValidationLength = NormalizeInt(supportAndResistanceValidationLength, 10);
// //
// Validate ... // Validate ...
result = bar.IsValid(); result = bar.IsValid();
@@ -1463,6 +1463,9 @@ class XCPOIDrawer : public XCBase
return; return;
} }
//
datetime cTime = TimeCurrent();
// //
// Handle Draws ... // Handle Draws ...
@@ -1475,6 +1478,7 @@ class XCPOIDrawer : public XCBase
// //
// Draw Zone ... // Draw Zone ...
_zone.to = cTime;
DrawZone(_zone, config); DrawZone(_zone, config);
} }
File diff suppressed because it is too large Load Diff
+16 -5
View File
@@ -2418,7 +2418,7 @@ struct XPatternAnalysisConfig
{ {
// //
// PV ... // PV ...
pvValidationLength = 7; pvValidationLength = 5;
peakPriceType = X_PRICE_HIGH; peakPriceType = X_PRICE_HIGH;
valePriceType = X_PRICE_LOW; valePriceType = X_PRICE_LOW;
@@ -2594,7 +2594,7 @@ struct XPivotAnalysisDrawConfig
// Tools ... // Tools ...
/** /**
* This function fulfills the will of the developer * This function fulfills the will of the developer
*/ */
void Clean() void Clean()
{ {
@@ -2717,7 +2717,7 @@ struct XPatternAnalysisDrawConfig
drawConfig.Default(); drawConfig.Default();
// //
FullDraw(); Full();
// //
// Remove Unused From Zones ... // Remove Unused From Zones ...
@@ -2735,9 +2735,20 @@ struct XPatternAnalysisDrawConfig
} }
/** /**
* Configure Full Draws ... * No Draw Abilioty ...
*/ */
void FullDraw() void Off()
{
//
XClean(allowedDraws);
XClean(allowedDrawZones);
XClean(allowedDrawPivots);
}
/**
* Full Draw Abilioty ...
*/
void Full()
{ {
// //
GetAllBarPatters(allowedDraws); GetAllBarPatters(allowedDraws);
@@ -41,13 +41,14 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
// Props ... // Props ...
// //
bool ignoreTargets; // Ignore Signal Targets ... bool ignoreTargets; // Ignore Signal Targets ...
CArrayObj drawnObjects; // Drawing Objects Holder ... CArrayObj drawnObjects; // Drawing Objects Holder ...
XFIMAInputs fimaInputs; // XFIMA Inputs ... XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ... XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ... XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ... XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
XPatternAnalysisConfig patternAnalyserConfig; // Bar Pattern Analyser Config ... XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ...
// //
// Constructor ... // Constructor ...
@@ -98,11 +99,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
// //
// Configure ... // Configure ...
structureConfig.Default();
// structureDrawConfig.Default();
patternAnalyserConfig.Clean();
patternAnalyserConfig.Default();
patternAnalyserConfig.FullPattern();
} }
// //
@@ -142,8 +140,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
ZeroMemory(poiDetector); ZeroMemory(poiDetector);
// //
// analyserConfig.Clean(); structureConfig.Clean();
patternAnalyserConfig.Clean(); structureDrawConfig.Clean();
} }
// //
@@ -254,7 +252,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
public: public:
// //
// Props ... // Props ...
// XFIMAPatternDetectorConfig analyserConfig; XFIMAMarketStructure structure; // XFIMA Market Structure ...
// //
// Constructor ... // Constructor ...
@@ -277,12 +275,12 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
) )
{ {
// //
// Configures ... // Configure ...
structureConfig.Default();
structureDrawConfig.Default();
// //
patternAnalyserConfig.Clean(); structure.Clean();
patternAnalyserConfig.Default();
patternAnalyserConfig.FullPattern();
// //
// Ignore Signal Targets ... // Ignore Signal Targets ...
@@ -293,7 +291,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// Deconstructor ... // Deconstructor ...
~XCXFIMAStrategy1Signaller() ~XCXFIMAStrategy1Signaller()
{ {
//
Destroy(); Destroy();
//
structure.Clean();
} }
// //
@@ -366,67 +368,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
} }
// //
// Analyse Market ... structure.Clean();
// poiDetector.AnalyseMarket( poiDetector.AnalyseMarket(
// iBar, structure,
// iStructure, structureConfig,
// analyserConfig // barIndex //
// ); );
poiDrawer.drawnObjects.Clear();
// poiDrawer.DrawMarketStructure(
// Bar Pattern Analysis Detection Test ... structure,
// has = poiDetector.AnalyseBarPatterns( structureDrawConfig //
// iBar, );
// iBarAnalysis,
// patternAnalyserConfig //
// );
// DrawBarPatternAnalysis(iBarAnalysis, patternAnalyserDrawConfig);
// //
// has = fimaHelper.IsBoundaryFakeBreaked(
// iDir,
// iBar.Index() //
// );
// if (has)
// {
// Print("Hot Place Detected");
// }
// //
// XPivot pvPivots[];
// count = fimaHelper.ExtractPVPivots(
// pvPivots,
// iBar.Index(),
// 25,
// 1500,
// 5 //
// );
// has = IsValidSize(count);
// if (has) {
// //
// XPivotAnalysis pvAnalysis;
// has = pvAnalysis.Init(
// "XPV",
// symbol,
// period,
// pvPivots //
// );
// if (has) {
// //
// XPivotAnalysisDrawConfig iC;
// iC.Default();
// iC.drawPivots = true;
// iC.drawPeakTrend = true;
// iC.drawValeTrend = true;
// poiDrawer.DrawPivotAnalysis(
// pvAnalysis,
// iC //
// );
// //
// Print("PV Analysis ...");
// }
// }
// //
// Disable Signallers ... // Disable Signallers ...
@@ -571,7 +523,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
XTarget &targets[], XTarget &targets[],
ENUM_X_DIRECTION &dir, ENUM_X_DIRECTION &dir,
XFIMAConditions &conditions, XFIMAConditions &conditions,
XFIMAMarketStructure &structure // XFIMAMarketStructure &_structure //
) )
{ {
// //
@@ -655,7 +607,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
XTarget &targets[], XTarget &targets[],
ENUM_X_DIRECTION &dir, ENUM_X_DIRECTION &dir,
XFIMAConditions &conditions, XFIMAConditions &conditions,
XFIMAMarketStructure &structure // XFIMAMarketStructure &_structure //
) )
{ {
// //
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+213 -18
View File
@@ -36,22 +36,14 @@
struct XFIMAMarketStructure struct XFIMAMarketStructure
{ {
// //
XOHCL bar; // Spacified Start Bar for Analysing ... XOHCL bar; // Spacified Start Bar for Analysing ...
int length; // Loopback Length for Analyse Structure ...
// //
XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ... XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ...
XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ... XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ...
XPivotAnalysis barsPivotsAnalysis; // Bars Pivot Analysis Result ...
// //
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ... XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
//
// Configure Pivots Detection ...
int requiredPivots; // Required Extracted Pivots for Analysis ...
// //
// Constructor ... // Constructor ...
@@ -70,13 +62,11 @@ struct XFIMAMarketStructure
{ {
// //
bar.Clean(); bar.Clean();
length = 0;
// //
pvAnalysis.Clean(); pvAnalysis.Clean();
zgAnalysis.Clean(); zgAnalysis.Clean();
XClean(barsAnalysis); XClean(barsAnalysis);
barsAnalysisConfig.Clean();
// //
ZeroMemory(this); ZeroMemory(this);
@@ -93,8 +83,7 @@ struct XFIMAMarketStructure
bool result = false; bool result = false;
// //
result = bar.IsValid() && result = bar.IsValid();
length > 0;
// //
return result; return result;
@@ -103,6 +92,120 @@ struct XFIMAMarketStructure
// //
}; };
struct XFIMAMarketStructureConfig
{
//
// Props ...
//
// Detector Flags ...
//
bool analysePVPivots; // Analyse PV Pivots ...
bool analyseZGPivots; // Analyse ZG Pivots ...
//
bool analyseBarPatterns; // Analyse Bar Patterns ...
//
// Detector Configs ...
//
int loopback; // Max Allowed Looping Back Length ...
int requiredPivots; // Required Extracted Pivots for Analysis ...
//
int pvPivotsValidationLength; // PV Pivots Validation Length ...
double maCrossValidationDiffMultiplier; // a Point Distance to Validate MA Crosses ...
//
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
//
// Constructor ...
XFIMAMarketStructureConfig()
{
Clean();
}
//
// Tools ...
/**
* This function fulfills the will of the developer
*/
void Clean()
{
//
// Detector Flags ...
analysePVPivots = false;
analyseZGPivots = false;
analyseBarPatterns = false;
//
// Configure Detectors ...
loopback = 0;
requiredPivots = 0;
pvPivotsValidationLength = 0;
maCrossValidationDiffMultiplier = 0;
//
barsAnalysisConfig.Clean();
//
ZeroMemory(this);
}
/**
* Default Configurations ...
*/
void Default()
{
//
// Detector Flags ...
analysePVPivots = true;
analyseZGPivots = true;
analyseBarPatterns = true;
//
// Configure Detectors ...
loopback = 500;
requiredPivots = 25;
pvPivotsValidationLength = 5;
maCrossValidationDiffMultiplier = 4;
//
barsAnalysisConfig.Default();
barsAnalysisConfig.FullPattern();
}
/**
* No Draw Abilioty ...
*/
void Off()
{
//
// Detector Flags ...
analysePVPivots = false;
analyseZGPivots = false;
analyseBarPatterns = false;
}
/**
* Full Draw Abilioty ...
*/
void Full()
{
//
// Detector Flags ...
analysePVPivots = true;
analyseZGPivots = true;
analyseBarPatterns = true;
}
//
};
/** /**
* Configure Market Structure Drawer ... * Configure Market Structure Drawer ...
**/ **/
@@ -110,6 +213,15 @@ struct XFIMAMarketStructureDrawerConfig
{ {
// //
// Props ... // Props ...
//
bool drawPVAnalysis;
bool drawZGAnalysis;
bool drawBarsAnalysis;
//
XPOIDrawConfig drawConfig;
XPivotAnalysisDrawConfig pivotAnalysisDrawConfig;
XPatternAnalysisDrawConfig barAnalysisDrawConfig; XPatternAnalysisDrawConfig barAnalysisDrawConfig;
// //
@@ -123,27 +235,110 @@ struct XFIMAMarketStructureDrawerConfig
// Tools ... // Tools ...
/** /**
* Cleanup Model ... * This function fulfills the will of the developer
*/ */
void Clean() void Clean()
{ {
//
// Drawing Flags ...
//
drawPVAnalysis = false;
drawZGAnalysis = false;
drawBarsAnalysis = false;
//
// Drawing Configs ...
drawConfig.Clean();
barAnalysisDrawConfig.Clean();
pivotAnalysisDrawConfig.Clean();
// //
ZeroMemory(this); ZeroMemory(this);
} }
/** /**
* Default Model ... * Default Configurations ...
*/ */
void Default() void Default()
{ {
//
// Drawing Flags ...
//
drawPVAnalysis = true;
drawZGAnalysis = true;
drawBarsAnalysis = true;
//
// Drawing Configs ...
drawConfig.Default();
pivotAnalysisDrawConfig.Default();
//
barAnalysisDrawConfig.Default();
barAnalysisDrawConfig.Full();
XClean(barAnalysisDrawConfig.allowedDrawZones);
Add(
X_BAR_PATTERN_SUPPORT,
barAnalysisDrawConfig.allowedDrawZones
);
Add(
X_BAR_PATTERN_RESISTANCE,
barAnalysisDrawConfig.allowedDrawZones
);
} }
/** /**
* Configure for Full Drawing ... * No Draw Abilioty ...
*/ */
void FullDraw() void Off()
{ {
//
// Drawing Flags ...
//
drawPVAnalysis = false;
drawZGAnalysis = false;
drawBarsAnalysis = false;
//
// Drawing Configs ...
barAnalysisDrawConfig.Off();
pivotAnalysisDrawConfig.Off();
}
/**
* Full Draw Abilioty ...
*/
void Full()
{
//
// Drawing Flags ...
//
drawPVAnalysis = false;
drawZGAnalysis = false;
drawBarsAnalysis = false;
//
// Drawing Configs ...
barAnalysisDrawConfig.Full();
pivotAnalysisDrawConfig.Full();
}
void ApplyDrawConfig()
{
//
barAnalysisDrawConfig.drawConfig = drawConfig;
pivotAnalysisDrawConfig.drawConfig = drawConfig;
}
void ApplyDrawConfig(XPOIDrawConfig &_drawConfig)
{
//
drawConfig = _drawConfig;
ApplyDrawConfig();
} }
// //