last ...
This commit is contained in:
@@ -1399,151 +1399,6 @@ class XCMarketPatternDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Liquidity Sweeps ...
|
||||
*
|
||||
* @param bar: XOHCL, Specified Bar ...
|
||||
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
|
||||
* @param sweeperBar: XOHCL, reference for Holding Sweeper Bar ...
|
||||
* @param zone: XBoxZone, reference for Holding new Support/Resistance after Liquidity Sweeped ...
|
||||
* @param sweepedLiquidity: XBoxZone, reference for Holding Sweeped Liquidity Zone ...
|
||||
* @param liquidityLoopbackLength: int, Max Allowed Length to Sweep a Liquidity ...
|
||||
* @param zoneValidationLength: int, Liquidity Detection Validatio Length ...
|
||||
* @param zodeMaxAllowedLoopback: int, Max Allowed Loopback Length to Detect Liquidity ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasSweepedLiquidity(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XOHCL &sweeperBar,
|
||||
XBoxZone &zone,
|
||||
XBoxZone &sweepedLiquidity,
|
||||
int liquidityLoopbackLength = 21,
|
||||
int zoneValidationLength = 21,
|
||||
int zodeMaxAllowedLoopback = 1500 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
sweeperBar.Clean();
|
||||
CleanDirection(dir);
|
||||
sweepedLiquidity.Clean();
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
zoneValidationLength = NormalizeInt(zoneValidationLength, 7);
|
||||
liquidityLoopbackLength = NormalizeInt(liquidityLoopbackLength, 5);
|
||||
zodeMaxAllowedLoopback = NormalizeInt(zodeMaxAllowedLoopback, 21, 1500);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL supportBar;
|
||||
XOHCL resistanceBar;
|
||||
datetime barBeofreOn = bar.BeforeOn();
|
||||
|
||||
//
|
||||
// Current Bar must has Support / Resistance ...
|
||||
|
||||
//
|
||||
// Support ...
|
||||
bool hasSupport = HasSupport(
|
||||
bar,
|
||||
supportBar,
|
||||
zoneValidationLength,
|
||||
zodeMaxAllowedLoopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Fresh Support ...
|
||||
hasSupport =
|
||||
hasSupport &&
|
||||
supportBar.time == barBeofreOn;
|
||||
|
||||
//
|
||||
// Validate Support Box Exists ...
|
||||
hasSupport =
|
||||
hasSupport &&
|
||||
ToSupportBox(supportBar, zone);
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
bool hasResistance = HasResistance(
|
||||
bar,
|
||||
resistanceBar,
|
||||
zoneValidationLength,
|
||||
zodeMaxAllowedLoopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Fresh Resistance ...
|
||||
hasResistance =
|
||||
hasResistance &&
|
||||
resistanceBar.time == barBeofreOn;
|
||||
|
||||
//
|
||||
// Validate Resistance Box Existx ...
|
||||
hasResistance =
|
||||
hasResistance &&
|
||||
ToResistanceBox(resistanceBar, zone);
|
||||
|
||||
//
|
||||
result =
|
||||
hasSupport ||
|
||||
hasResistance;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
sweeperBar.Clean();
|
||||
supportBar.Clean();
|
||||
CleanDirection(dir);
|
||||
resistanceBar.Clean();
|
||||
sweepedLiquidity.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
sweeperBar.Clean();
|
||||
CleanDirection(dir);
|
||||
sweepedLiquidity.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Trending ...
|
||||
|
||||
@@ -2026,6 +1881,152 @@ class XCMarketPatternDetector : public XCBase
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Tools / Actions ...
|
||||
|
||||
/**
|
||||
* Check Zones and Manage them ...
|
||||
*
|
||||
* @param forBar: XOHCL, reference to Specified Bar ...
|
||||
* @param zones: XBoxZone, reference to Specified Zone Collection ...
|
||||
* @param sortBy: X_SORT_BY_DATE, Sort Zones by ...
|
||||
* @param sortDir: ENUM_X_DIRECTION, Sort Zones in Direction ...
|
||||
* @param maxAllowed: int, Specified Max Allowed Zones ...
|
||||
*/
|
||||
void CheckZones(
|
||||
XOHCL &forBar,
|
||||
XBoxZone &zones[],
|
||||
ENUM_X_SORT_BY sortBy = X_SORT_BY_DATE,
|
||||
ENUM_X_DIRECTION sortDir = X_DIRECTION_BEARISH,
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
maxAllowed = NormalizeInt(maxAllowed, 0);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = forBar.IsValid() &&
|
||||
HasChild(zones);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Looping Through Zones ...
|
||||
int count = ArraySize(zones);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Check Break ...
|
||||
has = IsXValid(zones[i].breakAt);
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
zones[i].to = forBar.time;
|
||||
|
||||
//
|
||||
// Check for Test ...
|
||||
has = IsTested(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].tests //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Inside ...
|
||||
has = IsInside(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].insides //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Break ...
|
||||
has = IsBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].breaks //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Act ...
|
||||
has = IsActed(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].acteds //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for FakeBreakes ...
|
||||
has = IsFakeBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].fakeBreaks //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Valid Breakes ...
|
||||
has = IsValidBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
zones[i].breakAt = forBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Sort and Cleanup ...
|
||||
Sort(
|
||||
zones,
|
||||
sortBy,
|
||||
sortDir,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
|
||||
@@ -638,6 +638,7 @@ class XCPOIDrawer : public XCBase
|
||||
int DrawBoxes(
|
||||
XBoxZone &boxes[],
|
||||
CArrayObj *&objects,
|
||||
bool useTypeName = true,
|
||||
bool ignoreAt = true //
|
||||
)
|
||||
{
|
||||
@@ -658,14 +659,21 @@ class XCPOIDrawer : public XCBase
|
||||
//
|
||||
bool has = false;
|
||||
XCBoxObject *iObj;
|
||||
string name = NULL;
|
||||
int count = ArraySize(boxes);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
if (useTypeName) {
|
||||
name = boxes[i].type;
|
||||
}
|
||||
|
||||
//
|
||||
has = DrawBox(
|
||||
boxes[i],
|
||||
iObj,
|
||||
ignoreAt //
|
||||
ignoreAt,
|
||||
name //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,792 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Library
|
||||
// -------------------------------------------------
|
||||
// Name: XCXFIMAEALib ...
|
||||
// Description: XFIMAEA Library ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XFIMAEA Library"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
/**
|
||||
* Configure Market Structure Detection ...
|
||||
**/
|
||||
struct XFIMAPatternDetectorConfig
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Flags ...
|
||||
|
||||
//
|
||||
bool detectSupport;
|
||||
bool detectResistance;
|
||||
|
||||
//
|
||||
bool detectSwingTrend;
|
||||
|
||||
//
|
||||
bool detectOB;
|
||||
bool detectFVG;
|
||||
|
||||
//
|
||||
bool detectStarPattern;
|
||||
bool detectFlagPattern;
|
||||
bool detectRisingPattern;
|
||||
bool detectPiercingPattern;
|
||||
bool detectSignalKeyBarPattern;
|
||||
|
||||
//
|
||||
bool detectPinned;
|
||||
bool detectMomentum;
|
||||
bool detectEngulfed;
|
||||
bool detectTrueGaped;
|
||||
|
||||
//
|
||||
bool analyseFIMAPVPivots;
|
||||
bool analyseFIMASARPivots;
|
||||
bool analyseFIMAZigZagPivots;
|
||||
|
||||
//
|
||||
bool detectMACrosses;
|
||||
double validMACrossDiffMultiplier;
|
||||
|
||||
//
|
||||
bool detectHKSwitches;
|
||||
bool detectSARSwitches;
|
||||
|
||||
//
|
||||
// Configs ...
|
||||
|
||||
//
|
||||
// OB / FVG ...
|
||||
int obLoopback;
|
||||
int fvgLoopback;
|
||||
|
||||
//
|
||||
// Trending ...
|
||||
int trendingNumberOfSwings;
|
||||
int trendingSwingShoulders;
|
||||
|
||||
//
|
||||
int recentlyPatternsMaxLookupLength;
|
||||
int recentlyPatternsMaxAllowedCollecting;
|
||||
|
||||
//
|
||||
// Support and Resistance ...
|
||||
int recentlyZonesMaxLookupLength;
|
||||
int supportAndResistanceValidationLength;
|
||||
int minAllowdSupportAndResistanceStrength;
|
||||
int supportAndResistanceMaxAllowedLoopback;
|
||||
int supportAndResistanceBreakeValidationLength;
|
||||
|
||||
//
|
||||
// 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()
|
||||
{
|
||||
//
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
detectStarPattern = false;
|
||||
detectFlagPattern = false;
|
||||
detectRisingPattern = false;
|
||||
detectPiercingPattern = false;
|
||||
detectSignalKeyBarPattern = false;
|
||||
detectPinned = false;
|
||||
detectMomentum = false;
|
||||
detectEngulfed = false;
|
||||
detectTrueGaped = false;
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
//
|
||||
detectMACrosses = false;
|
||||
validMACrossDiffMultiplier = 0;
|
||||
|
||||
//
|
||||
detectHKSwitches = false;
|
||||
detectSARSwitches = false;
|
||||
|
||||
//
|
||||
obLoopback = 0;
|
||||
fvgLoopback = 0;
|
||||
trendingNumberOfSwings = 0;
|
||||
trendingSwingShoulders = 0;
|
||||
recentlyZonesMaxLookupLength = 0;
|
||||
recentlyPatternsMaxLookupLength = 0;
|
||||
recentlyPatternsMaxAllowedCollecting = 0;
|
||||
supportAndResistanceValidationLength = 0;
|
||||
minAllowdSupportAndResistanceStrength = 0;
|
||||
supportAndResistanceMaxAllowedLoopback = 0;
|
||||
supportAndResistanceBreakeValidationLength = 0;
|
||||
truwGapApprovedPointMultiplier = 0;
|
||||
flagPatternMinimumPullbackBars = 0;
|
||||
momentumBarRangeLength = 0;
|
||||
momentumBarApprovedMultiplier = 0;
|
||||
pinnedBaarShadowApprovedMultiplier = 0;
|
||||
pinnedBarMinimumPinBarRangeMultiplier = 0;
|
||||
pinnedBarForceDirection = false;
|
||||
signalKeyBarShadowApprovedMultiplier = 0;
|
||||
signalKeyBarMinimumPinBarRangeMultiplier = 0;
|
||||
signalKeyBarForceDirection = false;
|
||||
pvPivotsValidationLength = 0;
|
||||
numberOfRequiredPivotsForAnalysis = 0;
|
||||
maxAllowedLoopbackLengthForAnalysis = 0;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Model ...
|
||||
*/
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = false;
|
||||
detectFlagPattern = false;
|
||||
detectRisingPattern = false;
|
||||
detectPiercingPattern = false;
|
||||
detectSignalKeyBarPattern = false;
|
||||
|
||||
//
|
||||
// Bars ...
|
||||
detectPinned = false;
|
||||
detectMomentum = false;
|
||||
detectEngulfed = false;
|
||||
detectTrueGaped = false;
|
||||
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
//
|
||||
detectMACrosses = true;
|
||||
validMACrossDiffMultiplier = 1;
|
||||
|
||||
//
|
||||
detectHKSwitches = true;
|
||||
detectSARSwitches = true;
|
||||
|
||||
//
|
||||
// OB / FVg ...
|
||||
obLoopback = 5;
|
||||
fvgLoopback = 5;
|
||||
|
||||
//
|
||||
// Trending ...
|
||||
trendingNumberOfSwings = 3;
|
||||
trendingSwingShoulders = 11;
|
||||
|
||||
//
|
||||
// Support and Resistance ...
|
||||
recentlyZonesMaxLookupLength = 100;
|
||||
recentlyPatternsMaxLookupLength = 50;
|
||||
recentlyPatternsMaxAllowedCollecting = 20;
|
||||
supportAndResistanceValidationLength = 100;
|
||||
minAllowdSupportAndResistanceStrength = 1;
|
||||
supportAndResistanceMaxAllowedLoopback = 1500;
|
||||
supportAndResistanceBreakeValidationLength = 4;
|
||||
|
||||
//
|
||||
// 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()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = true;
|
||||
detectFVG = true;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = true;
|
||||
detectResistance = true;
|
||||
detectSwingTrend = true;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = true;
|
||||
detectFlagPattern = true;
|
||||
detectRisingPattern = true;
|
||||
detectPiercingPattern = true;
|
||||
detectSignalKeyBarPattern = true;
|
||||
|
||||
//
|
||||
// Bars ...
|
||||
detectPinned = true;
|
||||
detectMomentum = true;
|
||||
detectEngulfed = true;
|
||||
detectTrueGaped = true;
|
||||
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = true;
|
||||
analyseFIMASARPivots = true;
|
||||
analyseFIMAZigZagPivots = true;
|
||||
|
||||
//
|
||||
detectMACrosses = true;
|
||||
detectHKSwitches = true;
|
||||
detectSARSwitches = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Config, by turn off all detecting flags ...
|
||||
*/
|
||||
void OffDetectors()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = false;
|
||||
detectFlagPattern = false;
|
||||
detectRisingPattern = false;
|
||||
detectPiercingPattern = false;
|
||||
detectSignalKeyBarPattern = false;
|
||||
|
||||
//
|
||||
// Bars ...
|
||||
detectPinned = false;
|
||||
detectMomentum = false;
|
||||
detectEngulfed = false;
|
||||
detectTrueGaped = false;
|
||||
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
//
|
||||
detectMACrosses = false;
|
||||
detectHKSwitches = false;
|
||||
detectSARSwitches = false;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* XFIMA Base Market Structure ...
|
||||
* AnalyseMarket result ...
|
||||
**/
|
||||
struct XFIMAMarketStructure
|
||||
{
|
||||
//
|
||||
XOHCL bar;
|
||||
|
||||
//
|
||||
XBoxZone ob;
|
||||
XBoxZone fvg;
|
||||
XBoxZone support;
|
||||
XBoxZone resistance;
|
||||
|
||||
//
|
||||
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[];
|
||||
|
||||
//
|
||||
// Previous Support or Resistance based on current ...
|
||||
//
|
||||
// Current Support is Touched => Prev Support;
|
||||
// Current Resistance is Touched => Prev Resistance;
|
||||
XBoxZone fakeBreakedZone;
|
||||
|
||||
//
|
||||
XBoxZone recentlyTestedZones[];
|
||||
XBoxZone recentlyBreakedZones[];
|
||||
|
||||
//
|
||||
// Analysis ...
|
||||
XPivotAnalysis pvAnalysis;
|
||||
XPivotAnalysis sarAnalysis;
|
||||
XPivotAnalysis zigzagAnalysis;
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION pinnedDir;
|
||||
ENUM_X_DIRECTION momentumDir;
|
||||
ENUM_X_DIRECTION engulfedDir;
|
||||
ENUM_X_DIRECTION trueGapedDir;
|
||||
|
||||
//
|
||||
XOHCL flagSwing;
|
||||
ENUM_X_DIRECTION flagPatternDir;
|
||||
|
||||
//
|
||||
XOHCL trendSwings[];
|
||||
ENUM_X_DIRECTION trendDir;
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION starPatternDir;
|
||||
ENUM_X_DIRECTION risingPatternDir;
|
||||
ENUM_X_DIRECTION piercingPatternDir;
|
||||
ENUM_X_DIRECTION signalKeyBarPatternDir;
|
||||
|
||||
//
|
||||
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()
|
||||
{
|
||||
//
|
||||
ob.Clean();
|
||||
fvg.Clean();
|
||||
support.Clean();
|
||||
resistance.Clean();
|
||||
|
||||
//
|
||||
fakeBreakedZone.Clean();
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
flagSwing.Clean();
|
||||
|
||||
//
|
||||
pvAnalysis.Clean();
|
||||
sarAnalysis.Clean();
|
||||
zigzagAnalysis.Clean();
|
||||
|
||||
//
|
||||
trendDir = X_DIRECTION_NONE;
|
||||
pinnedDir = X_DIRECTION_NONE;
|
||||
momentumDir = X_DIRECTION_NONE;
|
||||
engulfedDir = X_DIRECTION_NONE;
|
||||
trueGapedDir = X_DIRECTION_NONE;
|
||||
flagPatternDir = X_DIRECTION_NONE;
|
||||
starPatternDir = X_DIRECTION_NONE;
|
||||
risingPatternDir = X_DIRECTION_NONE;
|
||||
piercingPatternDir = X_DIRECTION_NONE;
|
||||
signalKeyBarPatternDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
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);
|
||||
SpecifiedClean(recentlyTestedZones);
|
||||
SpecifiedClean(recentlyBreakedZones);
|
||||
|
||||
//
|
||||
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
@@ -827,13 +827,8 @@ void AnalyseMarket(int barIndex = 0)
|
||||
//
|
||||
// Configuring Detector ...
|
||||
|
||||
//
|
||||
detectorConfig.detectOB = true;
|
||||
detectorConfig.detectFVG = true;
|
||||
|
||||
//
|
||||
detectorConfig.detectSupport = true;
|
||||
detectorConfig.detectResistance = true;
|
||||
detectorConfig.detectSwingTrend = true;
|
||||
|
||||
//
|
||||
@@ -851,7 +846,6 @@ void AnalyseMarket(int barIndex = 0)
|
||||
|
||||
//
|
||||
detectorConfig.analyseFIMAPVPivots = true;
|
||||
detectorConfig.analyseFIMASARPivots = false;
|
||||
detectorConfig.analyseFIMAZigZagPivots = true;
|
||||
|
||||
//
|
||||
|
||||
@@ -3499,11 +3499,11 @@ bool AddIfNotExists(
|
||||
|
||||
/**
|
||||
* Extract Specified Directional Items ...
|
||||
*
|
||||
*
|
||||
* @param dest: reference collection to holds extracted items ...
|
||||
* @param source: reference collection to provides data source ...
|
||||
* @param forDir: Specified which direction to Extract items ...
|
||||
*
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
template <typename T>
|
||||
@@ -3534,7 +3534,7 @@ int ExtractByDirection(
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].dir == forDir;
|
||||
has = source[i].dir == forDir;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
@@ -4313,6 +4313,219 @@ bool IsInside(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Acted On Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsActed(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Previous Bar ...
|
||||
XOHCL pBar;
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar must one of Following States:
|
||||
// - Tested;
|
||||
// - Inside;
|
||||
// - Breaked;
|
||||
bool isTested = IsTested(pBar, zone);
|
||||
bool isInside = IsInside(pBar, zone);
|
||||
bool isBreaked = IsBreaked(pBar, zone);
|
||||
result = isTested ||
|
||||
isInside ||
|
||||
isBreaked;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Current Bar Must Close Over / Under Zone ...
|
||||
result =
|
||||
zone.IsBullish()
|
||||
? bar.close > zone.upper
|
||||
: zone.IsBearish()
|
||||
? bar.close < zone.lower
|
||||
: false;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Acted On Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
* @param validationLength: Specified Length for Breaks ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValidBreaked(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
int validationLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 1);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
int count = 0;
|
||||
int start = bar.Index();
|
||||
int end = start + validationLength;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
result = bar.BarAt(i, iBar);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBreaked(iBar, zone);
|
||||
if (result)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidSize(count) &&
|
||||
count >= validationLength;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Fake Breaked Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
* @param validationLength: Specified Length for Breaks ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsFakeBreaked(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
int validationLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 1);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Must Acting Zone ...
|
||||
result = zone.IsBullish()
|
||||
? bar.close > zone.upper
|
||||
: zone.IsBearish()
|
||||
? bar.close < zone.lower
|
||||
: false;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Breaker Bars ...
|
||||
XOHCL breakerBars[];
|
||||
int breakerBarsCount = GetBreakerBars(
|
||||
zone,
|
||||
breakerBars //
|
||||
);
|
||||
result = IsValidSize(breakerBarsCount);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
XClean(breakerBars);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Youngest Breaker Bars ...
|
||||
int idx = GetYoungestBar(breakerBars);
|
||||
result = IsValidIndex(idx);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
XClean(breakerBars);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = breakerBars[idx].Index() - bar.Index() <= validationLength;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
XClean(breakerBars);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Inside a Zone or not ...
|
||||
*
|
||||
|
||||
@@ -537,6 +537,15 @@ struct XBoxZone
|
||||
string type;
|
||||
ENUM_X_DIRECTION dir;
|
||||
|
||||
//
|
||||
// Special Props ...
|
||||
datetime breakAt;
|
||||
datetime tests[];
|
||||
datetime acteds[];
|
||||
datetime breaks[];
|
||||
datetime insides[];
|
||||
datetime fakeBreaks[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XBoxZone()
|
||||
@@ -562,10 +571,27 @@ struct XBoxZone
|
||||
period = NULL;
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
SpecialClean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean Special Props ...
|
||||
*/
|
||||
void SpecialClean()
|
||||
{
|
||||
//
|
||||
breakAt = NULL;
|
||||
XClean(tests);
|
||||
XClean(acteds);
|
||||
XClean(breaks);
|
||||
XClean(insides);
|
||||
XClean(fakeBreaks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
|
||||
@@ -520,29 +520,14 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
XBoxZone iZone;
|
||||
XSignal iSignal;
|
||||
bool has = false;
|
||||
XTarget targets[];
|
||||
XTarget iTargets[];
|
||||
string iName = NULL;
|
||||
XBoxZone supports[];
|
||||
XBoxZone resistances[];
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
int numberOfPivots = 25;
|
||||
XFIMAConditions iFIMAConditions;
|
||||
XFIMAMarketStructure iStructure;
|
||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
XPivot pvPivots[];
|
||||
string pvTrendName = "XXIFMA2PVTrend";
|
||||
CChartObjectTrend *pvTrendLine = NULL;
|
||||
ENUM_X_DIRECTION pvTrend = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
XPivot zgPivots[];
|
||||
string zgTrendName = "XFIMA2ZGTrend";
|
||||
CChartObjectTrend *zgTrendLine = NULL;
|
||||
ENUM_X_DIRECTION zgTrend = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Initialize Bar as CBar ...
|
||||
has = iBar.Init(
|
||||
@@ -582,486 +567,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
analyserConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Collect Support and Resistance Zones and Validate by them ...
|
||||
|
||||
//
|
||||
// PV Trend Line ...
|
||||
bool hasPVAnalysis = iStructure.pvAnalysis.IsValid();
|
||||
if (hasPVAnalysis)
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
XBoxZone supportBox;
|
||||
has = iStructure.pvAnalysis.HasSupportBox(supportBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
supportBox.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
supportBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
XBoxZone resistanceBox;
|
||||
has = iStructure.pvAnalysis.HasResistanceBox(resistanceBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
resistanceBox.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
resistanceBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Pivots ...
|
||||
XPivot pivots[];
|
||||
count = poiDetector.ExtractPVPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
numberOfPivots //
|
||||
);
|
||||
has = IsValidSize(count);
|
||||
|
||||
//
|
||||
// Sort ...
|
||||
Sort(
|
||||
pivots,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
// Remove Newest ...
|
||||
ArrayRemove(
|
||||
pivots,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Trend ...
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XPivot highs[];
|
||||
int highsCount = ExtractPivots(
|
||||
highs,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
Sort(
|
||||
highs,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
XPivot lows[];
|
||||
int lowsCount = ExtractPivots(
|
||||
lows,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
Sort(
|
||||
lows,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Highs and Lows ...
|
||||
has = IsValidSize(lowsCount) &&
|
||||
IsValidSize(highsCount) &&
|
||||
lowsCount >= 2 &&
|
||||
highsCount >= 2;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Try to Get Market Strucutre ...
|
||||
|
||||
//
|
||||
bool hasLowerHigh = highs[0].value < highs[1].value;
|
||||
bool hasLowerLow = lows[0].value < lows[1].value;
|
||||
|
||||
//
|
||||
bool hasHigherHigh = highs[0].value > highs[1].value;
|
||||
bool hasHigherLow = lows[0].value > lows[1].value;
|
||||
|
||||
//
|
||||
pvTrend =
|
||||
(hasHigherHigh &&
|
||||
hasHigherLow)
|
||||
? X_DIRECTION_BULLISH
|
||||
: (hasLowerHigh &&
|
||||
hasLowerLow)
|
||||
? X_DIRECTION_BEARISH
|
||||
: X_DIRECTION_NONE;
|
||||
has = HasDirection(pvTrend);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Select Swings for Trend Line ...
|
||||
XOHCL tmpBar;
|
||||
int llIDX = -1;
|
||||
int hhIDX = -1;
|
||||
datetime toTime = NULL;
|
||||
datetime fromTime = NULL;
|
||||
double toPrice = EMPTY_VALUE;
|
||||
color trendColor = CLR_NONE;
|
||||
double fromPrice = EMPTY_VALUE;
|
||||
if (IsSpecifiedBullish(pvTrend))
|
||||
{
|
||||
//
|
||||
llIDX = GetLowest(lows);
|
||||
hhIDX = GetHighest(lows);
|
||||
|
||||
//
|
||||
trendColor = clrAqua;
|
||||
|
||||
//
|
||||
toTime = lows[hhIDX].time;
|
||||
toPrice = lows[hhIDX].value;
|
||||
|
||||
//
|
||||
fromTime = lows[llIDX].time;
|
||||
fromPrice = lows[llIDX].value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
llIDX = GetLowest(highs);
|
||||
hhIDX = GetHighest(highs);
|
||||
|
||||
//
|
||||
trendColor = clrMagenta;
|
||||
|
||||
//
|
||||
toTime = highs[llIDX].time;
|
||||
toPrice = highs[llIDX].value;
|
||||
|
||||
//
|
||||
fromTime = highs[hhIDX].time;
|
||||
fromPrice = highs[hhIDX].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Requirements for Trend ...
|
||||
has =
|
||||
NotEmptyZero(toPrice) &&
|
||||
NotEmptyZero(fromPrice) &&
|
||||
IsSpecifiedValid(toTime) &&
|
||||
IsSpecifiedValid(fromTime);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = poiDrawer.DrawTrendLine(
|
||||
fromPrice,
|
||||
fromTime,
|
||||
toPrice,
|
||||
toTime,
|
||||
pvTrendLine,
|
||||
pvTrendName,
|
||||
true // Ray Right ...
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
pvTrendLine.Color(trendColor);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
tmpBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (!has)
|
||||
{
|
||||
SpecifiedClean(pivots);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(lows);
|
||||
SpecifiedClean(highs);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasChild(pivots);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
pivots,
|
||||
pvPivots //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(pivots);
|
||||
}
|
||||
|
||||
//
|
||||
// ZigZag Trend Line ...
|
||||
bool hasZGAnalysis = iStructure.zigzagAnalysis.IsValid();
|
||||
if (hasZGAnalysis)
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
XBoxZone supportBox;
|
||||
has = iStructure.zigzagAnalysis.HasSupportBox(supportBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
supportBox.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
supportBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
XBoxZone resistanceBox;
|
||||
has = iStructure.zigzagAnalysis.HasResistanceBox(resistanceBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
resistanceBox.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
resistanceBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Pivots ...
|
||||
XPivot pivots[];
|
||||
count = poiDetector.ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
numberOfPivots //
|
||||
);
|
||||
has = IsValidSize(count);
|
||||
|
||||
//
|
||||
// Sort ...
|
||||
Sort(
|
||||
pivots,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
// Remove Newest ...
|
||||
ArrayRemove(
|
||||
pivots,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Trend ...
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XPivot highs[];
|
||||
int highsCount = ExtractPivots(
|
||||
highs,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
Sort(
|
||||
highs,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
XPivot lows[];
|
||||
int lowsCount = ExtractPivots(
|
||||
lows,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
Sort(
|
||||
lows,
|
||||
X_SORT_BY_DATE,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Highs and Lows ...
|
||||
has = IsValidSize(lowsCount) &&
|
||||
IsValidSize(highsCount) &&
|
||||
lowsCount >= 2 &&
|
||||
highsCount >= 2;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Try to Get Market Strucutre ...
|
||||
|
||||
//
|
||||
bool hasLowerHigh = highs[0].value < highs[1].value;
|
||||
bool hasLowerLow = lows[0].value < lows[1].value;
|
||||
|
||||
//
|
||||
bool hasHigherHigh = highs[0].value > highs[1].value;
|
||||
bool hasHigherLow = lows[0].value > lows[1].value;
|
||||
|
||||
//
|
||||
zgTrend =
|
||||
(hasHigherHigh &&
|
||||
hasHigherLow)
|
||||
? X_DIRECTION_BULLISH
|
||||
: (hasLowerHigh &&
|
||||
hasLowerLow)
|
||||
? X_DIRECTION_BEARISH
|
||||
: X_DIRECTION_NONE;
|
||||
has = HasDirection(zgTrend);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Select Swings for Trend Line ...
|
||||
XOHCL tmpBar;
|
||||
int llIDX = -1;
|
||||
int hhIDX = -1;
|
||||
datetime toTime = NULL;
|
||||
datetime fromTime = NULL;
|
||||
double toPrice = EMPTY_VALUE;
|
||||
color trendColor = CLR_NONE;
|
||||
double fromPrice = EMPTY_VALUE;
|
||||
if (IsSpecifiedBullish(zgTrend))
|
||||
{
|
||||
//
|
||||
llIDX = GetLowest(lows);
|
||||
hhIDX = GetHighest(lows);
|
||||
|
||||
//
|
||||
trendColor = clrAqua;
|
||||
|
||||
//
|
||||
toTime = lows[hhIDX].time;
|
||||
toPrice = lows[hhIDX].value;
|
||||
|
||||
//
|
||||
fromTime = lows[llIDX].time;
|
||||
fromPrice = lows[llIDX].value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
llIDX = GetLowest(highs);
|
||||
hhIDX = GetHighest(highs);
|
||||
|
||||
//
|
||||
trendColor = clrMagenta;
|
||||
|
||||
//
|
||||
toTime = highs[llIDX].time;
|
||||
toPrice = highs[llIDX].value;
|
||||
|
||||
//
|
||||
fromTime = highs[hhIDX].time;
|
||||
fromPrice = highs[hhIDX].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Requirements for Trend ...
|
||||
has =
|
||||
NotEmptyZero(toPrice) &&
|
||||
NotEmptyZero(fromPrice) &&
|
||||
IsSpecifiedValid(toTime) &&
|
||||
IsSpecifiedValid(fromTime);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = poiDrawer.DrawTrendLine(
|
||||
fromPrice,
|
||||
fromTime,
|
||||
toPrice,
|
||||
toTime,
|
||||
zgTrendLine,
|
||||
zgTrendName,
|
||||
true // Ray Right ...
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
zgTrendLine.Color(trendColor);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
tmpBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (!has)
|
||||
{
|
||||
SpecifiedClean(pivots);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(lows);
|
||||
SpecifiedClean(highs);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasChild(pivots);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
pivots,
|
||||
zgPivots //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(pivots);
|
||||
}
|
||||
|
||||
//
|
||||
// Support ...
|
||||
bool hasSupport = iStructure.support.IsValid();
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
iStructure.support.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
iStructure.support,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
bool hasResistance = iStructure.resistance.IsValid();
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
iStructure.resistance.to = iBar.time;
|
||||
AddIfNotExists(
|
||||
iStructure.resistance,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Collect Bar Support and Resistance (s) ...
|
||||
|
||||
//
|
||||
// Disable Signallers ...
|
||||
has = false;
|
||||
@@ -1069,28 +574,30 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
//
|
||||
// Strategy 1 ...
|
||||
// Works on Support or Resistances Areas ...
|
||||
// has = Strategy1HasSignal(
|
||||
// iBar,
|
||||
// iZone,
|
||||
// supports,
|
||||
// resistances,
|
||||
// iDir,
|
||||
// iStructure,
|
||||
// iFIMAConditions //
|
||||
// );
|
||||
has = Strategy1HasSignal(
|
||||
iBar,
|
||||
iZone,
|
||||
iTargets,
|
||||
iDir,
|
||||
iFIMAConditions,
|
||||
iStructure //
|
||||
);
|
||||
|
||||
//
|
||||
// Strategy 2 ...
|
||||
// Works on MA Crosses ...
|
||||
has = Strategy2HasSignal(
|
||||
iBar,
|
||||
iZone,
|
||||
supports,
|
||||
resistances,
|
||||
iDir,
|
||||
iStructure,
|
||||
iFIMAConditions //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
// has = Strategy2HasSignal(
|
||||
// iBar,
|
||||
// iZone,
|
||||
// iTargets,
|
||||
// iDir,
|
||||
// iFIMAConditions,
|
||||
// iStructure //
|
||||
// );
|
||||
}
|
||||
|
||||
//
|
||||
has = HasDirection(iDir);
|
||||
@@ -1114,7 +621,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
has = PrepareSignal(
|
||||
iSignal,
|
||||
iDir,
|
||||
targets,
|
||||
iTargets,
|
||||
0, // Use Default R2R ...
|
||||
slPrice, // Provided Price for SL ...
|
||||
0 // Specified Risk in Point ....
|
||||
@@ -1134,11 +641,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
iSignal.Clean();
|
||||
iStructure.Clean();
|
||||
iFIMAConditions.Clean();
|
||||
SpecifiedClean(targets);
|
||||
SpecifiedClean(pvPivots);
|
||||
SpecifiedClean(zgPivots);
|
||||
SpecifiedClean(supports);
|
||||
SpecifiedClean(resistances);
|
||||
SpecifiedClean(iTargets);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1180,23 +683,21 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param iZone: XBoxZone, reference to holds affected zone ...
|
||||
* @param supports: XBoxZone, array reference to Provide Exists Supports ...
|
||||
* @param resistances: XBoxZone, array reference to Provide Exists Resistances ...
|
||||
* @param iDir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy1HasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &iZone,
|
||||
XBoxZone &supports[],
|
||||
XBoxZone &resistances[],
|
||||
ENUM_X_DIRECTION &iDir,
|
||||
XFIMAMarketStructure &structure,
|
||||
XFIMAConditions &conditions //
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XFIMAConditions &conditions,
|
||||
XFIMAMarketStructure &structure //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1204,8 +705,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
iZone.Clean();
|
||||
iDir = X_DIRECTION_NONE;
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
@@ -1243,6 +745,81 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Here i Use Specified Supports and Resistances ...
|
||||
XBoxZone tmpBox;
|
||||
bool has = false;
|
||||
XBoxZone supports[];
|
||||
XBoxZone resistances[];
|
||||
|
||||
//
|
||||
has = structure.pvAnalysis.IsValid() &&
|
||||
structure.pvAnalysis.HasSupportBox(tmpBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
tmpBox.to = bar.time;
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = structure.zigzagAnalysis.IsValid() &&
|
||||
structure.zigzagAnalysis.HasSupportBox(tmpBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
tmpBox.to = bar.time;
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = structure.pvAnalysis.IsValid() &&
|
||||
structure.pvAnalysis.HasResistanceBox(tmpBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
tmpBox.to = bar.time;
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = structure.zigzagAnalysis.IsValid() &&
|
||||
structure.zigzagAnalysis.HasResistanceBox(tmpBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
tmpBox.to = bar.time;
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
CArrayObj *zoneObjs;
|
||||
poiDrawer.DrawBoxes(
|
||||
supports,
|
||||
zoneObjs //
|
||||
);
|
||||
poiDrawer.DrawBoxes(
|
||||
resistances,
|
||||
zoneObjs //
|
||||
);
|
||||
poiDrawer.DrawBoxes(
|
||||
structure.fvgs,
|
||||
zoneObjs,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Affected Zone ...
|
||||
// Select a Support or Resistance ...
|
||||
@@ -1272,13 +849,13 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// and Validate it ...
|
||||
if (IsXBullish(patternDir))
|
||||
{
|
||||
iZone = supports[insideZoneIDX];
|
||||
zone = supports[insideZoneIDX];
|
||||
}
|
||||
else if (IsXBearish(patternDir))
|
||||
{
|
||||
iZone = resistances[insideZoneIDX];
|
||||
zone = resistances[insideZoneIDX];
|
||||
}
|
||||
result = iZone.IsValid();
|
||||
result = zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -1287,20 +864,29 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
//
|
||||
// Validate affected Zone based on Pattern's Bar ...
|
||||
result = IsXBullish(patternDir)
|
||||
? bar.high > iZone.upper
|
||||
? bar.high > zone.upper
|
||||
: IsXBearish(patternDir)
|
||||
? bar.low < iZone.lower
|
||||
? bar.low < zone.lower
|
||||
: false;
|
||||
if (result)
|
||||
{
|
||||
iDir = patternDir;
|
||||
//
|
||||
dir = patternDir;
|
||||
|
||||
//
|
||||
// Handle Targets Detection ...
|
||||
|
||||
//
|
||||
// Check Reversal FVGS ...
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
if (!result)
|
||||
{
|
||||
iZone.Clean();
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1311,23 +897,21 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param iZone: XBoxZone, reference to holds affected zone ...
|
||||
* @param supports: XBoxZone, array reference to Provide Exists Supports ...
|
||||
* @param resistances: XBoxZone, array reference to Provide Exists Resistances ...
|
||||
* @param iDir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy2HasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &iZone,
|
||||
XBoxZone &supports[],
|
||||
XBoxZone &resistances[],
|
||||
ENUM_X_DIRECTION &iDir,
|
||||
XFIMAMarketStructure &structure,
|
||||
XFIMAConditions &conditions //
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XFIMAConditions &conditions,
|
||||
XFIMAMarketStructure &structure //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1335,8 +919,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
iZone.Clean();
|
||||
iDir = X_DIRECTION_NONE;
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
@@ -1351,109 +936,46 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
result = HasDirection(structure.maCrossDir);
|
||||
|
||||
//
|
||||
// Collecting Bar Support and Resistances ...
|
||||
XBoxZone barZones[];
|
||||
int count = fimaHelper.ExtractBarZones(
|
||||
barZones,
|
||||
bar.Index(),
|
||||
analyserConfig.recentlyPatternsMaxAllowedCollecting, // Number of Zones ...
|
||||
analyserConfig.supportAndResistanceBreakeValidationLength, // Break Validation Length ...
|
||||
analyserConfig.supportAndResistanceBreakeValidationLength > 0, // Validate Fake Breaked Zones ...
|
||||
4, // Shadow Multiplier ...
|
||||
analyserConfig.minAllowdSupportAndResistanceStrength, // Validation Strength ...
|
||||
7, // Validation Length ...
|
||||
analyserConfig.supportAndResistanceMaxAllowedLoopback // Max Allowed Loopback ...
|
||||
);
|
||||
Copy(
|
||||
supports,
|
||||
barZones,
|
||||
false // Force Clean ...
|
||||
);
|
||||
Copy(
|
||||
resistances,
|
||||
barZones,
|
||||
false // Force Clean ...
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Conditions ...
|
||||
XBoxZone fvg;
|
||||
ENUM_X_DIRECTION tmpDir;
|
||||
bool hasFVG = poiDetector.HasFVG(
|
||||
bar,
|
||||
tmpDir,
|
||||
fvg,
|
||||
3 // Max Loopback ...
|
||||
);
|
||||
|
||||
//
|
||||
// Validate result by FVG ...
|
||||
// result =
|
||||
// result &&
|
||||
// hasFVG &&
|
||||
// fvg.dir == structure.maCrossDir;
|
||||
|
||||
//
|
||||
// Prepare zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
XCBoxObject *iFVGObj;
|
||||
poiDrawer.DrawBox(
|
||||
fvg,
|
||||
iFVGObj //
|
||||
);
|
||||
|
||||
//
|
||||
// Draw Support or Resistances based on Direction of Cross ...
|
||||
CArrayObj *iZones;
|
||||
count = poiDrawer.DrawBoxes(
|
||||
barZones,
|
||||
iZones //
|
||||
);
|
||||
|
||||
//
|
||||
Print("Cross Happens ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare iZone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
iZone.to = bar.time;
|
||||
iZone.from = GetBarTime(
|
||||
zone.to = bar.time;
|
||||
zone.from = GetBarTime(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
bar.Index() + 2 //
|
||||
);
|
||||
iZone.symbol = bar.symbol;
|
||||
iZone.period = bar.period;
|
||||
iZone.dir = structure.maCrossDir;
|
||||
iZone.lower = bar.FindLowest(2, MODE_LOW);
|
||||
iZone.upper = bar.FindHighest(2, MODE_HIGH);
|
||||
iZone.type = name + "_" + ToXString(structure.maCrossDir);
|
||||
|
||||
zone.symbol = bar.symbol;
|
||||
zone.period = bar.period;
|
||||
zone.dir = structure.maCrossDir;
|
||||
zone.lower = bar.FindLowest(2, MODE_LOW);
|
||||
zone.upper = bar.FindHighest(2, MODE_HIGH);
|
||||
zone.type = name + "_" + ToXString(structure.maCrossDir);
|
||||
|
||||
//
|
||||
result = iZone.IsValid();
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
if (result)
|
||||
{
|
||||
iDir = structure.maCrossDir;
|
||||
//
|
||||
dir = structure.maCrossDir;
|
||||
|
||||
//
|
||||
// Handle Targets Detection ...
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
if (!result)
|
||||
{
|
||||
iZone.Clean();
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
}
|
||||
|
||||
//
|
||||
fvg.Clean();
|
||||
XClean(barZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -527,79 +527,14 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
XBoxZone iBox;
|
||||
bool has = false;
|
||||
int maxAllowedCollecting = 50;
|
||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Detecting POI Based on Config ...
|
||||
|
||||
//
|
||||
// Order Block ...
|
||||
if (config.detectOB)
|
||||
{
|
||||
//
|
||||
bool isOB = HasOB(
|
||||
forBar,
|
||||
iDir,
|
||||
structure.ob,
|
||||
config.obLoopback //
|
||||
);
|
||||
bool isBullishOB = isOB &&
|
||||
IsSpecifiedBullish(iDir);
|
||||
bool isBearishOB = isOB &&
|
||||
IsSpecifiedBearish(iDir);
|
||||
if (!isOB)
|
||||
{
|
||||
structure.ob.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Touches ...
|
||||
if (isOB)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
structure.ob,
|
||||
obs,
|
||||
maxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gap ...
|
||||
if (config.detectFVG)
|
||||
{
|
||||
//
|
||||
bool isFVG = HasFVG(
|
||||
forBar,
|
||||
iDir,
|
||||
structure.fvg,
|
||||
config.fvgLoopback //
|
||||
);
|
||||
bool isBullishFVG = isFVG &&
|
||||
IsSpecifiedBullish(iDir);
|
||||
bool isBearishFVG = isFVG &&
|
||||
IsSpecifiedBearish(iDir);
|
||||
if (!isFVG)
|
||||
{
|
||||
structure.fvg.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Touches ...
|
||||
if (isFVG)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
structure.fvg,
|
||||
fvgs,
|
||||
maxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Momentum Bar ...
|
||||
if (config.detectMomentum)
|
||||
@@ -815,107 +750,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
SpecifiedClean(swings);
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Supports ...
|
||||
if (config.detectSupport)
|
||||
{
|
||||
//
|
||||
XOHCL support;
|
||||
bool hasSupport = HasSupport(
|
||||
forBar,
|
||||
support,
|
||||
config.supportAndResistanceValidationLength,
|
||||
config.supportAndResistanceMaxAllowedLoopback //
|
||||
);
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
XBoxZone supportBox;
|
||||
has = ToSupportBox(support, supportBox);
|
||||
|
||||
//
|
||||
// Validate Zone Strength if Provided ...
|
||||
if (config.minAllowdSupportAndResistanceStrength > 0)
|
||||
{
|
||||
//
|
||||
has = has &&
|
||||
ValidateStrength(
|
||||
supportBox,
|
||||
config.minAllowdSupportAndResistanceStrength //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
supportBox,
|
||||
supports,
|
||||
maxAllowedCollecting //
|
||||
);
|
||||
|
||||
//
|
||||
structure.support = supportBox;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Support Touches ...
|
||||
supportBox.Clean();
|
||||
}
|
||||
support.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Resistance ...
|
||||
if (config.detectResistance)
|
||||
{
|
||||
//
|
||||
XOHCL resistance;
|
||||
bool hasResistance = HasResistance(
|
||||
forBar,
|
||||
resistance,
|
||||
config.supportAndResistanceValidationLength,
|
||||
config.supportAndResistanceMaxAllowedLoopback //
|
||||
);
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
XBoxZone resistanceBox;
|
||||
has = ToResistanceBox(resistance, resistanceBox);
|
||||
|
||||
//
|
||||
// Validate Zone Strength if Provided ...
|
||||
if (config.minAllowdSupportAndResistanceStrength > 0)
|
||||
{
|
||||
//
|
||||
has = has &&
|
||||
ValidateStrength(
|
||||
resistanceBox,
|
||||
config.minAllowdSupportAndResistanceStrength //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
resistanceBox,
|
||||
resistances,
|
||||
maxAllowedCollecting //
|
||||
);
|
||||
|
||||
//
|
||||
structure.resistance = resistanceBox;
|
||||
}
|
||||
|
||||
//
|
||||
resistanceBox.Clean();
|
||||
}
|
||||
resistance.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Indicator Pivots ...
|
||||
|
||||
@@ -935,9 +769,9 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
fimaHelper.ExtractMAPivots(
|
||||
structure.maCrosses,
|
||||
idx,
|
||||
config.recentlyPatternsMaxAllowedCollecting,
|
||||
config.zonesRequiredNumber,
|
||||
config.validMACrossDiffMultiplier,
|
||||
config.recentlyPatternsMaxLookupLength //
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -956,14 +790,15 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
fimaHelper.ExtractHKPivots(
|
||||
structure.hkSwitches,
|
||||
idx,
|
||||
config.recentlyPatternsMaxAllowedCollecting,
|
||||
config.recentlyPatternsMaxLookupLength //
|
||||
config.zonesRequiredNumber,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting SAR Switches ...
|
||||
if (config.detectSARSwitches) {
|
||||
if (config.detectSARSwitches)
|
||||
{
|
||||
//
|
||||
idx = forBar.Index();
|
||||
has = fimaHelper.HasSARSwitch(
|
||||
@@ -975,8 +810,8 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
fimaHelper.ExtractSARPivots(
|
||||
structure.sarSwitches,
|
||||
idx,
|
||||
config.recentlyPatternsMaxAllowedCollecting,
|
||||
config.recentlyPatternsMaxLookupLength //
|
||||
config.zonesRequiredNumber,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1002,24 +837,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse Based on SAR ...
|
||||
if (config.analyseFIMASARPivots)
|
||||
{
|
||||
//
|
||||
XPivotAnalysis analysis;
|
||||
has = AnalyseSARPivots(
|
||||
analysis, // Result ...
|
||||
forBar.Index(), // Bar Index ...
|
||||
config.numberOfRequiredPivotsForAnalysis, // Required Number of Pivots ...
|
||||
config.maxAllowedLoopbackLengthForAnalysis // Max Allowed Loopback ...
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
structure.sarAnalysis = analysis;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse Based on ZigZag ...
|
||||
if (config.analyseFIMAZigZagPivots)
|
||||
@@ -1039,195 +856,16 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
}
|
||||
|
||||
//
|
||||
// COMPLEX Actions ...
|
||||
|
||||
//
|
||||
// Detect Recently Tested Zones ...
|
||||
if ((config.detectSupport ||
|
||||
config.detectResistance) &&
|
||||
config.recentlyZonesMaxLookupLength > 0)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
int start = forBar.Index();
|
||||
int end = start + config.recentlyZonesMaxLookupLength;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
has = forBar.BarAt(i, iBar);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Selecting Support and Resistances ...
|
||||
|
||||
//
|
||||
// Supports ...
|
||||
idx = GetYoungestBefore(iBar.time, supports);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Testing ...
|
||||
has = IsTested(iBar, supports[idx]);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
supports[idx],
|
||||
structure.recentlyTestedZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check Breaked ...
|
||||
has = IsBreaked(iBar, supports[idx]);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
supports[idx],
|
||||
structure.recentlyBreakedZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistances ...
|
||||
idx = GetYoungestBefore(iBar.time, resistances);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Testing ...
|
||||
has = IsTested(iBar, resistances[idx]);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
resistances[idx],
|
||||
structure.recentlyTestedZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check Breaked ...
|
||||
has = IsBreaked(iBar, resistances[idx]);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
resistances[idx],
|
||||
structure.recentlyBreakedZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Checkup for FakeBreaked Zones ...
|
||||
if ((config.detectSupport ||
|
||||
config.detectResistance) &&
|
||||
HasChild(structure.recentlyBreakedZones))
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Detect Youngest Recently Breaked Zones ...
|
||||
idx = GetYoungest(structure.recentlyBreakedZones);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
structure.fakeBreakedZone = structure.recentlyBreakedZones[idx];
|
||||
|
||||
//
|
||||
// Update To Time ...
|
||||
structure.fakeBreakedZone.to = forBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Price Going Back to Zone Area ...
|
||||
has = structure.fakeBreakedZone.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Current Bar Acted Based on Zone ...
|
||||
has = structure.fakeBreakedZone.IsBullish()
|
||||
? forBar.close > structure.fakeBreakedZone.upper
|
||||
: forBar.close < structure.fakeBreakedZone.lower;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Validate Breake Length ...
|
||||
|
||||
//
|
||||
// Get Youngest Breaker Bar ...
|
||||
XOHCL breakerBar;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XOHCL breakerBars[];
|
||||
int breakerBarsCount = GetBreakerBars(
|
||||
structure.fakeBreakedZone,
|
||||
breakerBars //
|
||||
);
|
||||
has = IsValidSize(breakerBarsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
idx = GetYoungestBar(breakerBars);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
breakerBar = breakerBars[idx];
|
||||
}
|
||||
}
|
||||
SpecifiedClean(breakerBars);
|
||||
}
|
||||
has = breakerBar.IsValid();
|
||||
|
||||
//
|
||||
// Validate BreakerBars Length ...
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
int diff = breakerBar.Index() - forBar.Index();
|
||||
|
||||
//
|
||||
has =
|
||||
config.supportAndResistanceBreakeValidationLength <= 0
|
||||
? true
|
||||
: diff <= config.supportAndResistanceBreakeValidationLength;
|
||||
}
|
||||
|
||||
//
|
||||
if (!has)
|
||||
{
|
||||
structure.fakeBreakedZone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
breakerBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Recently Patterns ...
|
||||
if (config.recentlyPatternsMaxLookupLength > 0)
|
||||
// Zones and Patterns Recent Actions ...
|
||||
if (config.zonesRequiredNumber > 0 &&
|
||||
config.zonesMaxAllowedLoopbackLength > 0)
|
||||
{
|
||||
//
|
||||
// Detect Recent Patterns ...
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
XOHCL tmpBar;
|
||||
XPivot iPivot;
|
||||
XBoxZone iBox;
|
||||
bool has = false;
|
||||
@@ -1236,75 +874,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
ENUM_X_SORT_BY iSortBy = X_SORT_BY_DATE;
|
||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||
ENUM_X_DIRECTION iSortDir = X_DIRECTION_BULLISH;
|
||||
int end = start + config.recentlyPatternsMaxLookupLength;
|
||||
|
||||
//
|
||||
// Order Blocks ...
|
||||
if (config.detectOB)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
obs,
|
||||
structure.obs //
|
||||
);
|
||||
Sort(
|
||||
structure.obs,
|
||||
iSortBy,
|
||||
iSortDir,
|
||||
config.recentlyPatternsMaxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
if (config.detectFVG)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
fvgs,
|
||||
structure.fvgs //
|
||||
);
|
||||
Sort(
|
||||
structure.fvgs,
|
||||
iSortBy,
|
||||
iSortDir,
|
||||
config.recentlyPatternsMaxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Supports ...
|
||||
if (config.detectSupport)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
supports,
|
||||
structure.supports //
|
||||
);
|
||||
Sort(
|
||||
structure.supports,
|
||||
iSortBy,
|
||||
iSortDir,
|
||||
config.recentlyPatternsMaxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistances ...
|
||||
if (config.detectResistance)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
resistances,
|
||||
structure.resistances //
|
||||
);
|
||||
Sort(
|
||||
structure.resistances,
|
||||
iSortBy,
|
||||
iSortDir,
|
||||
config.recentlyPatternsMaxAllowedCollecting //
|
||||
);
|
||||
}
|
||||
int end = start + config.zonesMaxAllowedLoopbackLength;
|
||||
|
||||
//
|
||||
// Loop through Items ...
|
||||
@@ -1323,6 +893,112 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// OB ...
|
||||
has = HasOB(
|
||||
iBar,
|
||||
iDir,
|
||||
iBox,
|
||||
5 //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
obs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// FVG ...
|
||||
has = HasFVG(
|
||||
iBar,
|
||||
iDir,
|
||||
iBox,
|
||||
5 //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
fvgs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// SUPPORT ...
|
||||
tmpBar.Clean();
|
||||
has = HasSupport(
|
||||
iBar,
|
||||
tmpBar,
|
||||
config.zonesValidationLength,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = ToSupportBox(tmpBar, iBox, iBar.time);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Strength ...
|
||||
if (config.zonesMinAlloweStrength > 0)
|
||||
{
|
||||
has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol));
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
iBox.Clean();
|
||||
tmpBar.Clean();
|
||||
|
||||
//
|
||||
// RESISATNCE ...
|
||||
tmpBar.Clean();
|
||||
has = HasResistance(
|
||||
iBar,
|
||||
tmpBar,
|
||||
config.zonesValidationLength,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = ToResistanceBox(tmpBar, iBox, iBar.time);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Strength ...
|
||||
if (config.zonesMinAlloweStrength > 0)
|
||||
{
|
||||
has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol));
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
iBox.Clean();
|
||||
tmpBar.Clean();
|
||||
|
||||
//
|
||||
// Bars Detecting ...
|
||||
|
||||
@@ -1595,14 +1271,201 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
iBox.Clean();
|
||||
tmpBar.Clean();
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Zones Extractions ...
|
||||
|
||||
//
|
||||
// XBARZONES ...
|
||||
XBoxZone tmpZones[];
|
||||
int tmpZonesCount = fimaHelper.ExtractBarZones(
|
||||
tmpZones,
|
||||
forBar.Index(),
|
||||
config.zonesRequiredNumber,
|
||||
config.zonesBreakValidationLength,
|
||||
config.zonesBreakValidationLength > 0,
|
||||
config.zonesBarShadowMultiplier,
|
||||
config.zonesMinAlloweStrength,
|
||||
config.zonesValidationLength,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
has = IsValidSize(tmpZonesCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < tmpZonesCount; i++)
|
||||
{
|
||||
//
|
||||
if (tmpZones[i].IsBullish())
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpZones[i],
|
||||
supports //
|
||||
);
|
||||
}
|
||||
else if (tmpZones[i].IsBearish())
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpZones[i],
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XClean(tmpZones);
|
||||
tmpZonesCount = fimaHelper.ExtractHKZones(
|
||||
tmpZones,
|
||||
forBar.Index(),
|
||||
config.zonesRequiredNumber,
|
||||
config.zonesBreakValidationLength,
|
||||
config.zonesBreakValidationLength > 0,
|
||||
config.zonesBarShadowMultiplier,
|
||||
config.zonesMinAlloweStrength,
|
||||
config.zonesValidationLength,
|
||||
config.zonesMaxAllowedLoopbackLength //
|
||||
);
|
||||
has = IsValidSize(tmpZonesCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < tmpZonesCount; i++)
|
||||
{
|
||||
//
|
||||
if (tmpZones[i].IsBullish())
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpZones[i],
|
||||
supports //
|
||||
);
|
||||
}
|
||||
else if (tmpZones[i].IsBearish())
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpZones[i],
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
iBox.Clean();
|
||||
tmpBar.Clean();
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Analysis Zones ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
|
||||
//
|
||||
// Support ...
|
||||
has = structure.pvAnalysis.IsValid() &&
|
||||
structure.pvAnalysis.HasSupportBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
has = structure.pvAnalysis.IsValid() &&
|
||||
structure.pvAnalysis.HasResistanceBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// XZG ...
|
||||
|
||||
//
|
||||
// Support ...
|
||||
has = structure.zigzagAnalysis.IsValid() &&
|
||||
structure.zigzagAnalysis.HasSupportBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
supports //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
has = structure.zigzagAnalysis.IsValid() &&
|
||||
structure.zigzagAnalysis.HasResistanceBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBox,
|
||||
resistances //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// ZONES Specified ...
|
||||
|
||||
//
|
||||
// OBS ...
|
||||
CheckZones(forBar, obs);
|
||||
Copy(
|
||||
obs,
|
||||
structure.obs //
|
||||
);
|
||||
|
||||
//
|
||||
// FVGS ...
|
||||
CheckZones(forBar, fvgs);
|
||||
Copy(
|
||||
fvgs,
|
||||
structure.fvgs //
|
||||
);
|
||||
|
||||
//
|
||||
// SUPPORTS ...
|
||||
CheckZones(forBar, supports);
|
||||
Copy(
|
||||
supports,
|
||||
structure.supports //
|
||||
);
|
||||
|
||||
//
|
||||
// RESISTANCES ...
|
||||
CheckZones(forBar, resistances);
|
||||
Copy(
|
||||
resistances,
|
||||
structure.resistances //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1611,9 +1474,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Tools / Actions ...
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,20 +37,9 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Flags ...
|
||||
|
||||
//
|
||||
bool detectSupport;
|
||||
bool detectResistance;
|
||||
|
||||
//
|
||||
bool detectSwingTrend;
|
||||
|
||||
//
|
||||
bool detectOB;
|
||||
bool detectFVG;
|
||||
|
||||
//
|
||||
bool detectStarPattern;
|
||||
bool detectFlagPattern;
|
||||
@@ -66,7 +55,6 @@ struct XFIMAPatternDetectorConfig
|
||||
|
||||
//
|
||||
bool analyseFIMAPVPivots;
|
||||
bool analyseFIMASARPivots;
|
||||
bool analyseFIMAZigZagPivots;
|
||||
|
||||
//
|
||||
@@ -80,27 +68,19 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Configs ...
|
||||
|
||||
//
|
||||
// OB / FVG ...
|
||||
int obLoopback;
|
||||
int fvgLoopback;
|
||||
|
||||
//
|
||||
// Trending ...
|
||||
int trendingNumberOfSwings;
|
||||
int trendingSwingShoulders;
|
||||
|
||||
//
|
||||
int recentlyPatternsMaxLookupLength;
|
||||
int recentlyPatternsMaxAllowedCollecting;
|
||||
|
||||
//
|
||||
// Support and Resistance ...
|
||||
int recentlyZonesMaxLookupLength;
|
||||
int supportAndResistanceValidationLength;
|
||||
int minAllowdSupportAndResistanceStrength;
|
||||
int supportAndResistanceMaxAllowedLoopback;
|
||||
int supportAndResistanceBreakeValidationLength;
|
||||
int zonesRequiredNumber;
|
||||
int zonesValidationLength;
|
||||
double zonesMinAlloweStrength;
|
||||
int zonesBreakValidationLength;
|
||||
double zonesBarShadowMultiplier;
|
||||
int zonesMaxAllowedLoopbackLength;
|
||||
|
||||
//
|
||||
// TrueGap ...
|
||||
@@ -149,23 +129,18 @@ struct XFIMAPatternDetectorConfig
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
detectStarPattern = false;
|
||||
detectFlagPattern = false;
|
||||
detectRisingPattern = false;
|
||||
detectPiercingPattern = false;
|
||||
detectSignalKeyBarPattern = false;
|
||||
detectPinned = false;
|
||||
detectMomentum = false;
|
||||
detectEngulfed = false;
|
||||
detectTrueGaped = false;
|
||||
detectSwingTrend = false;
|
||||
detectStarPattern = false;
|
||||
detectFlagPattern = false;
|
||||
detectRisingPattern = false;
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
detectPiercingPattern = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
detectSignalKeyBarPattern = false;
|
||||
|
||||
//
|
||||
detectMACrosses = false;
|
||||
@@ -176,30 +151,29 @@ struct XFIMAPatternDetectorConfig
|
||||
detectSARSwitches = false;
|
||||
|
||||
//
|
||||
obLoopback = 0;
|
||||
fvgLoopback = 0;
|
||||
zonesRequiredNumber = 0;
|
||||
zonesValidationLength = 0;
|
||||
zonesMinAlloweStrength = 0;
|
||||
zonesBarShadowMultiplier = 0;
|
||||
zonesBreakValidationLength = 0;
|
||||
zonesMaxAllowedLoopbackLength = 0;
|
||||
|
||||
//
|
||||
trendingNumberOfSwings = 0;
|
||||
trendingSwingShoulders = 0;
|
||||
recentlyZonesMaxLookupLength = 0;
|
||||
recentlyPatternsMaxLookupLength = 0;
|
||||
recentlyPatternsMaxAllowedCollecting = 0;
|
||||
supportAndResistanceValidationLength = 0;
|
||||
minAllowdSupportAndResistanceStrength = 0;
|
||||
supportAndResistanceMaxAllowedLoopback = 0;
|
||||
supportAndResistanceBreakeValidationLength = 0;
|
||||
momentumBarRangeLength = 0;
|
||||
pvPivotsValidationLength = 0;
|
||||
pinnedBarForceDirection = false;
|
||||
momentumBarApprovedMultiplier = 0;
|
||||
signalKeyBarForceDirection = false;
|
||||
truwGapApprovedPointMultiplier = 0;
|
||||
flagPatternMinimumPullbackBars = 0;
|
||||
momentumBarRangeLength = 0;
|
||||
momentumBarApprovedMultiplier = 0;
|
||||
pinnedBaarShadowApprovedMultiplier = 0;
|
||||
pinnedBarMinimumPinBarRangeMultiplier = 0;
|
||||
pinnedBarForceDirection = false;
|
||||
signalKeyBarShadowApprovedMultiplier = 0;
|
||||
signalKeyBarMinimumPinBarRangeMultiplier = 0;
|
||||
signalKeyBarForceDirection = false;
|
||||
pvPivotsValidationLength = 0;
|
||||
numberOfRequiredPivotsForAnalysis = 0;
|
||||
pinnedBaarShadowApprovedMultiplier = 0;
|
||||
maxAllowedLoopbackLengthForAnalysis = 0;
|
||||
signalKeyBarShadowApprovedMultiplier = 0;
|
||||
pinnedBarMinimumPinBarRangeMultiplier = 0;
|
||||
signalKeyBarMinimumPinBarRangeMultiplier = 0;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
@@ -210,17 +184,6 @@ struct XFIMAPatternDetectorConfig
|
||||
*/
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = false;
|
||||
@@ -239,7 +202,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
//
|
||||
@@ -250,11 +212,6 @@ struct XFIMAPatternDetectorConfig
|
||||
detectHKSwitches = true;
|
||||
detectSARSwitches = true;
|
||||
|
||||
//
|
||||
// OB / FVg ...
|
||||
obLoopback = 5;
|
||||
fvgLoopback = 5;
|
||||
|
||||
//
|
||||
// Trending ...
|
||||
trendingNumberOfSwings = 3;
|
||||
@@ -262,13 +219,12 @@ struct XFIMAPatternDetectorConfig
|
||||
|
||||
//
|
||||
// Support and Resistance ...
|
||||
recentlyZonesMaxLookupLength = 100;
|
||||
recentlyPatternsMaxLookupLength = 50;
|
||||
recentlyPatternsMaxAllowedCollecting = 20;
|
||||
supportAndResistanceValidationLength = 100;
|
||||
minAllowdSupportAndResistanceStrength = 1;
|
||||
supportAndResistanceMaxAllowedLoopback = 1500;
|
||||
supportAndResistanceBreakeValidationLength = 4;
|
||||
zonesRequiredNumber = 25;
|
||||
zonesValidationLength = 21;
|
||||
zonesMinAlloweStrength = 2;
|
||||
zonesBarShadowMultiplier = 4;
|
||||
zonesBreakValidationLength = 3;
|
||||
zonesMaxAllowedLoopbackLength = 200;
|
||||
|
||||
//
|
||||
// TrueGap ...
|
||||
@@ -307,17 +263,6 @@ struct XFIMAPatternDetectorConfig
|
||||
*/
|
||||
void FullDetect()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = true;
|
||||
detectFVG = true;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = true;
|
||||
detectResistance = true;
|
||||
detectSwingTrend = true;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = true;
|
||||
@@ -336,7 +281,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = true;
|
||||
analyseFIMASARPivots = true;
|
||||
analyseFIMAZigZagPivots = true;
|
||||
|
||||
//
|
||||
@@ -350,17 +294,6 @@ struct XFIMAPatternDetectorConfig
|
||||
*/
|
||||
void OffDetectors()
|
||||
{
|
||||
//
|
||||
// OB / FVG ...
|
||||
detectOB = false;
|
||||
detectFVG = false;
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
detectSupport = false;
|
||||
detectResistance = false;
|
||||
detectSwingTrend = false;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
detectStarPattern = false;
|
||||
@@ -379,7 +312,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
//
|
||||
@@ -400,12 +332,6 @@ struct XFIMAMarketStructure
|
||||
//
|
||||
XOHCL bar;
|
||||
|
||||
//
|
||||
XBoxZone ob;
|
||||
XBoxZone fvg;
|
||||
XBoxZone support;
|
||||
XBoxZone resistance;
|
||||
|
||||
//
|
||||
XBoxZone obs[];
|
||||
XBoxZone fvgs[];
|
||||
@@ -425,21 +351,9 @@ struct XFIMAMarketStructure
|
||||
XBoxZone piercingPatterns[];
|
||||
XBoxZone signalKeyBarPatterns[];
|
||||
|
||||
//
|
||||
// Previous Support or Resistance based on current ...
|
||||
//
|
||||
// Current Support is Touched => Prev Support;
|
||||
// Current Resistance is Touched => Prev Resistance;
|
||||
XBoxZone fakeBreakedZone;
|
||||
|
||||
//
|
||||
XBoxZone recentlyTestedZones[];
|
||||
XBoxZone recentlyBreakedZones[];
|
||||
|
||||
//
|
||||
// Analysis ...
|
||||
XPivotAnalysis pvAnalysis;
|
||||
XPivotAnalysis sarAnalysis;
|
||||
XPivotAnalysis zigzagAnalysis;
|
||||
|
||||
//
|
||||
@@ -489,22 +403,12 @@ struct XFIMAMarketStructure
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
ob.Clean();
|
||||
fvg.Clean();
|
||||
support.Clean();
|
||||
resistance.Clean();
|
||||
|
||||
//
|
||||
fakeBreakedZone.Clean();
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
flagSwing.Clean();
|
||||
|
||||
//
|
||||
pvAnalysis.Clean();
|
||||
sarAnalysis.Clean();
|
||||
zigzagAnalysis.Clean();
|
||||
|
||||
//
|
||||
@@ -548,8 +452,6 @@ struct XFIMAMarketStructure
|
||||
|
||||
//
|
||||
SpecifiedClean(trendSwings);
|
||||
SpecifiedClean(recentlyTestedZones);
|
||||
SpecifiedClean(recentlyBreakedZones);
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
|
||||
Reference in New Issue
Block a user