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.base.class.mq5"
|
||||||
#include "../Classes/x-saherelm.x-bar.analyser.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-poi.extensions.lib.mq5"
|
||||||
|
#include "../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||||
#include "../Libraries/x-saherelm.x-poi.lib.mq5"
|
#include "../Libraries/x-saherelm.x-poi.lib.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -715,7 +716,7 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool IsStartPattern(
|
bool IsStarPattern(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
ENUM_X_DIRECTION &dir //
|
ENUM_X_DIRECTION &dir //
|
||||||
)
|
)
|
||||||
@@ -1074,7 +1075,6 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
|
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
|
||||||
* @param swingBar: XOHCL, Detected Swing Bar ...
|
* @param swingBar: XOHCL, Detected Swing Bar ...
|
||||||
* @param minimumPullbackBars: int, Minimum Shoulders of Swing Bar ...
|
* @param minimumPullbackBars: int, Minimum Shoulders of Swing Bar ...
|
||||||
* @param minimumPullbackBars: int, Minimum Shoulders of Swing Bar ...
|
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
@@ -1967,6 +1967,494 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
return result;
|
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 ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Draw Market Analysis ...
|
||||||
|
// has = iStructure.pvAnalysis.IsValid();
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XBoxZone iBox;
|
||||||
|
// XCBoxObject *iBoxObj;
|
||||||
|
|
||||||
|
//
|
||||||
|
// poiDrawer.RemoveDraws();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = iStructure.pvAnalysis.HasSupportBox(iBox);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// iBox.to = iBar.time;
|
||||||
|
// poiDrawer.DrawBox(
|
||||||
|
// iBox,
|
||||||
|
// iBoxObj,
|
||||||
|
// true,
|
||||||
|
// iBox.type //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// ZeroMemory(iBoxObj);
|
||||||
|
// has = iStructure.pvAnalysis.HasResistanceBox(iBox);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// iBox.to = iBar.time;
|
||||||
|
// poiDrawer.DrawBox(
|
||||||
|
// iBox,
|
||||||
|
// iBoxObj,
|
||||||
|
// true,
|
||||||
|
// iBox.type //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw Zones ...
|
||||||
|
// has = HasChild(iStructure.supports);
|
||||||
|
// if (has) {
|
||||||
|
// //
|
||||||
|
// CArrayObj *iSupportObjs;
|
||||||
|
// poiDrawer.DrawBoxes(
|
||||||
|
// iStructure.supports,
|
||||||
|
// iSupportObjs,
|
||||||
|
// true //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = HasChild(iStructure.resistances);
|
||||||
|
// if (has) {
|
||||||
|
// //
|
||||||
|
// CArrayObj *iResistanceObjs;
|
||||||
|
// poiDrawer.DrawBoxes(
|
||||||
|
// iStructure.resistances,
|
||||||
|
// iResistanceObjs,
|
||||||
|
// true //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detecte Fibo Section Changes ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
||||||
|
// has = has &&
|
||||||
|
// IsXBullish(iDir) &&
|
||||||
|
// fimaHelper.IsValeOverLast(iBar.Index());
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
||||||
|
// has = has &&
|
||||||
|
// IsXBearish(iDir) &&
|
||||||
|
// fimaHelper.IsPeakUnderLast(iBar.Index());
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = fimaHelper.HasFiboPush(iDir, iBar.Index(), 5);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XBoxZone fimaZones[];
|
||||||
|
// int fimaZonesCount = fimaHelper.DetectXFIMAZones(
|
||||||
|
// fimaZones,
|
||||||
|
// iBar.Index(),
|
||||||
|
// true, // Only Valid Zones ...
|
||||||
|
// 50, // Number of Zones ...
|
||||||
|
// 4, // Shadow Multiplier ...
|
||||||
|
// 1, // Strength ...
|
||||||
|
// 7, // Validation Length ...
|
||||||
|
// 500 // Loopback ..
|
||||||
|
// );
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPivot fimaPivots[];
|
||||||
|
// int fimaPivotsCount = fimaHelper.DetecteXFIMAPivots(
|
||||||
|
// fimaPivots,
|
||||||
|
// iBar.Index(),
|
||||||
|
// 50, // Number of Pivots ...
|
||||||
|
// 7, // Validation Length ...
|
||||||
|
// 500 // Loopback ...
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = IsValidSize(fimaZonesCount);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Draw Detected Zones ...
|
||||||
|
// for (int i = 0; i < fimaZonesCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCBoxObject *iObj;
|
||||||
|
// has = poiDrawer.DrawBox(
|
||||||
|
// fimaZones[i],
|
||||||
|
// iObj,
|
||||||
|
// true, // Ignore At ...
|
||||||
|
// fimaZones[i].type // Specified Name ...
|
||||||
|
// );
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// zoneObjects.Add(iObj);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = IsValidSize(fimaPivotsCount);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Draw Detected Pivots ...
|
||||||
|
// for (int i = 0; i < fimaPivotsCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCBarArrowObject *iObj;
|
||||||
|
// has = poiDrawer.DrawPivot(
|
||||||
|
// fimaPivots[i],
|
||||||
|
// iObj);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// pivotObjects.Add(iObj);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect DecisionBars ...
|
||||||
|
// XOHCL decisionBars[];
|
||||||
|
// int decisionBarsCount = 0;
|
||||||
|
// ENUM_X_DIRECTION decisionBarDirs[];
|
||||||
|
// decisionBarsCount = fimaHelper.DetectXFIMAPOIBars(
|
||||||
|
// decisionBars,
|
||||||
|
// decisionBarDirs,
|
||||||
|
// iBar.Index(),
|
||||||
|
// X_DIRECTION_ALL, // For Dir ...
|
||||||
|
// 300 // Required Number of Bars ...
|
||||||
|
// );
|
||||||
|
// decisionBarsCount = fimaHelper.DetectXFIMAReversalPOIBars(
|
||||||
|
// decisionBars,
|
||||||
|
// decisionBarDirs,
|
||||||
|
// iBar.Index(),
|
||||||
|
// true, // Force Touch Boundary ...
|
||||||
|
// X_DIRECTION_ALL, // For Dir ...
|
||||||
|
// 300 // Required Number of Bars ...
|
||||||
|
// );
|
||||||
|
// decisionBarsCount = fimaHelper.DetectXFIMAContinuationalPOIBars(
|
||||||
|
// decisionBars,
|
||||||
|
// decisionBarDirs,
|
||||||
|
// iBar.Index(),
|
||||||
|
// true,
|
||||||
|
// X_DIRECTION_ALL, // For Dir ...
|
||||||
|
// 300 // Required Number of Bars ...
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = IsValidSize(decisionBarsCount);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// for (int i = 0; i < decisionBarsCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCBarArrowObject *iObj;
|
||||||
|
// has = poiDrawer.DrawBarArrow(
|
||||||
|
// decisionBars[i],
|
||||||
|
// iObj,
|
||||||
|
// IsXBullish(decisionBarDirs[i]) ? X_PRICE_LOW : X_PRICE_HIGH,
|
||||||
|
// 159,
|
||||||
|
// IsXBullish(decisionBarDirs[i]) ? clrAqua : clrMagenta,
|
||||||
|
// 5,
|
||||||
|
// IsXBullish(decisionBarDirs[i]) ? ANCHOR_TOP : ANCHOR_BOTTOM,
|
||||||
|
// "XOHCL_" + ToXString(TimeToSeconds(decisionBars[i].time)),
|
||||||
|
// true, // Ignore Bar Tag ...
|
||||||
|
// 5 // Threshold ...
|
||||||
|
// );
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// barObjects.Add(iObj);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -3632,7 +3632,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Star Pattern ...
|
// Star Pattern ...
|
||||||
bool isStarPattern = patternDetector.IsStartPattern(
|
bool isStarPattern = patternDetector.IsStarPattern(
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
@@ -4317,12 +4317,6 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DetectXFIMAPOIBarPatterns(
|
|
||||||
XOHCL &bars[],
|
|
||||||
XOHCL &dirs[],
|
|
||||||
int barIndex = 0,
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Values Retrievers ...
|
// Values Retrievers ...
|
||||||
|
|
||||||
|
|||||||
@@ -2441,4 +2441,609 @@ int GetBars(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Specified Item from a Collection ...
|
||||||
|
*
|
||||||
|
* @param item: Specified Item ...
|
||||||
|
* @param source: Specified Collection for Remove item from it ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Remove(
|
||||||
|
XOHCL &item,
|
||||||
|
XOHCL &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
item.IsValid() &&
|
||||||
|
HasChild(source);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
result = FindIndex(
|
||||||
|
idx,
|
||||||
|
item,
|
||||||
|
source //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArrayRemove(
|
||||||
|
source,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Specified items from a Collection ...
|
||||||
|
*
|
||||||
|
* @param items: Specified Items to Remove ...
|
||||||
|
* @param sources: Sepcified Collection for Removing items from it ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int Removes(
|
||||||
|
XOHCL &items[],
|
||||||
|
XOHCL &sources[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool has = HasChild(items) &&
|
||||||
|
HasChild(sources);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
has = false;
|
||||||
|
int count = ArraySize(items);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Item Index in Collection ...
|
||||||
|
has = FindIndex(
|
||||||
|
idx,
|
||||||
|
items[i],
|
||||||
|
sources //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Remove Detected Index from Collection ...
|
||||||
|
has = ArrayRemove(
|
||||||
|
sources,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Count Removed Items ...
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Specified Item index in a Collection ...
|
||||||
|
*
|
||||||
|
* @param index: int, reference to Hold Index if Exists ...
|
||||||
|
* @param item: Specified item to Detect ...
|
||||||
|
* @param source: Collection to Search for item ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool FindIndex(
|
||||||
|
int &index,
|
||||||
|
XOHCL &item,
|
||||||
|
XOHCL &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
index = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
result = item.IsValid() &&
|
||||||
|
IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isSame = item.IsSameAs(source[i]);
|
||||||
|
if (isSame)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(index);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add Specified Item to Specified Collection, if not Exists ...
|
||||||
|
*
|
||||||
|
* @param item: Item to Add ...
|
||||||
|
* @param sources: Collection to Add item ...
|
||||||
|
* @param maxAllowed: int, Max Allowed Collection Size ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AddIfNotExists(
|
||||||
|
XOHCL &item,
|
||||||
|
XOHCL &sources[],
|
||||||
|
int maxAllowed = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
result = item.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Item Exists or not ...
|
||||||
|
int idx = -1;
|
||||||
|
bool isExists = FindIndex(
|
||||||
|
idx,
|
||||||
|
item,
|
||||||
|
sources //
|
||||||
|
);
|
||||||
|
result = !isExists;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
item,
|
||||||
|
sources //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Cleanup Collection
|
||||||
|
// if Max Reached ...
|
||||||
|
if (result &&
|
||||||
|
maxAllowed > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
sources,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Oldest Index of Specified Collection ...
|
||||||
|
*
|
||||||
|
* @param source: Specified Collection ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetOldest(
|
||||||
|
XOHCL &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL selected;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool canSet =
|
||||||
|
!selected.IsValid()
|
||||||
|
? true
|
||||||
|
: selected.time > source[i].time;
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = i;
|
||||||
|
selected = source[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
selected.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Youngest Index of Specified Collection ...
|
||||||
|
*
|
||||||
|
* @param source: Specified Collection ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetYoungest(
|
||||||
|
XOHCL &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL selected;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool canSet =
|
||||||
|
!selected.IsValid()
|
||||||
|
? true
|
||||||
|
: selected.time < source[i].time;
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = i;
|
||||||
|
selected = source[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
selected.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Lowest Index of Specified Collection ...
|
||||||
|
*
|
||||||
|
* @param source: Specified Collection ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetLowest(
|
||||||
|
XOHCL &source[],
|
||||||
|
ENUM_X_PRICE _priceType = X_PRICE_LOW //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsXValid(_priceType))
|
||||||
|
{
|
||||||
|
_priceType = X_PRICE_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL selected;
|
||||||
|
double iPrice = EMPTY_VALUE;
|
||||||
|
double selectedPrice = EMPTY_VALUE;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iPrice = source[i].GetPrice(_priceType);
|
||||||
|
selectedPrice = selected.GetPrice(_priceType);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSet =
|
||||||
|
!selected.IsValid()
|
||||||
|
? true
|
||||||
|
: selectedPrice > iPrice;
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = i;
|
||||||
|
selected = source[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
selected.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Highest Index of Specified Collection ...
|
||||||
|
*
|
||||||
|
* @param source: Specified Collection ...
|
||||||
|
* @param _priceType: Specified Price type ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetHighest(
|
||||||
|
XOHCL &source[],
|
||||||
|
ENUM_X_PRICE _priceType = X_PRICE_HIGH //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsXValid(_priceType))
|
||||||
|
{
|
||||||
|
_priceType = X_PRICE_HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL selected;
|
||||||
|
double iPrice = EMPTY_VALUE;
|
||||||
|
double selectedPrice = EMPTY_VALUE;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iPrice = source[i].GetPrice(_priceType);
|
||||||
|
selectedPrice = selected.GetPrice(_priceType);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSet =
|
||||||
|
!selected.IsValid()
|
||||||
|
? true
|
||||||
|
: selectedPrice < iPrice;
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = i;
|
||||||
|
selected = source[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
selected.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Nearest Directional Bar ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL, reference to Specified Start Bar ...
|
||||||
|
* @param directionalBar: XOHCL, reference to hold Detected Bar ...
|
||||||
|
* @param forDir: ENUM_X_DIRECTION, Specified Which Directional Bar looking for ...
|
||||||
|
* @param loopback: int, Loopback Length ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetDirectionalBar(
|
||||||
|
XOHCL &bar,
|
||||||
|
XOHCL &directionalBar,
|
||||||
|
ENUM_X_DIRECTION forDir,
|
||||||
|
int loopback = 1500 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
directionalBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
loopback = NormalizeInt(loopback, 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
HasDirection(forDir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int start = bar.Index() + 1;
|
||||||
|
int end = start + loopback;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
directionalBar.Clean();
|
||||||
|
result = bar.BarAt(i, directionalBar);
|
||||||
|
result = result &&
|
||||||
|
directionalBar.GetDirection() == forDir;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
directionalBar.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = directionalBar.IsValid() &&
|
||||||
|
forDir == directionalBar.GetDirection();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
directionalBar.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Nearest Breaker Bar of Specified Bar's Price ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL, reference to Specified Bar ...
|
||||||
|
* @param breaker: XOHCL, reference to hold Detected Breaker Bar ...
|
||||||
|
* @param priceType: ENUM_X_PRICE, which price type of Bar to Check to Break ...
|
||||||
|
* @param breakType: ENUM_X_PRICE, which price of Breaker Bar must Breke price ...
|
||||||
|
* @param breakDir: ENUM_X_DIRECTION, Specified Break Direction ...
|
||||||
|
* @param loopback: int, Max Allowed Loopback to Detect Breaker Bar ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetBreakerBar(
|
||||||
|
XOHCL &bar,
|
||||||
|
XOHCL &breaker,
|
||||||
|
ENUM_X_PRICE priceType,
|
||||||
|
ENUM_X_PRICE breakType,
|
||||||
|
ENUM_X_DIRECTION breakDir,
|
||||||
|
int loopback = 1500 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// PriceType: which Applied Price of Specified Bar must to Check for Break ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// BreakType: which Applied Price of breakerBar must Break price ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// BreakDir:
|
||||||
|
// -----------
|
||||||
|
// Bullish: Price Must Break Applied Price from Down to Top ...
|
||||||
|
// Bearish: Price must Break Applied Price from Top to Down ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
breaker.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
loopback = NormalizeInt(loopback, 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
IsXValid(priceType) &&
|
||||||
|
IsXValid(breakType) &&
|
||||||
|
HasDirection(breakDir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double iPrice = EMPTY_VALUE;
|
||||||
|
bool isBullish = IsXBullish(breakDir);
|
||||||
|
double price = bar.GetPrice(priceType);
|
||||||
|
|
||||||
|
//
|
||||||
|
int start = bar.Index();
|
||||||
|
int end = start + loopback;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
breaker.Clean();
|
||||||
|
iPrice = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
result = bar.BarAt(i, breaker);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
breaker.Clean();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Breake ...
|
||||||
|
iPrice = breaker.GetPrice(breakType);
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? iPrice > price
|
||||||
|
: iPrice < price;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = breaker.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
breaker.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ enum ENUM_X_BAR_PATTERN
|
|||||||
X_BAR_PATTERN_LOW = 2,
|
X_BAR_PATTERN_LOW = 2,
|
||||||
X_BAR_PATTERN_MOMENTUM = 3,
|
X_BAR_PATTERN_MOMENTUM = 3,
|
||||||
X_BAR_PATTERN_ENGULFED = 4,
|
X_BAR_PATTERN_ENGULFED = 4,
|
||||||
X_BAR_PATTERN_TRUE_GAPPED = 5,
|
X_BAR_PATTERN_TRUE_GAPED = 5,
|
||||||
X_BAR_PATTERN_PINNED = 6,
|
X_BAR_PATTERN_PINNED = 6,
|
||||||
X_BAR_PATTERN_STAR = 7,
|
X_BAR_PATTERN_STAR = 7,
|
||||||
X_BAR_PATTERN_PIERCING = 8,
|
X_BAR_PATTERN_PIERCING = 8,
|
||||||
@@ -53,9 +53,9 @@ enum ENUM_X_BAR_PATTERN
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an ENUM member ...
|
* Validate an ENUM member ...
|
||||||
*
|
*
|
||||||
* @param value: ENUM_X_BAR_PATTERN ...
|
* @param value: ENUM_X_BAR_PATTERN ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool IsXValid(ENUM_X_BAR_PATTERN value)
|
bool IsXValid(ENUM_X_BAR_PATTERN value)
|
||||||
@@ -65,9 +65,9 @@ bool IsXValid(ENUM_X_BAR_PATTERN value)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Pattern ENUM to String Representation ...
|
* Converts a Pattern ENUM to String Representation ...
|
||||||
*
|
*
|
||||||
* @param value: ENUM_X_BAR_PATTERN, member ...
|
* @param value: ENUM_X_BAR_PATTERN, member ...
|
||||||
*
|
*
|
||||||
* @return ( string )
|
* @return ( string )
|
||||||
*/
|
*/
|
||||||
string ToXString(ENUM_X_BAR_PATTERN value)
|
string ToXString(ENUM_X_BAR_PATTERN value)
|
||||||
@@ -104,8 +104,8 @@ string ToXString(ENUM_X_BAR_PATTERN value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_BAR_PATTERN_TRUE_GAPPED:
|
case X_BAR_PATTERN_TRUE_GAPED:
|
||||||
result = "XGAPPED";
|
result = "XGAPED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -165,9 +165,9 @@ string ToXString(ENUM_X_BAR_PATTERN value)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an String Representation to it's Corresponding Bar Pattern ENUM ...
|
* Parse an String Representation to it's Corresponding Bar Pattern ENUM ...
|
||||||
*
|
*
|
||||||
* @param value: string, provided pattern's string ...
|
* @param value: string, provided pattern's string ...
|
||||||
*
|
*
|
||||||
* @return ( ENUM_X_BAR_PATTERN )
|
* @return ( ENUM_X_BAR_PATTERN )
|
||||||
*/
|
*/
|
||||||
ENUM_X_BAR_PATTERN ToBarPattern(string value)
|
ENUM_X_BAR_PATTERN ToBarPattern(string value)
|
||||||
@@ -203,9 +203,9 @@ ENUM_X_BAR_PATTERN ToBarPattern(string value)
|
|||||||
{
|
{
|
||||||
result = X_BAR_PATTERN_ENGULFED;
|
result = X_BAR_PATTERN_ENGULFED;
|
||||||
}
|
}
|
||||||
else if (value == ToXString(X_BAR_PATTERN_TRUE_GAPPED))
|
else if (value == ToXString(X_BAR_PATTERN_TRUE_GAPED))
|
||||||
{
|
{
|
||||||
result = X_BAR_PATTERN_TRUE_GAPPED;
|
result = X_BAR_PATTERN_TRUE_GAPED;
|
||||||
}
|
}
|
||||||
else if (value == ToXString(X_BAR_PATTERN_PINNED))
|
else if (value == ToXString(X_BAR_PATTERN_PINNED))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -450,9 +450,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
CArrayObj barObjects;
|
CArrayObj drawnObjects;
|
||||||
CArrayObj zoneObjects;
|
|
||||||
CArrayObj pivotObjects;
|
|
||||||
XFIMAPatternDetectorConfig analyserConfig;
|
XFIMAPatternDetectorConfig analyserConfig;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -529,6 +527,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
string iName = NULL;
|
string iName = NULL;
|
||||||
bool isBullish = false;
|
bool isBullish = false;
|
||||||
bool isBearish = false;
|
bool isBearish = false;
|
||||||
|
XPatternAnalysis iBarAnalysis;
|
||||||
XFIMAConditions iFIMAConditions;
|
XFIMAConditions iFIMAConditions;
|
||||||
XFIMAMarketStructure iStructure;
|
XFIMAMarketStructure iStructure;
|
||||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||||
@@ -573,211 +572,519 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw Market Analysis ...
|
// Bar Pattern Analysis Detection Test ...
|
||||||
// has = iStructure.pvAnalysis.IsValid();
|
has = poiDetector.AnalyseBarPatterns(
|
||||||
// if (has)
|
iBar,
|
||||||
// {
|
iBarAnalysis
|
||||||
// //
|
//
|
||||||
// XBoxZone iBox;
|
// Use Default Config ...
|
||||||
// XCBoxObject *iBoxObj;
|
|
||||||
|
|
||||||
//
|
|
||||||
// poiDrawer.RemoveDraws();
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = iStructure.pvAnalysis.HasSupportBox(iBox);
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// iBox.to = iBar.time;
|
|
||||||
// poiDrawer.DrawBox(
|
|
||||||
// iBox,
|
|
||||||
// iBoxObj,
|
|
||||||
// true,
|
|
||||||
// iBox.type //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// ZeroMemory(iBoxObj);
|
|
||||||
// has = iStructure.pvAnalysis.HasResistanceBox(iBox);
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// iBox.to = iBar.time;
|
|
||||||
// poiDrawer.DrawBox(
|
|
||||||
// iBox,
|
|
||||||
// iBoxObj,
|
|
||||||
// true,
|
|
||||||
// iBox.type //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Draw Zones ...
|
|
||||||
// has = HasChild(iStructure.supports);
|
|
||||||
// if (has) {
|
|
||||||
// //
|
|
||||||
// CArrayObj *iSupportObjs;
|
|
||||||
// poiDrawer.DrawBoxes(
|
|
||||||
// iStructure.supports,
|
|
||||||
// iSupportObjs,
|
|
||||||
// true //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = HasChild(iStructure.resistances);
|
|
||||||
// if (has) {
|
|
||||||
// //
|
|
||||||
// CArrayObj *iResistanceObjs;
|
|
||||||
// poiDrawer.DrawBoxes(
|
|
||||||
// iStructure.resistances,
|
|
||||||
// iResistanceObjs,
|
|
||||||
// true //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detecte Fibo Section Changes ...
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
|
||||||
// has = has &&
|
|
||||||
// IsXBullish(iDir) &&
|
|
||||||
// fimaHelper.IsValeOverLast(iBar.Index());
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
|
||||||
// has = has &&
|
|
||||||
// IsXBearish(iDir) &&
|
|
||||||
// fimaHelper.IsPeakUnderLast(iBar.Index());
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = fimaHelper.HasFiboPush(iDir, iBar.Index(), 5);
|
|
||||||
|
|
||||||
// //
|
|
||||||
// XBoxZone fimaZones[];
|
|
||||||
// int fimaZonesCount = fimaHelper.DetectXFIMAZones(
|
|
||||||
// fimaZones,
|
|
||||||
// iBar.Index(),
|
|
||||||
// true, // Only Valid Zones ...
|
|
||||||
// 50, // Number of Zones ...
|
|
||||||
// 4, // Shadow Multiplier ...
|
|
||||||
// 1, // Strength ...
|
|
||||||
// 7, // Validation Length ...
|
|
||||||
// 500 // Loopback ..
|
|
||||||
// );
|
|
||||||
|
|
||||||
//
|
|
||||||
// XPivot fimaPivots[];
|
|
||||||
// int fimaPivotsCount = fimaHelper.DetecteXFIMAPivots(
|
|
||||||
// fimaPivots,
|
|
||||||
// iBar.Index(),
|
|
||||||
// 50, // Number of Pivots ...
|
|
||||||
// 7, // Validation Length ...
|
|
||||||
// 500 // Loopback ...
|
|
||||||
// );
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = IsValidSize(fimaZonesCount);
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // Draw Detected Zones ...
|
|
||||||
// for (int i = 0; i < fimaZonesCount; i++)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// XCBoxObject *iObj;
|
|
||||||
// has = poiDrawer.DrawBox(
|
|
||||||
// fimaZones[i],
|
|
||||||
// iObj,
|
|
||||||
// true, // Ignore At ...
|
|
||||||
// fimaZones[i].type // Specified Name ...
|
|
||||||
// );
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// zoneObjects.Add(iObj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// has = IsValidSize(fimaPivotsCount);
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // Draw Detected Pivots ...
|
|
||||||
// for (int i = 0; i < fimaPivotsCount; i++)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// XCBarArrowObject *iObj;
|
|
||||||
// has = poiDrawer.DrawPivot(
|
|
||||||
// fimaPivots[i],
|
|
||||||
// iObj);
|
|
||||||
// if (has)
|
|
||||||
// {
|
|
||||||
// pivotObjects.Add(iObj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect DecisionBars ...
|
|
||||||
XOHCL decisionBars[];
|
|
||||||
int decisionBarsCount = 0;
|
|
||||||
ENUM_X_DIRECTION decisionBarDirs[];
|
|
||||||
// decisionBarsCount = fimaHelper.DetectXFIMAPOIBars(
|
|
||||||
// decisionBars,
|
|
||||||
// decisionBarDirs,
|
|
||||||
// iBar.Index(),
|
|
||||||
// X_DIRECTION_ALL, // For Dir ...
|
|
||||||
// 300 // Required Number of Bars ...
|
|
||||||
// );
|
|
||||||
// decisionBarsCount = fimaHelper.DetectXFIMAReversalPOIBars(
|
|
||||||
// decisionBars,
|
|
||||||
// decisionBarDirs,
|
|
||||||
// iBar.Index(),
|
|
||||||
// true, // Force Touch Boundary ...
|
|
||||||
// X_DIRECTION_ALL, // For Dir ...
|
|
||||||
// 300 // Required Number of Bars ...
|
|
||||||
// );
|
|
||||||
decisionBarsCount = fimaHelper.DetectXFIMAContinuationalPOIBars(
|
|
||||||
decisionBars,
|
|
||||||
decisionBarDirs,
|
|
||||||
iBar.Index(),
|
|
||||||
true,
|
|
||||||
X_DIRECTION_ALL, // For Dir ...
|
|
||||||
300 // Required Number of Bars ...
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
|
||||||
has = IsValidSize(decisionBarsCount);
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
for (int i = 0; i < decisionBarsCount; i++)
|
// Draw Bar Patterns Analysis ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL patternBar;
|
||||||
|
XPivot patternPivot;
|
||||||
|
XBoxZone patternBox;
|
||||||
|
ENUM_X_BAR_PATTERN pattern;
|
||||||
|
ENUM_X_DIRECTION patternDir;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistance ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support ...
|
||||||
|
isBearish = false;
|
||||||
|
isBullish = iBarAnalysis.IsSupport();
|
||||||
|
has = isBullish;
|
||||||
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XCBarArrowObject *iObj;
|
pattern = X_BAR_PATTERN_SUPPORT;
|
||||||
has = poiDrawer.DrawBarArrow(
|
patternDir = X_DIRECTION_BULLISH;
|
||||||
decisionBars[i],
|
has = iBarAnalysis.GetPattern(
|
||||||
iObj,
|
patternBar,
|
||||||
IsXBullish(decisionBarDirs[i]) ? X_PRICE_LOW : X_PRICE_HIGH,
|
patternPivot,
|
||||||
159,
|
patternBox,
|
||||||
IsXBullish(decisionBarDirs[i]) ? clrAqua : clrMagenta,
|
pattern,
|
||||||
5,
|
patternDir //
|
||||||
IsXBullish(decisionBarDirs[i]) ? ANCHOR_TOP : ANCHOR_BOTTOM,
|
|
||||||
"XOHCL_" + ToXString(TimeToSeconds(decisionBars[i].time)),
|
|
||||||
true, // Ignore Bar Tag ...
|
|
||||||
5 // Threshold ...
|
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
barObjects.Add(iObj);
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Resistance ...
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = iBarAnalysis.IsResistance();
|
||||||
|
has = isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_SUPPORT;
|
||||||
|
patternDir = X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// PV: High and Low ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
isBearish = false;
|
||||||
|
isBullish = iBarAnalysis.IsLow();
|
||||||
|
has = isBullish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_LOW;
|
||||||
|
patternDir = X_DIRECTION_BULLISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = iBarAnalysis.IsHigh();
|
||||||
|
has = isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_HIGH;
|
||||||
|
patternDir = X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// OB ...
|
||||||
|
isBullish = iBarAnalysis.IsOB(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsOB(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_OB;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FVG ...
|
||||||
|
isBullish = iBarAnalysis.IsFVG(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsFVG(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_FVG;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Momentum ...
|
||||||
|
isBullish = iBarAnalysis.IsMomentum(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsMomentum(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_MOMENTUM;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Engulfed ...
|
||||||
|
isBullish = iBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_ENGULFED;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pinned ...
|
||||||
|
isBullish = iBarAnalysis.IsPinned(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsPinned(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_PINNED;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TrueGaped ...
|
||||||
|
isBullish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_TRUE_GAPED;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Star ...
|
||||||
|
isBullish = iBarAnalysis.IsStar(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsStar(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_STAR;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Piercing ...
|
||||||
|
isBullish = iBarAnalysis.IsPiercing(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsPiercing(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_PIERCING;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Rising ...
|
||||||
|
isBullish = iBarAnalysis.IsRising(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsRising(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_RISING;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Flag ...
|
||||||
|
isBullish = iBarAnalysis.IsFlag(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsFlag(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_FLAG;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SignalKey ...
|
||||||
|
isBullish = iBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH);
|
||||||
|
isBearish = iBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH);
|
||||||
|
has = isBullish || isBearish;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pattern = X_BAR_PATTERN_SIGNALKEY;
|
||||||
|
patternDir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
has = iBarAnalysis.GetPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
DrawPattern(
|
||||||
|
patternBar,
|
||||||
|
patternPivot,
|
||||||
|
patternBox,
|
||||||
|
pattern,
|
||||||
|
patternDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
patternBar.Clean();
|
||||||
|
patternBox.Clean();
|
||||||
|
patternPivot.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -860,6 +1167,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
iZone.Clean();
|
iZone.Clean();
|
||||||
iSignal.Clean();
|
iSignal.Clean();
|
||||||
iStructure.Clean();
|
iStructure.Clean();
|
||||||
|
iBarAnalysis.Clean();
|
||||||
iFIMAConditions.Clean();
|
iFIMAConditions.Clean();
|
||||||
SpecifiedClean(iTargets);
|
SpecifiedClean(iTargets);
|
||||||
}
|
}
|
||||||
@@ -1360,6 +1668,133 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drawer Functions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
void DrawPattern(
|
||||||
|
XOHCL &_bar,
|
||||||
|
XPivot &_pivot,
|
||||||
|
XBoxZone &_zone,
|
||||||
|
ENUM_X_BAR_PATTERN _pattern,
|
||||||
|
ENUM_X_DIRECTION _patternDir //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has =
|
||||||
|
poiDrawer != NULL &&
|
||||||
|
_bar.IsValid() &&
|
||||||
|
IsXValid(_pattern) &&
|
||||||
|
HasDirection(_patternDir);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Defien Draw Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
int width = 3;
|
||||||
|
bool ignoreBoxAt = true;
|
||||||
|
int arrowThreshold = 5;
|
||||||
|
|
||||||
|
//
|
||||||
|
int bullishArrow = 159;
|
||||||
|
int bearishArrow = 159;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_PRICE arrowValePriceType = X_PRICE_LOW;
|
||||||
|
ENUM_X_PRICE arrowPeakPriceType = X_PRICE_HIGH;
|
||||||
|
|
||||||
|
//
|
||||||
|
color bullishColor = clrAqua;
|
||||||
|
color bearishColor = clrMagenta;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Bar ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Pivot ...
|
||||||
|
if (_pivot.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCBarArrowObject *iObj;
|
||||||
|
has = poiDrawer.DrawBarArrow(
|
||||||
|
_bar,
|
||||||
|
iObj,
|
||||||
|
_pivot.IsPeak()
|
||||||
|
? arrowPeakPriceType
|
||||||
|
: arrowValePriceType,
|
||||||
|
IsXBullish(_patternDir)
|
||||||
|
? bullishArrow
|
||||||
|
: bearishArrow,
|
||||||
|
IsXBullish(_patternDir)
|
||||||
|
? bullishColor
|
||||||
|
: bearishColor,
|
||||||
|
width,
|
||||||
|
IsXBullish(_patternDir)
|
||||||
|
? ANCHOR_TOP
|
||||||
|
: ANCHOR_BOTTOM,
|
||||||
|
_pivot.prefix + "_" + ToXString(TimeToSeconds(_pivot.time)),
|
||||||
|
true, // Ignore Bar Tag ...
|
||||||
|
arrowThreshold // Threshold ...
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
drawnObjects.Add(iObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(iObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Box ...
|
||||||
|
if (_zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCBoxObject *iObj;
|
||||||
|
has = poiDrawer.DrawBox(
|
||||||
|
_zone,
|
||||||
|
iObj,
|
||||||
|
ignoreBoxAt,
|
||||||
|
_zone.type + "_" + ToXString(TimeToSeconds(_zone.from)) //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPOIStyle iStyle;
|
||||||
|
poiDrawer.GetBoxStyle(
|
||||||
|
iStyle,
|
||||||
|
_zone.dir //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
iStyle.clr =
|
||||||
|
IsXBullish(_patternDir)
|
||||||
|
? bullishColor
|
||||||
|
: bearishColor;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.ApplyBoxStyle(
|
||||||
|
iObj,
|
||||||
|
iStyle //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
drawnObjects.Add(iObj);
|
||||||
|
|
||||||
|
//
|
||||||
|
iStyle.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -622,7 +622,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
if (config.detectStarPattern)
|
if (config.detectStarPattern)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool isStarPattern = IsStartPattern(
|
bool isStarPattern = IsStarPattern(
|
||||||
forBar,
|
forBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
@@ -1129,7 +1129,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
iPrefix = "Star";
|
iPrefix = "Star";
|
||||||
has = IsStartPattern(
|
has = IsStarPattern(
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user