last works on Peak and Vales ...
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#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.lib.mq5"
|
||||
|
||||
//
|
||||
@@ -715,7 +716,7 @@ class XCMarketPatternDetector : public XCBase
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsStartPattern(
|
||||
bool IsStarPattern(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
@@ -1074,7 +1075,6 @@ class XCMarketPatternDetector : public XCBase
|
||||
* @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 )
|
||||
*/
|
||||
@@ -1967,6 +1967,494 @@ class XCMarketPatternDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Analysers ...
|
||||
|
||||
/**
|
||||
* Analyse Specified Bar ...
|
||||
*
|
||||
* @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 ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
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 = 2,
|
||||
//
|
||||
// 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 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
analysis.Clean();
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
//
|
||||
pvValidationLength = NormalizeInt(pvValidationLength, 2);
|
||||
|
||||
//
|
||||
momentumBarValidationLength = NormalizeInt(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();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
analysis.bar = bar;
|
||||
analysis.time = TimeCurrent();
|
||||
|
||||
//
|
||||
XOHCL iSwing;
|
||||
XBoxZone iZone;
|
||||
ENUM_X_DIRECTION iDir;
|
||||
ENUM_X_BAR_PATTERN iPattern;
|
||||
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
//
|
||||
iPattern =
|
||||
isHigh
|
||||
? 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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
analysis.AddPattern(
|
||||
iPattern,
|
||||
iDir //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Pattern Detectors ...
|
||||
|
||||
//
|
||||
// Star ...
|
||||
bool isStar = IsStarPattern(
|
||||
bar,
|
||||
iDir //
|
||||
);
|
||||
bool isBullishStar = isStar &&
|
||||
IsXBullish(iDir);
|
||||
bool isBearishStar = isStar &&
|
||||
IsXBearish(iDir);
|
||||
if (isStar)
|
||||
{
|
||||
//
|
||||
iPattern = X_BAR_PATTERN_STAR;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
analysis.AddPattern(
|
||||
iPattern,
|
||||
iDir //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Zone Detectors ...
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
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,
|
||||
iZone,
|
||||
bar.time //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.AddPattern(
|
||||
iPattern,
|
||||
iZone.dir //
|
||||
);
|
||||
|
||||
//
|
||||
analysis.support = iZone;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
bool isResistance = HasResistance(
|
||||
bar,
|
||||
iSwing,
|
||||
supportAndResistanceValidationLength,
|
||||
supportAndResistanceLoopbackLength //
|
||||
);
|
||||
if (isMomentum)
|
||||
{
|
||||
//
|
||||
iPattern = X_BAR_PATTERN_RESISTANCE;
|
||||
|
||||
//
|
||||
bool has = ToResistanceBox(
|
||||
iSwing,
|
||||
iZone,
|
||||
bar.time //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.AddPattern(
|
||||
iPattern,
|
||||
iZone.dir //
|
||||
);
|
||||
|
||||
//
|
||||
analysis.resistance = iZone;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Analysis ...
|
||||
result = analysis.IsValid();
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iZone.Clean();
|
||||
iSwing.Clean();
|
||||
CleanDirection(iDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user