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 analysis: XPatternAnalysis, reference to holds Analysis result ...
* @param pvValidationLength: int, Validation Length for Peak and Vale Detection ...
* @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 ...
* @param config: XPatternAnalysisConfig, reference to Provides Detector Configs ...
*
* @return ( bool )
*/
@@ -1996,37 +1983,6 @@ class XCMarketPatternDetector : public XCBase
XOHCL &bar,
XPatternAnalysis &analysis,
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 ...
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 ...
result = bar.IsValid();
@@ -1463,6 +1463,9 @@ class XCPOIDrawer : public XCBase
return;
}
//
datetime cTime = TimeCurrent();
//
// Handle Draws ...
@@ -1475,6 +1478,7 @@ class XCPOIDrawer : public XCBase
//
// Draw Zone ...
_zone.to = cTime;
DrawZone(_zone, config);
}
File diff suppressed because it is too large Load Diff
+16 -5
View File
@@ -2418,7 +2418,7 @@ struct XPatternAnalysisConfig
{
//
// PV ...
pvValidationLength = 7;
pvValidationLength = 5;
peakPriceType = X_PRICE_HIGH;
valePriceType = X_PRICE_LOW;
@@ -2594,7 +2594,7 @@ struct XPivotAnalysisDrawConfig
// Tools ...
/**
* This function fulfills the will of the developer
* This function fulfills the will of the developer
*/
void Clean()
{
@@ -2717,7 +2717,7 @@ struct XPatternAnalysisDrawConfig
drawConfig.Default();
//
FullDraw();
Full();
//
// 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);
@@ -41,13 +41,14 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
// Props ...
//
bool ignoreTargets; // Ignore Signal Targets ...
CArrayObj drawnObjects; // Drawing Objects Holder ...
XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
XPatternAnalysisConfig patternAnalyserConfig; // Bar Pattern Analyser Config ...
bool ignoreTargets; // Ignore Signal Targets ...
CArrayObj drawnObjects; // Drawing Objects Holder ...
XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ...
//
// Constructor ...
@@ -98,11 +99,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
//
// Configure ...
//
patternAnalyserConfig.Clean();
patternAnalyserConfig.Default();
patternAnalyserConfig.FullPattern();
structureConfig.Default();
structureDrawConfig.Default();
}
//
@@ -142,8 +140,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
ZeroMemory(poiDetector);
//
// analyserConfig.Clean();
patternAnalyserConfig.Clean();
structureConfig.Clean();
structureDrawConfig.Clean();
}
//
@@ -254,7 +252,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
public:
//
// Props ...
// XFIMAPatternDetectorConfig analyserConfig;
XFIMAMarketStructure structure; // XFIMA Market Structure ...
//
// Constructor ...
@@ -277,12 +275,12 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
)
{
//
// Configures ...
// Configure ...
structureConfig.Default();
structureDrawConfig.Default();
//
patternAnalyserConfig.Clean();
patternAnalyserConfig.Default();
patternAnalyserConfig.FullPattern();
structure.Clean();
//
// Ignore Signal Targets ...
@@ -293,7 +291,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// Deconstructor ...
~XCXFIMAStrategy1Signaller()
{
//
Destroy();
//
structure.Clean();
}
//
@@ -366,67 +368,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Analyse Market ...
// poiDetector.AnalyseMarket(
// iBar,
// iStructure,
// analyserConfig //
// );
//
// Bar Pattern Analysis Detection Test ...
// has = poiDetector.AnalyseBarPatterns(
// 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 ...");
// }
// }
structure.Clean();
poiDetector.AnalyseMarket(
structure,
structureConfig,
barIndex //
);
poiDrawer.drawnObjects.Clear();
poiDrawer.DrawMarketStructure(
structure,
structureDrawConfig //
);
//
// Disable Signallers ...
@@ -571,7 +523,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
XTarget &targets[],
ENUM_X_DIRECTION &dir,
XFIMAConditions &conditions,
XFIMAMarketStructure &structure //
XFIMAMarketStructure &_structure //
)
{
//
@@ -655,7 +607,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
XTarget &targets[],
ENUM_X_DIRECTION &dir,
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
{
//
XOHCL bar; // Spacified Start Bar for Analysing ...
int length; // Loopback Length for Analyse Structure ...
XOHCL bar; // Spacified Start Bar for Analysing ...
//
XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ...
XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ...
XPivotAnalysis barsPivotsAnalysis; // Bars Pivot Analysis Result ...
//
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
//
// Configure Pivots Detection ...
int requiredPivots; // Required Extracted Pivots for Analysis ...
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
//
// Constructor ...
@@ -70,13 +62,11 @@ struct XFIMAMarketStructure
{
//
bar.Clean();
length = 0;
//
pvAnalysis.Clean();
zgAnalysis.Clean();
XClean(barsAnalysis);
barsAnalysisConfig.Clean();
//
ZeroMemory(this);
@@ -93,8 +83,7 @@ struct XFIMAMarketStructure
bool result = false;
//
result = bar.IsValid() &&
length > 0;
result = bar.IsValid();
//
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 ...
**/
@@ -110,6 +213,15 @@ struct XFIMAMarketStructureDrawerConfig
{
//
// Props ...
//
bool drawPVAnalysis;
bool drawZGAnalysis;
bool drawBarsAnalysis;
//
XPOIDrawConfig drawConfig;
XPivotAnalysisDrawConfig pivotAnalysisDrawConfig;
XPatternAnalysisDrawConfig barAnalysisDrawConfig;
//
@@ -123,27 +235,110 @@ struct XFIMAMarketStructureDrawerConfig
// Tools ...
/**
* Cleanup Model ...
* This function fulfills the will of the developer
*/
void Clean()
{
//
// Drawing Flags ...
//
drawPVAnalysis = false;
drawZGAnalysis = false;
drawBarsAnalysis = false;
//
// Drawing Configs ...
drawConfig.Clean();
barAnalysisDrawConfig.Clean();
pivotAnalysisDrawConfig.Clean();
//
ZeroMemory(this);
}
/**
* Default Model ...
* Default Configurations ...
*/
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();
}
//