This commit is contained in:
2025-10-08 18:47:29 +03:30
parent 96972931a7
commit d963ce8acf
10 changed files with 6108 additions and 3372 deletions
+557 -287
View File
@@ -23,8 +23,8 @@
// Imports ...
#include "../Classes/x-saherelm.base.class.mq5"
#include "../Classes/x-saherelm.x-bar.analyser.class.mq5"
#include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
#include "../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
#include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
#include "../Libraries/x-saherelm.x-poi.lib.mq5"
//
@@ -1995,36 +1995,37 @@ class XCMarketPatternDetector : public XCBase
bool AnalyseBarPatterns(
XOHCL &bar,
XPatternAnalysis &analysis,
//
// 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 //
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 //
//
)
{
@@ -2035,28 +2036,28 @@ class XCMarketPatternDetector : public XCBase
// Prepare ...
analysis.Clean();
//
// Normalize ...
//
pvValidationLength = NormalizeInt(pvValidationLength, 2);
// //
// // Normalize ...
// //
// config.pvValidationLength = NormalizeInt(config.pvValidationLength, 2);
//
momentumBarValidationLength = NormalizeInt(momentumBarValidationLength, 2);
momentumBarApprovedMultiplier = NormalizeDouble(momentumBarApprovedMultiplier, 1);
// //
// config.momentumBarValidationLength = NormalizeInt(config.momentumBarValidationLength, 2);
// momentumBarApprovedMultiplier = NormalizeDouble(momentumBarApprovedMultiplier, 1);
//
trueGapApprovedStrength = NormalizeDouble(trueGapApprovedStrength, 1);
// //
// trueGapApprovedStrength = NormalizeDouble(trueGapApprovedStrength, 1);
//
pinBarRangeMultiplier = NormalizeDouble(pinBarRangeMultiplier, 4);
pinBarShadowApprovedMultiplier = NormalizeDouble(pinBarShadowApprovedMultiplier, 3);
// //
// pinBarRangeMultiplier = NormalizeDouble(pinBarRangeMultiplier, 4);
// pinBarShadowApprovedMultiplier = NormalizeDouble(pinBarShadowApprovedMultiplier, 3);
//
flagPatternPullbackLength = NormalizeInt(flagPatternPullbackLength, 3);
// //
// flagPatternPullbackLength = NormalizeInt(flagPatternPullbackLength, 3);
//
supportAndResistanceLoopbackLength = NormalizeInt(supportAndResistanceLoopbackLength, 10);
supportAndResistanceValidationLength = NormalizeInt(supportAndResistanceValidationLength, 10);
// //
// supportAndResistanceLoopbackLength = NormalizeInt(supportAndResistanceLoopbackLength, 10);
// supportAndResistanceValidationLength = NormalizeInt(supportAndResistanceValidationLength, 10);
//
// Validate ...
@@ -2076,129 +2077,245 @@ class XCMarketPatternDetector : public XCBase
ENUM_X_DIRECTION iDir;
ENUM_X_BAR_PATTERN iPattern;
//
bool has;
bool isBullish;
bool isBearish;
//
bool canDetect;
bool canDetectBullish;
bool canDetectBearish;
//
// Bars Detectors ...
//
// XPV High Low Detection ...
bool isPV = IsPV(
bar,
iDir,
pvValidationLength,
peakPriceType,
valePriceType //
);
bool isHigh = isPV &&
IsXBearish(iDir);
bool isLow = isPV &&
IsXBullish(iDir);
if (isPV)
canDetect = config.CanDetect(X_BAR_PATTERN_HIGH) ||
config.CanDetect(X_BAR_PATTERN_LOW);
if (canDetect)
{
//
iPattern =
isHigh
? X_BAR_PATTERN_HIGH
: X_BAR_PATTERN_LOW;
has = IsPV(
bar,
iDir,
config.pvValidationLength,
config.peakPriceType,
config.valePriceType //
);
//
analysis.AddPattern(
iPattern,
iDir //
);
canDetectBullish = config.CanDetect(X_BAR_PATTERN_LOW);
canDetectBearish = config.CanDetect(X_BAR_PATTERN_HIGH);
//
isBullish =
has &&
IsXBullish(iDir) &&
canDetectBullish;
//
isBearish =
has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
iPattern =
isBearish
? X_BAR_PATTERN_HIGH
: X_BAR_PATTERN_LOW;
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Momentum ...
bool isMomentum = IsMomentumBar(
bar,
iDir,
momentumBarValidationLength,
momentumBarApprovedMultiplier //
);
bool isBullishMomentum = isMomentum &&
IsXBullish(iDir);
bool isBearishMomentum = isMomentum &&
IsXBearish(iDir);
if (isMomentum)
iPattern = X_BAR_PATTERN_MOMENTUM;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_MOMENTUM;
has = IsMomentumBar(
bar,
iDir,
config.momentumBarValidationLength,
config.momentumBarApprovedMultiplier //
);
//
analysis.AddPattern(
canDetectBullish = config.CanDetect(
iPattern,
iDir //
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Engulfed ...
bool isEngulfed = IsEngulfedBar(
bar,
iDir //
);
bool isBullishEngulfed = isEngulfed &&
IsXBullish(iDir);
bool isBearishEngulfed = isEngulfed &&
IsXBearish(iDir);
if (isEngulfed)
iPattern = X_BAR_PATTERN_ENGULFED;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_ENGULFED;
//
analysis.AddPattern(
iPattern,
has = IsEngulfedBar(
bar,
iDir //
);
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// TrueGap ...
bool isTrueGaped = IsTrueGapedBar(
bar,
iDir,
trueGapApprovedStrength //
);
bool isBullishTrueGaped = isTrueGaped &&
IsXBullish(iDir);
bool isBearishTrueGaped = isTrueGaped &&
IsXBearish(iDir);
if (isTrueGaped)
iPattern = X_BAR_PATTERN_TRUE_GAPED;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_TRUE_GAPED;
has = IsTrueGapedBar(
bar,
iDir,
config.trueGapApprovedStrength //
);
//
analysis.AddPattern(
canDetectBullish = config.CanDetect(
iPattern,
iDir //
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Pinned ...
bool isPinned = IsPinnedBar(
bar,
iDir,
pinBarShadowApprovedMultiplier,
pinBarRangeMultiplier,
pinBarForceDirection //
);
bool isBullishPinned = isPinned &&
IsXBullish(iDir);
bool isBearishPinned = isPinned &&
IsXBearish(iDir);
if (isPinned)
iPattern = X_BAR_PATTERN_PINNED;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_PINNED;
has = IsPinnedBar(
bar,
iDir,
config.pinBarShadowApprovedMultiplier,
config.pinBarRangeMultiplier,
config.pinBarForceDirection //
);
//
analysis.AddPattern(
canDetectBullish = config.CanDetect(
iPattern,
iDir //
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
@@ -2206,120 +2323,225 @@ class XCMarketPatternDetector : public XCBase
//
// Star ...
bool isStar = IsStarPattern(
bar,
iDir //
);
bool isBullishStar = isStar &&
IsXBullish(iDir);
bool isBearishStar = isStar &&
IsXBearish(iDir);
if (isStar)
iPattern = X_BAR_PATTERN_STAR;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_STAR;
//
analysis.AddPattern(
iPattern,
has = IsStarPattern(
bar,
iDir //
);
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Piercing ...
bool isPiercing = IsPiercingPattern(
bar,
iDir //
);
bool isBullishPiercing = isPiercing &&
IsXBullish(iDir);
bool isBearishPiercing = isPiercing &&
IsXBearish(iDir);
if (isPiercing)
iPattern = X_BAR_PATTERN_PIERCING;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_PIERCING;
//
analysis.AddPattern(
iPattern,
has = IsPiercingPattern(
bar,
iDir //
);
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Rising ...
bool isRising = IsRisingPattern(
bar,
iDir //
);
bool isBullishRising = isRising &&
IsXBullish(iDir);
bool isBearishRising = isRising &&
IsXBearish(iDir);
if (isRising)
iPattern = X_BAR_PATTERN_RISING;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_RISING;
//
analysis.AddPattern(
iPattern,
has = IsRisingPattern(
bar,
iDir //
);
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
// Flag ...
bool isFlag = IsFlagPattern(
bar,
iDir,
iSwing,
flagPatternPullbackLength //
);
bool isBullishFlag = isFlag &&
IsXBullish(iDir);
bool isBearishFlag = isFlag &&
IsXBearish(iDir);
if (isFlag)
iPattern = X_BAR_PATTERN_FLAG;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_FLAG;
//
analysis.AddPattern(
iPattern,
iDir //
has = IsFlagPattern(
bar,
iDir,
iSwing,
config.flagPatternPullbackLength //
);
//
analysis.flagSwing = iSwing;
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
//
analysis.flagSwing = iSwing;
}
}
//
// SignalKey ...
bool isSignalKey = IsSignalKeyBarPattern(
bar,
iDir,
pinBarShadowApprovedMultiplier,
pinBarRangeMultiplier,
pinBarForceDirection //
);
bool isBullishSignalKey = isSignalKey &&
IsXBullish(iDir);
bool isBearishSignalKey = isSignalKey &&
IsXBearish(iDir);
if (isSignalKey)
iPattern = X_BAR_PATTERN_SIGNALKEY;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_SIGNALKEY;
has = IsSignalKeyBarPattern(
bar,
iDir,
config.pinBarShadowApprovedMultiplier,
config.pinBarRangeMultiplier,
config.pinBarForceDirection //
);
//
analysis.AddPattern(
canDetectBullish = config.CanDetect(
iPattern,
iDir //
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
IsXBullish(iDir) &&
canDetectBullish;
isBearish = has &&
IsXBearish(iDir) &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iDir //
);
}
}
//
@@ -2327,78 +2549,40 @@ class XCMarketPatternDetector : public XCBase
//
// OB ...
bool isOB = barAnalyser.IsOB(
bar,
iZone,
fvgForceType,
obForceTwoBar //
);
bool isBullishOB = isOB &&
iZone.IsBullish();
bool isBearishOB = isOB &&
iZone.IsBearish();
if (isOB)
iPattern = X_BAR_PATTERN_OB;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_OB;
//
analysis.AddPattern(
iPattern,
iZone.dir //
);
//
analysis.ob = iZone;
}
//
// FVG ...
bool isFVG = barAnalyser.IsFVG(
bar,
iZone,
fvgForceType //
);
bool isBullishFVG = isFVG &&
iZone.IsBullish();
bool isBearishFVG = isFVG &&
iZone.IsBearish();
if (isFVG)
{
//
iPattern = X_BAR_PATTERN_FVG;
//
analysis.AddPattern(
iPattern,
iZone.dir //
);
//
analysis.fvg = iZone;
}
//
// Support ...
bool isSupport = HasSupport(
bar,
iSwing,
supportAndResistanceValidationLength,
supportAndResistanceLoopbackLength //
);
if (isSupport)
{
//
iPattern = X_BAR_PATTERN_SUPPORT;
//
bool has = ToSupportBox(
iSwing,
has = barAnalyser.IsOB(
bar,
iZone,
bar.time,
supportAndResistanceValidationLength //
config.fvgForceType,
config.obForceTwoBar //
);
if (has)
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
iZone.IsBullish() &&
canDetectBullish;
isBearish = has &&
iZone.IsBearish() &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
@@ -2407,40 +2591,126 @@ class XCMarketPatternDetector : public XCBase
);
//
analysis.support = iZone;
analysis.ob = iZone;
}
}
//
// FVG ...
iPattern = X_BAR_PATTERN_FVG;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
has = barAnalyser.IsFVG(
bar,
iZone,
config.fvgForceType //
);
//
canDetectBullish = config.CanDetect(
iPattern,
X_DIRECTION_BULLISH //
);
canDetectBearish = config.CanDetect(
iPattern,
X_DIRECTION_BEARISH //
);
//
isBullish = has &&
iZone.IsBullish() &&
canDetectBullish;
isBearish = has &&
iZone.IsBearish() &&
canDetectBearish;
//
canDetect = isBullish ||
isBearish;
if (canDetect)
{
//
analysis.AddPattern(
iPattern,
iZone.dir //
);
//
analysis.fvg = iZone;
}
}
//
// Support ...
iPattern = X_BAR_PATTERN_SUPPORT;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
has = HasSupport(
bar,
iSwing,
config.supportAndResistanceValidationLength,
config.supportAndResistanceLoopbackLength //
);
if (has)
{
//
has = ToSupportBox(
iSwing,
iZone,
bar.time,
config.supportAndResistanceValidationLength //
);
if (has)
{
//
analysis.AddPattern(
iPattern,
iZone.dir //
);
//
analysis.support = iZone;
}
}
}
//
// Resistance ...
bool isResistance = HasResistance(
bar,
iSwing,
supportAndResistanceValidationLength,
supportAndResistanceLoopbackLength //
);
if (isResistance)
iPattern = X_BAR_PATTERN_RESISTANCE;
canDetect = config.CanDetect(iPattern);
if (canDetect)
{
//
iPattern = X_BAR_PATTERN_RESISTANCE;
//
bool has = ToResistanceBox(
has = HasResistance(
bar,
iSwing,
iZone,
bar.time,
supportAndResistanceValidationLength //
config.supportAndResistanceValidationLength,
config.supportAndResistanceLoopbackLength //
);
if (has)
{
//
analysis.AddPattern(
iPattern,
iZone.dir //
has = ToResistanceBox(
iSwing,
iZone,
bar.time,
config.supportAndResistanceValidationLength //
);
if (has)
{
//
analysis.AddPattern(
iPattern,
iZone.dir //
);
//
analysis.resistance = iZone;
//
analysis.resistance = iZone;
}
}
}
+694
View File
@@ -0,0 +1,694 @@
///////////////////////////////////////////////////////
//
// 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 ...
//
bool detectSwingTrend;
//
bool detectStarPattern;
bool detectFlagPattern;
bool detectRisingPattern;
bool detectPiercingPattern;
bool detectSignalKeyBarPattern;
//
bool detectPinned;
bool detectMomentum;
bool detectEngulfed;
bool detectTrueGaped;
//
bool analyseFIMAPVPivots;
bool analyseFIMAZigZagPivots;
//
bool detectMACrosses;
double validMACrossDiffMultiplier;
//
bool detectHKSwitches;
bool detectSARSwitches;
//
// Configs ...
//
// Trending ...
int trendingNumberOfSwings;
int trendingSwingShoulders;
//
// Support and Resistance ...
int zonesRequiredNumber;
int zonesValidationLength;
double zonesMinAlloweStrength;
int zonesBreakValidationLength;
double zonesBarShadowMultiplier;
int zonesMaxAllowedLoopbackLength;
//
// 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 numberOfRequiredPivotsForAnalysis;
int maxAllowedLoopbackLengthForAnalysis;
//
// Constructor ...
XFIMAPatternDetectorConfig()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
detectSwingTrend = false;
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
analyseFIMAPVPivots = false;
detectPiercingPattern = false;
analyseFIMAZigZagPivots = false;
detectSignalKeyBarPattern = false;
//
detectMACrosses = false;
validMACrossDiffMultiplier = 0;
//
detectHKSwitches = false;
detectSARSwitches = false;
//
zonesRequiredNumber = 0;
zonesValidationLength = 0;
zonesMinAlloweStrength = 0;
zonesBarShadowMultiplier = 0;
zonesBreakValidationLength = 0;
zonesMaxAllowedLoopbackLength = 0;
//
trendingNumberOfSwings = 0;
trendingSwingShoulders = 0;
momentumBarRangeLength = 0;
pvPivotsValidationLength = 0;
pinnedBarForceDirection = false;
momentumBarApprovedMultiplier = 0;
signalKeyBarForceDirection = false;
truwGapApprovedPointMultiplier = 0;
flagPatternMinimumPullbackBars = 0;
numberOfRequiredPivotsForAnalysis = 0;
pinnedBaarShadowApprovedMultiplier = 0;
maxAllowedLoopbackLengthForAnalysis = 0;
signalKeyBarShadowApprovedMultiplier = 0;
pinnedBarMinimumPinBarRangeMultiplier = 0;
signalKeyBarMinimumPinBarRangeMultiplier = 0;
//
ZeroMemory(this);
}
/**
* Default Model ...
*/
void Default()
{
//
// Patterns ...
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
//
// Bars ...
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
//
// Analysers ...
analyseFIMAPVPivots = false;
analyseFIMAZigZagPivots = false;
//
detectMACrosses = true;
validMACrossDiffMultiplier = 1;
//
detectHKSwitches = true;
detectSARSwitches = true;
//
// Trending ...
trendingNumberOfSwings = 3;
trendingSwingShoulders = 11;
//
// Support and Resistance ...
zonesRequiredNumber = 25;
zonesValidationLength = 21;
zonesMinAlloweStrength = 2;
zonesBarShadowMultiplier = 4;
zonesBreakValidationLength = 3;
zonesMaxAllowedLoopbackLength = 200;
//
// 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;
numberOfRequiredPivotsForAnalysis = 50;
maxAllowedLoopbackLengthForAnalysis = 1500;
}
/**
* Full Detection Model ...
*/
void FullDetect()
{
//
// Patterns ...
detectStarPattern = true;
detectFlagPattern = true;
detectRisingPattern = true;
detectPiercingPattern = true;
detectSignalKeyBarPattern = true;
//
// Bars ...
detectPinned = true;
detectMomentum = true;
detectEngulfed = true;
detectTrueGaped = true;
//
// Analysers ...
analyseFIMAPVPivots = true;
analyseFIMAZigZagPivots = true;
//
detectMACrosses = true;
detectHKSwitches = true;
detectSARSwitches = true;
}
/**
* Default Config, by turn off all detecting flags ...
*/
void OffDetectors()
{
//
// Patterns ...
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
//
// Bars ...
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
//
// Analysers ...
analyseFIMAPVPivots = false;
analyseFIMAZigZagPivots = false;
//
detectMACrosses = false;
detectHKSwitches = false;
detectSARSwitches = false;
}
//
};
/**
* XFIMA Base Market Structure ...
* AnalyseMarket result ...
**/
struct XFIMAMarketStructure
{
//
XOHCL bar;
//
XBoxZone obs[];
XBoxZone fvgs[];
XBoxZone supports[];
XBoxZone resistances[];
//
XPivot pinBars[];
XPivot engulfBars[];
XPivot trueGapBars[];
XPivot momentumBars[];
//
XBoxZone flagPatterns[];
XBoxZone starPatterns[];
XBoxZone risingPatterns[];
XBoxZone piercingPatterns[];
XBoxZone signalKeyBarPatterns[];
//
// Analysis ...
XPivotAnalysis pvAnalysis;
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;
//
ENUM_X_DIRECTION maCrossDir;
XPivot maCrosses[];
//
ENUM_X_DIRECTION hkSwitchDir;
XPivot hkSwitches[];
//
ENUM_X_DIRECTION sarSwitchDir;
XPivot sarSwitches[];
//
// Constructor ...
XFIMAMarketStructure()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
bar.Clean();
flagSwing.Clean();
//
pvAnalysis.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;
//
maCrossDir = X_DIRECTION_NONE;
SpecifiedClean(maCrosses);
//
hkSwitchDir = X_DIRECTION_NONE;
SpecifiedClean(hkSwitches);
//
sarSwitchDir = X_DIRECTION_NONE;
SpecifiedClean(sarSwitches);
//
SpecifiedClean(obs);
SpecifiedClean(fvgs);
SpecifiedClean(pinBars);
SpecifiedClean(supports);
SpecifiedClean(engulfBars);
SpecifiedClean(resistances);
SpecifiedClean(trueGapBars);
SpecifiedClean(momentumBars);
SpecifiedClean(flagPatterns);
SpecifiedClean(starPatterns);
SpecifiedClean(risingPatterns);
SpecifiedClean(piercingPatterns);
SpecifiedClean(signalKeyBarPatterns);
//
SpecifiedClean(trendSwings);
//
ZeroMemory(this);
}
//
// Checker Functions ...
//
};
/**
* Configure Market Structure Drawer ...
**/
struct XFIMAMarketStructureDrawerConfig
{
//
// Props ...
//
bool drawOB; // Current Order Block ...
bool drawFVG; // Current Fair Value Gap ...
//
bool drawSupport; // Detected Supports ...
bool drawResistance; // Detected Resistances ...
//
bool drawSwingTrend; // Swing Trend ...
bool swingTrendRayLeft; // Ray Left Swing Trend ...
bool swingTrendRayRight; // Ray Right Swing Trend ...
//
// Draw Current Detected Patterns ...
//
bool drawPinned;
bool drawMomentum;
bool drawEngulfed;
bool drawTrueGaped;
//
bool drawStarPattern;
bool drawFlagPattern;
bool drawRisingPattern;
bool drawPiercingPattern;
bool drawSignalKeyBarPattern;
//
// Draw Recently Zones ...
bool drawRecentPatterns;
bool drawFakeBreakedZone;
bool drawRecentlyTestedZones;
bool drawRecentlyBreakedZones;
//
// Draw Analysis Pivots ...
//
// XPV ...
bool drawFIMAPVPivotsAnalysis;
bool drawFIMAPVPivotsAnalysisZones;
bool drawFIMAPVPivotsAnalysisTrends;
bool drawFIMAPVPivotsAnalysisPivots;
//
// XSAR ...
bool drawFIMASARPivotsAnalysis;
bool drawFIMASARPivotsAnalysisZones;
bool drawFIMASARPivotsAnalysisTrends;
bool drawFIMASARPivotsAnalysisPivots;
//
// XZIGZAG ...
bool drawFIMAZigZagPivotsAnalysis;
bool drawFIMAZigZagPivotsAnalysisZones;
bool drawFIMAZigZagPivotsAnalysisTrends;
bool drawFIMAZigZagPivotsAnalysisPivots;
//
// Constructor ...
XFIMAMarketStructureDrawerConfig()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
drawOB = false;
drawFVG = false;
drawPinned = false;
drawMomentum = false;
drawSupport = false;
drawEngulfed = false;
drawTrueGaped = false;
drawResistance = false;
drawSwingTrend = false;
drawStarPattern = false;
drawFlagPattern = false;
swingTrendRayLeft = false;
drawRisingPattern = false;
swingTrendRayRight = false;
drawPiercingPattern = false;
drawSignalKeyBarPattern = false;
//
drawRecentPatterns = false;
drawFakeBreakedZone = false;
drawRecentlyTestedZones = false;
drawRecentlyBreakedZones = false;
//
drawFIMAPVPivotsAnalysis = false;
drawFIMAPVPivotsAnalysisZones = false;
drawFIMAPVPivotsAnalysisTrends = false;
drawFIMAPVPivotsAnalysisPivots = false;
//
drawFIMASARPivotsAnalysis = false;
drawFIMASARPivotsAnalysisZones = false;
drawFIMASARPivotsAnalysisTrends = false;
drawFIMASARPivotsAnalysisPivots = false;
//
drawFIMAZigZagPivotsAnalysis = false;
drawFIMAZigZagPivotsAnalysisZones = false;
drawFIMAZigZagPivotsAnalysisTrends = false;
drawFIMAZigZagPivotsAnalysisPivots = false;
//
ZeroMemory(this);
}
/**
* Default Model ...
*/
void Default()
{
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupport = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
drawPiercingPattern = true;
swingTrendRayLeft = false;
swingTrendRayRight = true;
drawSignalKeyBarPattern = true;
//
drawRecentPatterns = true;
drawFakeBreakedZone = true;
drawRecentlyTestedZones = true;
drawRecentlyBreakedZones = true;
//
drawFIMAPVPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisZones = true;
drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true;
drawFIMASARPivotsAnalysisTrends = true;
drawFIMASARPivotsAnalysisPivots = true;
//
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysisZones = true;
drawFIMAZigZagPivotsAnalysisTrends = true;
drawFIMAZigZagPivotsAnalysisPivots = true;
}
/**
* Configure for Full Drawing ...
*/
void FullDraw()
{
//
Default();
//
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupport = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
swingTrendRayLeft = true;
swingTrendRayRight = true;
drawPiercingPattern = true;
drawSignalKeyBarPattern = true;
//
drawRecentPatterns = true;
drawFakeBreakedZone = true;
drawRecentlyTestedZones = true;
drawRecentlyBreakedZones = true;
//
drawFIMAPVPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisZones = true;
drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true;
drawFIMASARPivotsAnalysisTrends = true;
drawFIMASARPivotsAnalysisPivots = true;
//
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysisZones = true;
drawFIMAZigZagPivotsAnalysisTrends = true;
drawFIMAZigZagPivotsAnalysisPivots = true;
}
//
};
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -153,9 +153,9 @@ XCBackTesterEA *eaExpert; // EA Expert ...
XCXFIMAStrategy1Signaller *fima1Signaller; // XFIMA1 Signaller ...
//
XFIMAMarketStructure marketStructure; // POI Analysis Result ...
XFIMAPatternDetectorConfig detectorConfig; // POI Detector Config ...
XFIMAMarketStructureDrawerConfig marketStructureDrawerConfig; // POI Drawer Config ...
// XFIMAMarketStructure marketStructure; // POI Analysis Result ...
// XFIMAPatternDetectorConfig detectorConfig; // POI Detector Config ...
// XFIMAMarketStructureDrawerConfig marketStructureDrawerConfig; // POI Drawer Config ...
//
// Drawer and eaDraws ...
@@ -426,9 +426,9 @@ int OnInit()
//
// Configure XFIMA POI Detector / Drawer ...
detectorConfig.Default();
detectorConfig.FullDetect();
marketStructureDrawerConfig.FullDraw();
// detectorConfig.Default();
// detectorConfig.FullDetect();
// marketStructureDrawerConfig.FullDraw();
//
Print(ShortName, ": Initialized Successfully ...");
+268 -1
View File
@@ -908,6 +908,14 @@ class XCXFIMAHelper : public XCBaseHelper
barIndex = NormalizeInt(barIndex, 0);
validCrossDiffMultiplier = NormalizeDouble(validCrossDiffMultiplier, 0);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double fast[];
int fastCount = CopyMAFast(barIndex, 2, fast);
@@ -1107,7 +1115,7 @@ class XCXFIMAHelper : public XCBaseHelper
//
// Validate ...
result = mHandler != INVALID_HANDLE;
result = IsValid();
if (!result)
{
return result;
@@ -1166,6 +1174,262 @@ class XCXFIMAHelper : public XCBaseHelper
return result;
}
/**
* Check Specified Bar's Price in Hot Place or Not ...
*
* @param dir: reference for holds cross Direction ...
* @param barIndex: int, Specified Bar Index ...
* @param overMaxPriceType: ENUM_X_PRICE, which price of Specified bar to Check ...
* @param underMinPriceType: ENUM_X_PRICE, which price of Specified bar to Check ...
*
* @return ( bool )
*/
bool IsInHotPlace(
ENUM_X_DIRECTION &dir,
int barIndex = 0,
ENUM_X_PRICE overMaxPriceType = X_PRICE_NONE,
ENUM_X_PRICE underMinPriceType = X_PRICE_NONE //
)
{
//
bool result = false;
//
// Prepare ...
dir = X_DIRECTION_NONE;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
if (!IsXValid(overMaxPriceType))
{
overMaxPriceType = X_PRICE_LOW;
}
if (!IsXValid(underMinPriceType))
{
underMinPriceType = X_PRICE_HIGH;
}
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
// Initialize Bar ...
XOHCL bar;
result = bar.Init(
mSymbol,
mPeriod,
barIndex);
if (!result)
{
//
bar.Clean();
return result;
}
//
double overMaxPrice = bar.GetPrice(overMaxPriceType);
double underMinPrice = bar.GetPrice(underMinPriceType);
//
// Reading Boundary Value ...
double min;
double max;
result = GetBoundaryValues(
min,
max,
barIndex //
);
if (!result)
{
//
bar.Clean();
return result;
}
//
bool isBullish = underMinPrice < min;
bool isBearish = overMaxPrice > max;
//
result = (isBullish && !isBearish) ||
(isBearish && !isBullish);
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
}
//
// Cleanup Resources ...
bar.Clean();
//
return result;
}
bool (
ENUM_X_DIRECTION &dir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Prepare ...
dir = X_DIRECTION_NONE;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double fast = GetMAFast(barIndex);
double slow = GetMASlow(barIndex);
//
double maBondUpper = GetMABondUpper(barIndex);
double maBondLower = GetMABondLower(barIndex);
//
double pbBondUpper = GetPBBondUpper(barIndex);
double pbBondLower = GetPBBondLower(barIndex);
//
double hkBondUpper = GetHKBondUpper(barIndex);
double hkBondLower = GetHKBondLower(barIndex);
//
result =
NotEmptyZero(fast) &&
NotEmptyZero(slow) &&
NotEmptyZero(maBondUpper) &&
NotEmptyZero(maBondLower) &&
NotEmptyZero(hkBondUpper) &&
NotEmptyZero(hkBondLower) &&
NotEmptyZero(pbBondUpper) &&
NotEmptyZero(pbBondLower);
if (!result)
{
return result;
}
//
bool isBullish =
fast > hkBondLower &&
slow > hkBondLower &&
maBondUpper > hkBondLower &&
maBondLower > hkBondLower &&
pbBondUpper > hkBondLower &&
pbBondLower > hkBondLower;
bool isBearish =
fast < hkBondUpper &&
slow < hkBondUpper &&
maBondUpper < hkBondUpper &&
maBondLower < hkBondUpper &&
pbBondUpper < hkBondUpper &&
pbBondLower < hkBondUpper;
//
result = (isBullish && !isBearish) ||
(isBearish && !isBullish);
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
}
//
return result;
}
bool HasBoundarySwitch(
ENUM_X_DIRECTION &dir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Prepare ...
dir = X_DIRECTION_NONE;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
result = HasBoundaryTrend(
dir,
barIndex //
);
if (!result)
{
return result;
}
bool isBullish = IsXBullish(dir);
bool isBearish = IsXBearish(dir);
//
result = HasBoundaryTrend(
dir,
barIndex + 1 //
);
if (!result)
{
return result;
}
bool isPBullish = IsXBullish(dir);
bool isPBearish = IsXBearish(dir);
//
bool isSwitchedToBullish =
isBullish && !isPBullish;
bool isSwitchedToBearish =
isBearish && !isPBearish;
result = isSwitchedToBullish ||
isSwitchedToBearish;
if (result)
{
//
dir = isSwitchedToBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
}
//
return result;
}
/**
* Check Peak Happens over Last ...
*
@@ -3101,6 +3365,9 @@ class XCXFIMAHelper : public XCBaseHelper
return result;
}
//
// Detectors ...
/**
* Detect Zones (Support / Resistance) based on XFIMA Validators ...
*
@@ -2303,10 +2303,286 @@ struct XPatternAnalysis
//
};
struct XPatternAnalysisConfig
{
//
// Props ...
//
// PV ...
int pvValidationLength;
ENUM_X_PRICE peakPriceType;
ENUM_X_PRICE valePriceType;
//
// Momentum ...
int momentumBarValidationLength;
double momentumBarApprovedMultiplier;
//
// TrueGap ...
double trueGapApprovedStrength;
//
// Pin ...
double pinBarShadowApprovedMultiplier;
double pinBarRangeMultiplier;
bool pinBarForceDirection;
//
// Flag ...
int flagPatternPullbackLength;
//
// FVG ...
bool fvgForceType;
//
// OB ...
bool obForceTwoBar;
//
// Support and Resistance ...
int supportAndResistanceValidationLength;
int supportAndResistanceLoopbackLength;
//
ENUM_X_DIRECTION allowedDirs[];
ENUM_X_BAR_PATTERN allowedPatterns[];
//
// Constructor ...
XPatternAnalysisConfig()
{
Clean();
}
//
// Tools ...
/**
* Cleanup ...
*/
void Clean()
{
//
// PV ...
pvValidationLength = 0;
peakPriceType = X_PRICE_NONE;
valePriceType = X_PRICE_NONE;
//
// Momentum ...
momentumBarValidationLength = 0;
momentumBarApprovedMultiplier = 0;
//
// TrueGap ...
trueGapApprovedStrength = 0;
//
// Pin ...
pinBarShadowApprovedMultiplier = 0;
pinBarRangeMultiplier = 0;
pinBarForceDirection = false;
//
// Flag ...
flagPatternPullbackLength = 0;
//
// FVG ...
fvgForceType = false;
//
// OB ...
obForceTwoBar = false;
//
// Support and Resistance ...
supportAndResistanceValidationLength = 0;
supportAndResistanceLoopbackLength = 0;
//
XClean(allowedDirs);
XClean(allowedPatterns);
//
ZeroMemory(this);
}
/**
* Default Configurations ...
*/
void Default()
{
//
// PV ...
pvValidationLength = 7;
peakPriceType = X_PRICE_HIGH;
valePriceType = X_PRICE_LOW;
//
// Momentum ...
momentumBarValidationLength = 3;
momentumBarApprovedMultiplier = 3;
//
// TrueGap ...
trueGapApprovedStrength = 1;
//
// Pin ...
pinBarShadowApprovedMultiplier = 3;
pinBarRangeMultiplier = 4;
pinBarForceDirection = false;
//
// Flag ...
flagPatternPullbackLength = 3;
//
// FVG ...
fvgForceType = false;
//
// OB ...
obForceTwoBar = false;
//
// Support and Resistance ...
supportAndResistanceValidationLength = 21;
supportAndResistanceLoopbackLength = 50;
}
//
// Permissions ...
/**
* Check Specified Patterns Detection is Allowed or not ...
*
* @param pattern: ENUM_X_BAR_PATTERN, Specified Pattern to Detect ...
* @param patternDir: ENUM_X_DIRECTION, which Pattern Direction to Detect ...
*
* @return ( bool )
*/
bool CanDetect(
ENUM_X_BAR_PATTERN pattern,
ENUM_X_DIRECTION patternDir = X_DIRECTION_NONE //
)
{
//
bool result = false;
//
// Validate Pattern and
// Check Pattern Exists ...
result = IsXValid(pattern) &&
HasChild(allowedPatterns) &&
Contains(pattern, allowedPatterns);
if (!result)
{
return result;
}
//
// Now Check Direction ...
int index = FindIndex(pattern, allowedPatterns);
result = IsValidIndex(index) &&
HasChild(allowedDirs) &&
(!HasDirection(patternDir)
? !HasDirection(allowedDirs[index])
: (!HasDirection(allowedDirs[index]) ||
patternDir == allowedDirs[index]));
//
return result;
}
//
// Collection Manipulations ...
/**
* Full Detect Patterns ...
*
* @param forDir: ENUM_X_DIRECTION, which Pattern Direction to Detect ...
*/
void FullPattern(
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
)
{
//
int count = GetAllBarPatters(allowedPatterns);
for (int i = 0; i < count; i++)
{
//
Add(
forDir,
allowedDirs //
);
}
}
/**
* Add Specified Pattern to Detecte ...
*
* @param pattern: ENUM_X_BAR_PATTERN, Specified Pattern to Detect ...
* @param patternDir: ENUM_X_DIRECTION, which Pattern Direction to Detect ...
*/
void AddPattern(
ENUM_X_BAR_PATTERN pattern,
ENUM_X_DIRECTION patternDir = X_DIRECTION_NONE //
)
{
//
bool has = IsXValid(pattern);
if (!has)
{
return;
}
//
Add(
pattern,
allowedPatterns //
);
//
Add(
patternDir,
allowedDirs //
);
}
//
};
struct XPatternAnalysisDrawConfig
{
//
// Props ...
//
int zonesWidth;
bool fillZones;
int arrowsWidth;
bool ignoreZonesAt;
int arrowsThreshold;
ENUM_LINE_STYLE zonesStyle;
//
int bullishArrow;
int bearishArrow;
//
color bullishColor;
color bearishColor;
//
ENUM_X_PRICE arrowValePriceType;
ENUM_X_PRICE arrowPeakPriceType;
//
ENUM_X_BAR_PATTERN allowedDraws[]; // Allowed Draw Patterns
ENUM_X_BAR_PATTERN allowedDrawZones[]; // Allowed Draw Pattern Zones
ENUM_X_BAR_PATTERN allowedDrawPivots[]; // Allowed Draw Pattern Pivots
@@ -2326,6 +2602,20 @@ struct XPatternAnalysisDrawConfig
*/
void Clean()
{
//
arrowsWidth = 0;
zonesWidth = 0;
bullishArrow = 0;
bearishArrow = 0;
fillZones = false;
arrowsThreshold = 0;
ignoreZonesAt = false;
bullishColor = CLR_NONE;
bearishColor = CLR_NONE;
zonesStyle = STYLE_SOLID;
arrowValePriceType = X_PRICE_NONE;
arrowPeakPriceType = X_PRICE_NONE;
//
XClean(allowedDraws);
XClean(allowedDrawZones);
@@ -2337,6 +2627,20 @@ struct XPatternAnalysisDrawConfig
*/
void Default()
{
//
zonesWidth = 1;
arrowsWidth = 1;
arrowsThreshold = 2;
bullishArrow = 159;
bearishArrow = 159;
fillZones = false;
ignoreZonesAt = true;
bullishColor = clrAqua;
zonesStyle = STYLE_SOLID;
bearishColor = clrMagenta;
arrowValePriceType = X_PRICE_LOW;
arrowPeakPriceType = X_PRICE_HIGH;
//
FullDraw();
+14 -26
View File
@@ -3995,7 +3995,6 @@ bool ToBox(
iLower = bar.FindLowest(idx, mLength, valePriceType);
iUpper = bar.FindHighest(idx, mLength, peakPriceType);
}
}
break;
@@ -4019,7 +4018,7 @@ bool ToBox(
}
//
iUpper = valePrice;
iUpper = peakPrice;
iLower = valePrice;
}
break;
@@ -4044,14 +4043,8 @@ bool ToBox(
}
//
iUpper =
isBullish
? peakPrice
: valePrice;
iLower =
isBullish
? peakPrice
: valePrice;
iUpper = peakPrice;
iLower = valePrice;
}
break;
@@ -4075,14 +4068,10 @@ bool ToBox(
}
//
iUpper =
isBullish
? peakPrice
: valePrice;
iLower =
isBullish
? peakPrice
: valePrice;
int idx = -1;
int mLength = 3;
iUpper = bar.FindHighest(idx, mLength, peakPriceType);
iLower = bar.FindLowest(idx, mLength, valePriceType);
}
break;
@@ -4106,14 +4095,13 @@ bool ToBox(
}
//
iUpper =
isBullish
? peakPrice
: valePrice;
iLower =
isBullish
? peakPrice
: valePrice;
has = bar.GetPreviousBar(tmpBar);
if (has)
{
//
iUpper = MathMax(peakPrice, tmpBar.GetPrice(peakPriceType));
iLower = MathMin(valePrice, tmpBar.GetPrice(valePriceType));
}
}
break;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-534
View File
@@ -37,82 +37,6 @@ struct XFIMAPatternDetectorConfig
//
// Props ...
//
bool detectSwingTrend;
//
bool detectStarPattern;
bool detectFlagPattern;
bool detectRisingPattern;
bool detectPiercingPattern;
bool detectSignalKeyBarPattern;
//
bool detectPinned;
bool detectMomentum;
bool detectEngulfed;
bool detectTrueGaped;
//
bool analyseFIMAPVPivots;
bool analyseFIMAZigZagPivots;
//
bool detectMACrosses;
double validMACrossDiffMultiplier;
//
bool detectHKSwitches;
bool detectSARSwitches;
//
// Configs ...
//
// Trending ...
int trendingNumberOfSwings;
int trendingSwingShoulders;
//
// Support and Resistance ...
int zonesRequiredNumber;
int zonesValidationLength;
double zonesMinAlloweStrength;
int zonesBreakValidationLength;
double zonesBarShadowMultiplier;
int zonesMaxAllowedLoopbackLength;
//
// 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 numberOfRequiredPivotsForAnalysis;
int maxAllowedLoopbackLengthForAnalysis;
//
// Constructor ...
XFIMAPatternDetectorConfig()
@@ -128,54 +52,6 @@ struct XFIMAPatternDetectorConfig
*/
void Clean()
{
//
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
detectSwingTrend = false;
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
analyseFIMAPVPivots = false;
detectPiercingPattern = false;
analyseFIMAZigZagPivots = false;
detectSignalKeyBarPattern = false;
//
detectMACrosses = false;
validMACrossDiffMultiplier = 0;
//
detectHKSwitches = false;
detectSARSwitches = false;
//
zonesRequiredNumber = 0;
zonesValidationLength = 0;
zonesMinAlloweStrength = 0;
zonesBarShadowMultiplier = 0;
zonesBreakValidationLength = 0;
zonesMaxAllowedLoopbackLength = 0;
//
trendingNumberOfSwings = 0;
trendingSwingShoulders = 0;
momentumBarRangeLength = 0;
pvPivotsValidationLength = 0;
pinnedBarForceDirection = false;
momentumBarApprovedMultiplier = 0;
signalKeyBarForceDirection = false;
truwGapApprovedPointMultiplier = 0;
flagPatternMinimumPullbackBars = 0;
numberOfRequiredPivotsForAnalysis = 0;
pinnedBaarShadowApprovedMultiplier = 0;
maxAllowedLoopbackLengthForAnalysis = 0;
signalKeyBarShadowApprovedMultiplier = 0;
pinnedBarMinimumPinBarRangeMultiplier = 0;
signalKeyBarMinimumPinBarRangeMultiplier = 0;
//
ZeroMemory(this);
}
@@ -184,78 +60,6 @@ struct XFIMAPatternDetectorConfig
*/
void Default()
{
//
// Patterns ...
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
//
// Bars ...
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
//
// Analysers ...
analyseFIMAPVPivots = false;
analyseFIMAZigZagPivots = false;
//
detectMACrosses = true;
validMACrossDiffMultiplier = 1;
//
detectHKSwitches = true;
detectSARSwitches = true;
//
// Trending ...
trendingNumberOfSwings = 3;
trendingSwingShoulders = 11;
//
// Support and Resistance ...
zonesRequiredNumber = 25;
zonesValidationLength = 21;
zonesMinAlloweStrength = 2;
zonesBarShadowMultiplier = 4;
zonesBreakValidationLength = 3;
zonesMaxAllowedLoopbackLength = 200;
//
// 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;
numberOfRequiredPivotsForAnalysis = 50;
maxAllowedLoopbackLengthForAnalysis = 1500;
}
/**
@@ -263,30 +67,6 @@ struct XFIMAPatternDetectorConfig
*/
void FullDetect()
{
//
// Patterns ...
detectStarPattern = true;
detectFlagPattern = true;
detectRisingPattern = true;
detectPiercingPattern = true;
detectSignalKeyBarPattern = true;
//
// Bars ...
detectPinned = true;
detectMomentum = true;
detectEngulfed = true;
detectTrueGaped = true;
//
// Analysers ...
analyseFIMAPVPivots = true;
analyseFIMAZigZagPivots = true;
//
detectMACrosses = true;
detectHKSwitches = true;
detectSARSwitches = true;
}
/**
@@ -294,30 +74,6 @@ struct XFIMAPatternDetectorConfig
*/
void OffDetectors()
{
//
// Patterns ...
detectStarPattern = false;
detectFlagPattern = false;
detectRisingPattern = false;
detectPiercingPattern = false;
detectSignalKeyBarPattern = false;
//
// Bars ...
detectPinned = false;
detectMomentum = false;
detectEngulfed = false;
detectTrueGaped = false;
//
// Analysers ...
analyseFIMAPVPivots = false;
analyseFIMAZigZagPivots = false;
//
detectMACrosses = false;
detectHKSwitches = false;
detectSARSwitches = false;
}
//
@@ -332,62 +88,6 @@ struct XFIMAMarketStructure
//
XOHCL bar;
//
XBoxZone obs[];
XBoxZone fvgs[];
XBoxZone supports[];
XBoxZone resistances[];
//
XPivot pinBars[];
XPivot engulfBars[];
XPivot trueGapBars[];
XPivot momentumBars[];
//
XBoxZone flagPatterns[];
XBoxZone starPatterns[];
XBoxZone risingPatterns[];
XBoxZone piercingPatterns[];
XBoxZone signalKeyBarPatterns[];
//
// Analysis ...
XPivotAnalysis pvAnalysis;
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;
//
ENUM_X_DIRECTION maCrossDir;
XPivot maCrosses[];
//
ENUM_X_DIRECTION hkSwitchDir;
XPivot hkSwitches[];
//
ENUM_X_DIRECTION sarSwitchDir;
XPivot sarSwitches[];
//
// Constructor ...
XFIMAMarketStructure()
@@ -403,55 +103,6 @@ struct XFIMAMarketStructure
*/
void Clean()
{
//
bar.Clean();
flagSwing.Clean();
//
pvAnalysis.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;
//
maCrossDir = X_DIRECTION_NONE;
SpecifiedClean(maCrosses);
//
hkSwitchDir = X_DIRECTION_NONE;
SpecifiedClean(hkSwitches);
//
sarSwitchDir = X_DIRECTION_NONE;
SpecifiedClean(sarSwitches);
//
SpecifiedClean(obs);
SpecifiedClean(fvgs);
SpecifiedClean(pinBars);
SpecifiedClean(supports);
SpecifiedClean(engulfBars);
SpecifiedClean(resistances);
SpecifiedClean(trueGapBars);
SpecifiedClean(momentumBars);
SpecifiedClean(flagPatterns);
SpecifiedClean(starPatterns);
SpecifiedClean(risingPatterns);
SpecifiedClean(piercingPatterns);
SpecifiedClean(signalKeyBarPatterns);
//
SpecifiedClean(trendSwings);
//
ZeroMemory(this);
@@ -471,66 +122,6 @@ struct XFIMAMarketStructureDrawerConfig
//
// Props ...
//
bool drawOB; // Current Order Block ...
bool drawFVG; // Current Fair Value Gap ...
//
bool drawSupport; // Detected Supports ...
bool drawResistance; // Detected Resistances ...
//
bool drawSwingTrend; // Swing Trend ...
bool swingTrendRayLeft; // Ray Left Swing Trend ...
bool swingTrendRayRight; // Ray Right Swing Trend ...
//
// Draw Current Detected Patterns ...
//
bool drawPinned;
bool drawMomentum;
bool drawEngulfed;
bool drawTrueGaped;
//
bool drawStarPattern;
bool drawFlagPattern;
bool drawRisingPattern;
bool drawPiercingPattern;
bool drawSignalKeyBarPattern;
//
// Draw Recently Zones ...
bool drawRecentPatterns;
bool drawFakeBreakedZone;
bool drawRecentlyTestedZones;
bool drawRecentlyBreakedZones;
//
// Draw Analysis Pivots ...
//
// XPV ...
bool drawFIMAPVPivotsAnalysis;
bool drawFIMAPVPivotsAnalysisZones;
bool drawFIMAPVPivotsAnalysisTrends;
bool drawFIMAPVPivotsAnalysisPivots;
//
// XSAR ...
bool drawFIMASARPivotsAnalysis;
bool drawFIMASARPivotsAnalysisZones;
bool drawFIMASARPivotsAnalysisTrends;
bool drawFIMASARPivotsAnalysisPivots;
//
// XZIGZAG ...
bool drawFIMAZigZagPivotsAnalysis;
bool drawFIMAZigZagPivotsAnalysisZones;
bool drawFIMAZigZagPivotsAnalysisTrends;
bool drawFIMAZigZagPivotsAnalysisPivots;
//
// Constructor ...
XFIMAMarketStructureDrawerConfig()
@@ -546,47 +137,6 @@ struct XFIMAMarketStructureDrawerConfig
*/
void Clean()
{
//
drawOB = false;
drawFVG = false;
drawPinned = false;
drawMomentum = false;
drawSupport = false;
drawEngulfed = false;
drawTrueGaped = false;
drawResistance = false;
drawSwingTrend = false;
drawStarPattern = false;
drawFlagPattern = false;
swingTrendRayLeft = false;
drawRisingPattern = false;
swingTrendRayRight = false;
drawPiercingPattern = false;
drawSignalKeyBarPattern = false;
//
drawRecentPatterns = false;
drawFakeBreakedZone = false;
drawRecentlyTestedZones = false;
drawRecentlyBreakedZones = false;
//
drawFIMAPVPivotsAnalysis = false;
drawFIMAPVPivotsAnalysisZones = false;
drawFIMAPVPivotsAnalysisTrends = false;
drawFIMAPVPivotsAnalysisPivots = false;
//
drawFIMASARPivotsAnalysis = false;
drawFIMASARPivotsAnalysisZones = false;
drawFIMASARPivotsAnalysisTrends = false;
drawFIMASARPivotsAnalysisPivots = false;
//
drawFIMAZigZagPivotsAnalysis = false;
drawFIMAZigZagPivotsAnalysisZones = false;
drawFIMAZigZagPivotsAnalysisTrends = false;
drawFIMAZigZagPivotsAnalysisPivots = false;
//
ZeroMemory(this);
@@ -597,46 +147,6 @@ struct XFIMAMarketStructureDrawerConfig
*/
void Default()
{
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupport = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
drawPiercingPattern = true;
swingTrendRayLeft = false;
swingTrendRayRight = true;
drawSignalKeyBarPattern = true;
//
drawRecentPatterns = true;
drawFakeBreakedZone = true;
drawRecentlyTestedZones = true;
drawRecentlyBreakedZones = true;
//
drawFIMAPVPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisZones = true;
drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true;
drawFIMASARPivotsAnalysisTrends = true;
drawFIMASARPivotsAnalysisPivots = true;
//
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysisZones = true;
drawFIMAZigZagPivotsAnalysisTrends = true;
drawFIMAZigZagPivotsAnalysisPivots = true;
}
/**
@@ -644,50 +154,6 @@ struct XFIMAMarketStructureDrawerConfig
*/
void FullDraw()
{
//
Default();
//
drawOB = true;
drawFVG = true;
drawPinned = true;
drawMomentum = true;
drawSupport = true;
drawEngulfed = true;
drawTrueGaped = true;
drawResistance = true;
drawSwingTrend = true;
drawStarPattern = true;
drawFlagPattern = true;
drawRisingPattern = true;
swingTrendRayLeft = true;
swingTrendRayRight = true;
drawPiercingPattern = true;
drawSignalKeyBarPattern = true;
//
drawRecentPatterns = true;
drawFakeBreakedZone = true;
drawRecentlyTestedZones = true;
drawRecentlyBreakedZones = true;
//
drawFIMAPVPivotsAnalysis = true;
drawFIMAPVPivotsAnalysisZones = true;
drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true;
drawFIMASARPivotsAnalysisTrends = true;
drawFIMASARPivotsAnalysisPivots = true;
//
drawFIMAZigZagPivotsAnalysis = true;
drawFIMAZigZagPivotsAnalysisZones = true;
drawFIMAZigZagPivotsAnalysisTrends = true;
drawFIMAZigZagPivotsAnalysisPivots = true;
}
//