This commit is contained in:
2025-10-01 12:06:18 +03:30
parent c5a1e326b2
commit 684d3028c4
11 changed files with 4472 additions and 2379 deletions
@@ -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