Files
MQL5Data/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5
T

559 lines
12 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Library
// -------------------------------------------------
// Name: XCXFIMAEALib ...
// Description: XFIMAEA Library ...
//
//
// 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 XFIMAEA Library"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
//
// Definitions ...
/**
* Configure Market Structure Detection ...
**/
struct XFIMAPatternDetectorConfig
{
//
// Props ...
//
// Flags ...
//
bool detectSupports;
bool detectResistance;
//
bool detectSwingTrend;
//
bool detectOB;
bool detectFVG;
//
bool detectStarPattern;
bool detectFlagPattern;
bool detectRisingPattern;
bool detectPiercingPattern;
bool detectSignalKeyBarPattern;
//
bool detectPinned;
bool detectMomentum;
bool detectEngulfed;
bool detectTrueGaped;
//
bool analyseFIMAPVPivots;
bool analyseFIMAMAPivots;
bool analyseFIMASARPivots;
bool analyseFIMAZigZagPivots;
//
// Configs ...
//
// OB / FVG ...
int obLoopback;
int fvgLoopback;
//
// Trending ...
int trendingNumberOfSwings;
int trendingSwingShoulders;
//
// Support and Resistance ...
int supportAndResistanceValidationLength;
int supportAndResistanceMaxAllowedLoopback;
//
// TrueGap ...
double truwGapApprovedPointMultiplier;
//
// Flag Pattern ...
int flagPatternMinimumPullbackBars;
//
// Momentum Bar ...
int momentumBarRangeLength;
double momentumBarApprovedMultiplier;
//
// Pinned Bar ...
double pinnedBaarShadowApprovedMultiplier;
double pinnedBarMinimumPinBarRangeMultiplier;
bool pinnedBarForceDirection;
//
// SignalKey Bar ...
double signalKeyBarShadowApprovedMultiplier;
double signalKeyBarMinimumPinBarRangeMultiplier;
bool signalKeyBarForceDirection;
//
// Analyser ...
int pvPivotsValidationLength;
int maPivotsValidationLength;
int numberOfRequiredPivotsForAnalysis;
int maxAllowedLoopbackLengthForAnalysis;
//
// Constructor ...
XFIMAPatternDetectorConfig()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
detectOB = false;
detectFVG = false;
detectSupports = false;
detectResistance = false;
detectSwingTrend = false;
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
analyseFIMAPVPivots = false;
analyseFIMAMAPivots = false;
analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false;
//
obLoopback = 0;
fvgLoopback = 0;
trendingNumberOfSwings = 0;
trendingSwingShoulders = 0;
supportAndResistanceValidationLength = 0;
supportAndResistanceMaxAllowedLoopback = 0;
truwGapApprovedPointMultiplier = 0;
flagPatternMinimumPullbackBars = 0;
momentumBarRangeLength = 0;
momentumBarApprovedMultiplier = 0;
pinnedBaarShadowApprovedMultiplier = 0;
pinnedBarMinimumPinBarRangeMultiplier = 0;
pinnedBarForceDirection = false;
signalKeyBarShadowApprovedMultiplier = 0;
signalKeyBarMinimumPinBarRangeMultiplier = 0;
signalKeyBarForceDirection = false;
pvPivotsValidationLength = 0;
maPivotsValidationLength = 0;
numberOfRequiredPivotsForAnalysis = 0;
maxAllowedLoopbackLengthForAnalysis = 0;
}
/**
* Default Model ...
*/
void Default()
{
//
// OB / FVG ...
detectOB = true;
detectFVG = true;
//
// Support and Resistances ...
detectSupports = true;
detectResistance = true;
detectSwingTrend = true;
//
// Patterns ...
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
//
// Bars ...
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
//
// Analysers ...
analyseFIMAPVPivots = false;
analyseFIMAMAPivots = false;
analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false;
//
// OB / FVg ...
obLoopback = 5;
fvgLoopback = 5;
//
// Trending ...
trendingNumberOfSwings = 3;
trendingSwingShoulders = 7;
//
// Support and Resistance ...
supportAndResistanceValidationLength = 21;
supportAndResistanceMaxAllowedLoopback = 1500;
//
// TrueGap ...
truwGapApprovedPointMultiplier = 1;
//
// Flag Pattern ...
flagPatternMinimumPullbackBars = 3;
//
// Momentum Bar ...
momentumBarRangeLength = 3;
momentumBarApprovedMultiplier = 2;
//
// Pinned Bar ...
pinnedBaarShadowApprovedMultiplier = 3;
pinnedBarMinimumPinBarRangeMultiplier = 4;
pinnedBarForceDirection = false;
//
// SignalKey Bar ...
signalKeyBarShadowApprovedMultiplier = 3;
signalKeyBarMinimumPinBarRangeMultiplier = 4;
signalKeyBarForceDirection = false;
//
// Length ...
pvPivotsValidationLength = 10;
maPivotsValidationLength = 0;
numberOfRequiredPivotsForAnalysis = 50;
maxAllowedLoopbackLengthForAnalysis = 1500;
}
/**
* Full Detection Model ...
*/
void FullDetect()
{
//
Default();
//
// OB / FVG ...
detectOB = true;
detectFVG = true;
//
// Support and Resistances ...
detectSupports = true;
detectResistance = true;
detectSwingTrend = true;
//
// Patterns ...
detectStarPattern = true;
detectFlagPattern = true;
detectRisingPattern = true;
detectPiercingPattern = true;
detectSignalKeyBarPattern = true;
//
// Bars ...
detectPinned = true;
detectMomentum = true;
detectEngulfed = true;
detectTrueGaped = true;
//
// Analysers ...
analyseFIMAPVPivots = true;
analyseFIMAMAPivots = true;
analyseFIMASARPivots = true;
analyseFIMAZigZagPivots = true;
}
//
};
/**
* XFIMA Base Market Structure ...
* AnalyseMarket result ...
**/
struct XFIMAMarketStructure
{
//
XOHCL bar;
//
XBoxZone ob;
XBoxZone fvg;
XBoxZone support;
XBoxZone resistance;
//
// Analysis ...
XPivotAnalysis pvAnalysis;
XPivotAnalysis maAnalysis;
XPivotAnalysis sarAnalysis;
XPivotAnalysis zigzagAnalysis;
//
ENUM_X_DIRECTION pinnedDir;
ENUM_X_DIRECTION momentumDir;
ENUM_X_DIRECTION engulfedDir;
ENUM_X_DIRECTION trueGapedDir;
//
XOHCL flagSwing;
ENUM_X_DIRECTION flagPatternDir;
//
XOHCL trendSwings[];
ENUM_X_DIRECTION trendDir;
//
ENUM_X_DIRECTION starPatternDir;
ENUM_X_DIRECTION risingPatternDir;
ENUM_X_DIRECTION piercingPatternDir;
ENUM_X_DIRECTION signalKeyBarPatternDir;
//
// Constructor ...
XFIMAMarketStructure()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
ob.Clean();
fvg.Clean();
support.Clean();
resistance.Clean();
//
bar.Clean();
flagSwing.Clean();
//
pvAnalysis.Clean();
maAnalysis.Clean();
sarAnalysis.Clean();
zigzagAnalysis.Clean();
//
trendDir = X_DIRECTION_NONE;
pinnedDir = X_DIRECTION_NONE;
momentumDir = X_DIRECTION_NONE;
engulfedDir = X_DIRECTION_NONE;
trueGapedDir = X_DIRECTION_NONE;
flagPatternDir = X_DIRECTION_NONE;
starPatternDir = X_DIRECTION_NONE;
risingPatternDir = X_DIRECTION_NONE;
piercingPatternDir = X_DIRECTION_NONE;
signalKeyBarPatternDir = X_DIRECTION_NONE;
//
SpecifiedClean(trendSwings);
}
//
// Checker Functions ...
//
};
/**
* Configure Market Structure Drawer ...
**/
struct XFIMAMarketStructureDrawerConfig
{
//
// Props ...
//
bool drawSupports;
bool drawResistance;
//
bool drawSwingTrend;
//
bool drawOB;
bool drawFVG;
//
bool drawStarPattern;
bool drawFlagPattern;
bool drawRisingPattern;
bool drawPiercingPattern;
bool drawSignalKeyBarPattern;
//
bool drawPinned;
bool drawMomentum;
bool drawEngulfed;
bool drawTrueGaped;
//
bool drawFIMAPVPivotsAnalysis;
bool drawFIMAPVPivotsAnalysisPivots;
//
bool drawFIMAMAPivotsAnalysis;
bool drawFIMAMAPivotsAnalysisPivots;
//
bool drawFIMASARPivotsAnalysis;
bool drawFIMASARPivotsAnalysisPivots;
//
bool drawFIMAZigZagPivotsAnalysis;
bool drawFIMAZigZagPivotsAnalysisPivots;
//
// Constructor ...
XFIMAMarketStructureDrawerConfig()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
drawOB = false;
drawFVG = false;
drawPinned = false;
drawMomentum = false;
drawSupports = false;
drawEngulfed = false;
drawTrueGaped = false;
drawResistance = false;
drawSwingTrend = false;
drawStarPattern = false;
drawFlagPattern = false;
drawRisingPattern = false;
drawPiercingPattern = false;
drawSignalKeyBarPattern = false;
drawFIMAPVPivotsAnalysis = false;
drawFIMAMAPivotsAnalysis = false;
drawFIMASARPivotsAnalysis = false;
drawFIMAZigZagPivotsAnalysis = false;
drawFIMAPVPivotsAnalysisPivots = false;
drawFIMAMAPivotsAnalysisPivots = false;
drawFIMASARPivotsAnalysisPivots = false;
drawFIMAZigZagPivotsAnalysisPivots = false;
}
/**
* Default Model ...
*/
void Default()
{
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupports = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
drawPiercingPattern = true;
drawSignalKeyBarPattern = true;
drawFIMAPVPivotsAnalysis = true;
drawFIMAMAPivotsAnalysis = true;
drawFIMASARPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisPivots = false;
drawFIMAMAPivotsAnalysisPivots = false;
drawFIMASARPivotsAnalysisPivots = false;
drawFIMAZigZagPivotsAnalysisPivots = false;
}
/**
* Configure for Full Drawing ...
*/
void FullDraw()
{
//
Default();
//
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupports = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
drawPiercingPattern = true;
drawSignalKeyBarPattern = true;
drawFIMAPVPivotsAnalysis = true;
drawFIMAMAPivotsAnalysis = true;
drawFIMASARPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisPivots = true;
drawFIMAMAPivotsAnalysisPivots = true;
drawFIMASARPivotsAnalysisPivots = true;
drawFIMAZigZagPivotsAnalysisPivots = true;
}
//
};