This commit is contained in:
2025-09-21 10:35:47 +03:30
parent 98b62aba96
commit 84dc311c72
8 changed files with 1484 additions and 741 deletions
@@ -25,6 +25,7 @@
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
#include "../Classes/x-saherelm.xfima.x-poi.detector.class.mq5"
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
//
// Implementation ...
@@ -42,6 +43,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
//
XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *fimaPOIDrawer; // XFIMA POI Drawer ...
XCXFIMAPOIDetector *fimaPOIDetector; // XFIMA POI Detector ...
//
@@ -88,6 +90,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
}
//
fimaPOIDrawer = new XCXFIMAPOIDrawer();
fimaPOIDetector = new XCXFIMAPOIDetector();
}
@@ -119,6 +122,10 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
delete fimaHelper;
ZeroMemory(fimaHelper);
//
delete fimaPOIDrawer;
ZeroMemory(fimaPOIDrawer);
//
delete fimaPOIDetector;
ZeroMemory(fimaPOIDetector);
@@ -29,7 +29,7 @@
//
// Implementation ...
class XCXFIMAPOIDetector : public XCBase
class XCXFIMAPOIDetector : public XCMarketPatternDetector
{
//
// Public ...
@@ -37,7 +37,6 @@ class XCXFIMAPOIDetector : public XCBase
//
// Props ...
XCBarAnalyser *barAnalyser; // Bar Analyser ...
XCMarketPatternDetector *patternDetector; // Pattern Detector ...
//
// Constructor ...
@@ -45,7 +44,6 @@ class XCXFIMAPOIDetector : public XCBase
{
//
barAnalyser = new XCBarAnalyser();
patternDetector = new XCMarketPatternDetector();
}
//
@@ -64,15 +62,15 @@ class XCXFIMAPOIDetector : public XCBase
* @param bar: XOHCL, Specified Bar for Start ...
* @param fimaHelper: XCXFIMAHelper, instance of XFIMA Helper ...
* @param zigzagPoints: XZigZagPoint, Array of Founded Points ...
* @param numberOfRequiredPoints: int, Specified Number of required ZigZag Points ...
* @param numberOfRequiredPivots: int, Specified Number of required ZigZag Points ...
*
* @return ( int )
*/
int GetZigZagPoint(
int GetZigZagPivot(
XOHCL &bar,
XCXFIMAHelper *&fimaHelper,
XZigZagPoint &zigzagPoints[],
int numberOfRequiredPoints = 5 //
XZigZagPivot &zigzagPivots[],
int numberOfRequiredPivots = 5 //
)
{
//
@@ -80,8 +78,8 @@ class XCXFIMAPOIDetector : public XCBase
//
// Normalize ...
SpecifiedClean(zigzagPoints);
numberOfRequiredPoints = NormalizeInt(numberOfRequiredPoints, 3);
SpecifiedClean(zigzagPivots);
numberOfRequiredPivots = NormalizeInt(numberOfRequiredPivots, 3);
//
// Validate ...
@@ -106,13 +104,13 @@ class XCXFIMAPOIDetector : public XCBase
int iPZGIdx = -1;
bool has = false;
int start = index;
XZigZagPoint iZGPoint;
XZigZagPivot iZGPoint;
datetime iZGTime = NULL;
datetime iPZGTime = NULL;
int lastZGDetected = start;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
ENUM_X_ZIGZAG_POINT_TYPE iType = X_ZIGZAG_POINT_TYPE_NONE;
while (ArraySize(zigzagPoints) < numberOfRequiredPoints)
ENUM_X_ZIGZAG_POINT_TYPE iType = X_ZIGZAG_PIVOT_TYPE_NONE;
while (ArraySize(zigzagPivots) < numberOfRequiredPivots)
{
//
// Reading Last two ZigZag Value ...
@@ -131,7 +129,7 @@ class XCXFIMAPOIDetector : public XCBase
iPZGTime = NULL;
iZGPoint.Clean();
iDir = X_DIRECTION_NONE;
iType = X_ZIGZAG_POINT_TYPE_NONE;
iType = X_ZIGZAG_PIVOT_TYPE_NONE;
//
start++;
@@ -155,7 +153,7 @@ class XCXFIMAPOIDetector : public XCBase
iPZGTime = NULL;
iZGPoint.Clean();
iDir = X_DIRECTION_NONE;
iType = X_ZIGZAG_POINT_TYPE_NONE;
iType = X_ZIGZAG_PIVOT_TYPE_NONE;
//
start++;
@@ -178,10 +176,10 @@ class XCXFIMAPOIDetector : public XCBase
// Check Point Type ...
iType =
IsSpecifiedBullish(iDir)
? X_ZIGZAG_POINT_TYPE_PEAK
? X_ZIGZAG_PIVOT_TYPE_PEAK
: IsSpecifiedBearish(iDir)
? X_ZIGZAG_POINT_TYPE_VALE
: X_ZIGZAG_POINT_TYPE_NONE;
? X_ZIGZAG_PIVOT_TYPE_VALE
: X_ZIGZAG_PIVOT_TYPE_NONE;
has =
IsXValid(iType) &&
HasDirection(iDir);
@@ -196,7 +194,7 @@ class XCXFIMAPOIDetector : public XCBase
iPZGTime = NULL;
iZGPoint.Clean();
iDir = X_DIRECTION_NONE;
iType = X_ZIGZAG_POINT_TYPE_NONE;
iType = X_ZIGZAG_PIVOT_TYPE_NONE;
//
start++;
@@ -219,7 +217,7 @@ class XCXFIMAPOIDetector : public XCBase
if (has)
{
//
iZGPoint.AddIfNotExists(zigzagPoints);
iZGPoint.AddIfNotExists(zigzagPivots);
lastZGDetected = iZGIdx + 1;
}
@@ -233,14 +231,14 @@ class XCXFIMAPOIDetector : public XCBase
iPZGTime = NULL;
iZGPoint.Clean();
iDir = X_DIRECTION_NONE;
iType = X_ZIGZAG_POINT_TYPE_NONE;
iType = X_ZIGZAG_PIVOT_TYPE_NONE;
//
start++;
}
//
result = ArraySize(zigzagPoints);
result = ArraySize(zigzagPivots);
//
return result;
@@ -250,7 +248,9 @@ class XCXFIMAPOIDetector : public XCBase
bool AnalyseMarketUsingZigZag(
XOHCL &bar,
ENUM_TIMEFRAMES forPeriod,
XZigZagAnalysis &analysis //
XCXFIMAHelper *&fimaHelper,
XZigZagAnalysis &analysis,
int numberOfRequiredPivots = 20 //
)
{
//
@@ -270,6 +270,7 @@ class XCXFIMAPOIDetector : public XCBase
//
// Normalize ...
numberOfRequiredPivots = NormalizeInt(numberOfRequiredPivots, 5);
if (!IsSpecifiedValid(forPeriod))
{
forPeriod = bar.period;
@@ -277,365 +278,55 @@ class XCXFIMAPOIDetector : public XCBase
//
// Reading XZigZag Points ...
XOHCL iPeriodBar;
result = iPeriodBar.Init(
bar.symbol,
forPeriod,
bar.Index() //
);
if (!result)
{
//
iPeriodBar.Clean();
return result;
}
//
// Reading Required Pivots ...
XZigZagPivot pivots[];
int pivotsCount = GetZigZagPivot(
iPeriodBar,
fimaHelper,
pivots,
numberOfRequiredPivots //
);
result = IsValidSize(pivotsCount);
if (!result)
{
//
analysis.Clean();
iPeriodBar.Clean();
SpecifiedClean(pivots);
}
//
// Initialize Analysis Model ...
result = analysis.Analyse(
bar,
pivots //
);
if (!result)
{
//
analysis.Clean();
iPeriodBar.Clean();
SpecifiedClean(pivots);
}
//
return result;
}
//
// Implementing Patrren Detector ...
/**
* Check Specified Bar is Momentum Bar or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param requiredBars: int, bar range for approve Momentum ...
* @param approvedMultiplier: int, a Multipler for approve Momentum ...
*
* @return ( bool )
*/
bool IsMomentumBar(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int requiredBars = 3,
int approvedMultiplier = 2 //
)
{
//
return patternDetector.IsMomentumBar(
bar,
dir,
requiredBars,
approvedMultiplier //
);
}
/**
* Check Specified Bar is Engulfed Bar or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
*
* @return ( bool )
*/
bool IsEngulfedBar(
XOHCL &bar,
ENUM_X_DIRECTION &dir //
)
{
//
return patternDetector.IsEngulfedBar(
bar,
dir //
);
}
/**
* Check Specified Bar is True Gapped Bar or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param approvedPointMultiplier: double, Gap Validation Multiplier in Point ...
*
* @return ( bool )
*/
bool IsTrueGapedBar(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
double approvedPointMultiplier = 1 //
)
{
//
return patternDetector.IsTrueGapedBar(
bar,
dir,
approvedPointMultiplier //
);
}
/**
* Check Specified Bar is Pinned Bar or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param shadowApprovedMultiplier: int, Shadow Size Approve Multiplier ...
* @param minimumPinBarRangeMultiplier: doubble, Range Size Approve Multiplier in Point ...
* @param forceDirection: bool, Apply Force Bar Type ...
*
* @return ( bool )
*/
bool IsPinnedBar(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int shadowApprovedMultiplier = 3,
double minimumPinBarRangeMultiplier = 4,
bool forceDirection = false //
)
{
//
return patternDetector.IsPinnedBar(
bar,
dir,
shadowApprovedMultiplier,
minimumPinBarRangeMultiplier,
forceDirection //
);
}
/**
* Check Specified Bar has Star Pattern or not ...
* Morning Star => Bullish
* Evening Star => Bearish
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
*
* @return ( bool )
*/
bool IsStartPattern(
XOHCL &bar,
ENUM_X_DIRECTION &dir //
)
{
//
return patternDetector.IsStartPattern(
bar,
dir //
);
}
/**
* Check Specified Bar has Pirecing Pattern or not ...
* Piercing => Bullish
* Dark Cloud Cover => Bearish
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
*
* @return ( bool )
*/
bool IsPiercingPattern(
XOHCL &bar,
ENUM_X_DIRECTION &dir //
)
{
//
return patternDetector.IsPiercingPattern(
bar,
dir //
);
}
/**
* Check Specified Bar has Rising Pattern or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
*
* @return ( bool )
*/
bool IsRisingPattern(
XOHCL &bar,
ENUM_X_DIRECTION &dir //
)
{
//
return patternDetector.IsRisingPattern(
bar,
dir //
);
}
/**
* Check Specified Bar has Flag Pattern or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param swingBar: XOHCL, Detected Swing Bar ...
* @param minimumPullbackBars: int, Minimum Shoulders of Swing Bar ...
* @param minimumPullbackBars: int, Minimum Shoulders of Swing Bar ...
*
* @return ( bool )
*/
bool IsFlagPattern(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
XOHCL &swingBar,
int minimumPullbackBars = 3 //
)
{
//
return patternDetector.IsFlagPattern(
bar,
dir,
swingBar,
minimumPullbackBars //
);
}
/**
* Check Specified Bar has SignalKey Bar Pattern or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param shadowApprovedMultiplier: int, Shadow Size Approve Multiplier ...
* @param minimumPinBarRangeMultiplier: doubble, Range Size Approve Multiplier in Point ...
* @param forceDirection: bool, Apply Force Bar Type ...
*
* @return ( bool )
*/
bool IsSignalKeyBarPattern(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int shadowApprovedMultiplier = 3,
double minimumPinBarRangeMultiplier = 4,
bool forceDirection = false //
)
{
//
return patternDetector.IsSignalKeyBarPattern(
bar,
dir,
shadowApprovedMultiplier,
minimumPinBarRangeMultiplier,
forceDirection //
);
}
/**
* Check For FVG Exists in Specified Loopback Period ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param fvg: XBoxZone, reference for Holding FVG ...
* @param maxLoopback: int, Max Allowed Loopback to Lookup FVG ...
*
* @return ( bool )
*/
bool HasFVG(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
XBoxZone &fvg,
int maxLoopback = 5 //
)
{
//
return patternDetector.HasFVG(
bar,
dir,
fvg,
maxLoopback //
);
}
/**
* Check For OB Exists in Specified Loopback Period ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param ob: XBoxZone, reference for Holding OB ...
* @param maxLoopback: int, Max Allowed Loopback to Lookup OB ...
*
* @return ( bool )
*/
bool HasOB(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
XBoxZone &ob,
int maxLoopback = 5 //
)
{
//
return patternDetector.HasOB(
bar,
dir,
ob,
maxLoopback //
);
}
/**
* Check Trend Exists Based on Swings ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param swings: XOHCL Array, Holds Swings ...
* @param numberOfSwings: int, Number of Swing Points for Detect Trend ...
* @param swingShoulders: int, Swing Shoulders Approvement Length ...
*
* @return ( bool )
*/
bool HasSwingTrend(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
XOHCL &swings[],
int numberOfSwings = 3,
int swingShoulders = 7 //
)
{
//
return patternDetector.HasSwingTrend(
bar,
dir,
swings,
numberOfSwings,
swingShoulders //
);
}
/**
* Check Specified Bar Has Support or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param support: XOHCL, Supported Bar ...
* @param validationLength: int, Validation Length ...
* @param maxAllowedLoopback: int, Max Allowed Loopback to Detection ...
*
* @return ( bool )
*/
bool HasSupport(
XOHCL &bar,
XOHCL &support,
int validationLength = 21,
int maxAllowedLoopback = 1500 //
)
{
//
return patternDetector.HasSupport(
bar,
support,
validationLength,
maxAllowedLoopback //
);
}
/**
* Check Specified Bar Has Resistance or not ...
*
* @param bar: XOHCL, Specified Bar ...
* @param resistence: XOHCL, Resistanced Bar ...
* @param validationLength: int, Validation Length ...
* @param maxAllowedLoopback: int, Max Allowed Loopback to Detection ...
*
* @return ( bool )
*/
bool HasResistance(
XOHCL &bar,
XOHCL &resistence,
int validationLength = 21,
int maxAllowedLoopback = 1500 //
)
{
//
return patternDetector.HasResistance(
bar,
resistence,
validationLength,
maxAllowedLoopback //
);
}
//
// Tools ...
@@ -647,10 +338,6 @@ class XCXFIMAPOIDetector : public XCBase
//
delete barAnalyser;
ZeroMemory(barAnalyser);
//
delete patternDetector;
ZeroMemory(patternDetector);
}
//
@@ -0,0 +1,141 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class
// -------------------------------------------------
// Name: XCXFIMAPoiDrawer ...
// Description: XFIMA POI Drawer Class ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XFIMA POI Drawer Class"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../Libraries/x-saherelm.xfima.lib.mq5"
//
// Implementation ...
class XCXFIMAPOIDrawer : public XCPOIDrawer
{
//
public:
//
/**
* Draw Specified XZigZagMarketStyle on Chart ...
*
* @param object: XCZigZagAnalysisObject, pointer reference to Drawn Object ...
* @param model: XZigZagAnalysis, reference to Model ...
* @param numberOfPivots: int, required number of pivots for Draw Trends ...
* @param rayRight: bool, Ray To Right ...
* @param rayLeft: bool, Ray To Left ...
*
* @return ( bool )
*/
bool DrawZigZagMarketAnalysis(
XCZigZagAnalysisObject *&object,
XZigZagAnalysis &model,
bool rayRight = false,
bool rayLeft = false,
int numberOfPivots = 2 //
)
{
//
bool result = false;
//
// Prepare ...
object = NULL;
//
// Validate ...
result = model.IsValid();
if (!result)
{
return result;
}
//
object = new XCZigZagAnalysisObject();
result = object.Create(
ChartIdentification(),
SubWindowIdentification(),
model,
numberOfPivots //
);
if (result)
{
//
// Apply Style ...
bool isBullish = model.IsBullish();
//
XPOIStyle style;
if (isBullish)
{
style = defaultBullishStyle;
}
else
{
style = defaultBearishStyle;
}
//
ApplyZigZagMarketAnalysisStyle(
object,
style,
false, // Ray Right ...
true // Ray Left ...
);
}
//
return result;
}
/**
* Apply Specified Style to Object ...
*/
void ApplyZigZagMarketAnalysisStyle(
XCZigZagAnalysisObject *&object,
XPOIStyle &style,
bool rayRight = false,
bool rayLeft = false //
)
{
//
bool has = object != NULL;
if (!has)
{
return;
}
//
object.UpperColor(style.clr);
object.LowerColor(style.clr);
object.UpperWidth(style.width);
object.UpperRayLeft(rayLeft);
object.UpperRayRight(rayRight);
object.LowerWidth(style.width);
object.UpperStyle(style.style);
object.LowerStyle(style.style);
object.LowerRayLeft(rayLeft);
object.LowerRayRight(rayRight);
}
//
};
//
File diff suppressed because it is too large Load Diff