This commit is contained in:
2025-09-30 03:53:35 +03:30
parent ab38b28fab
commit 32b218afbc
7 changed files with 674 additions and 254 deletions
+371 -1
View File
@@ -96,7 +96,9 @@ class XCBaseHelper : public XCBase
} }
// //
virtual void Free() {} virtual void Free()
{
}
// //
// Generate Tag ... // Generate Tag ...
@@ -123,6 +125,374 @@ class XCBaseHelper : public XCBase
// //
// Functions ... // Functions ...
/**
* Extract Validated Zones ...
*
* @param zones: XBoxZone, collection reference to holds results ...
* @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFZones: int, required Number of Zones ...
* @param breakValidLength: int, Breake Validation Length of Zones ...
* @param validateFakeBreakes: bool, Validation Fake Breaked Zones ...
* @param shadowMultiplier: double a Shadow Multiplier for Validation ...
* @param validationStrength: double, Minimum Strngth Multiplier in Point to Validate ...
* @param validationLength: int, Validation Length of Zones ...
* @param maxAllowedLoopbackLength: int, max Allowed Loopback Length ...
*
* @return ( int )
*/
int ExtractBarZones(
XBoxZone &zones[],
int barIndex = 0,
int requiredNumberOFZones = 50,
int breakValidLength = 3,
bool validateFakeBreakes = true,
double shadowMultiplier = 3,
double validationStrength = 1,
int validationLength = 21,
int maxAllowedLoopbackLength = 1500 //
)
{
//
int result = 0;
//
// Prepare ...
SpecifiedClean(zones);
//
// Normalize ...
barIndex = NormalizeInt(barIndex, 0);
validationLength = NormalizeInt(validationLength, 7);
shadowMultiplier = NormalizeDouble(shadowMultiplier, 1);
validationStrength = NormalizeDouble(validationStrength, 1);
requiredNumberOFZones = NormalizeInt(requiredNumberOFZones, 5);
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 100);
//
// Reading Values ...
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
double minAllowedStrength = (validationStrength * GetPoints(symbol));
//
XOHCL bar;
bool has = false;
//
// Initialized Start Bar ...
has = bar.Init(
symbol,
period,
barIndex //
);
if (!has)
{
return result;
}
//
XOHCL iBar;
XBoxZone zone;
int start = barIndex;
bool isBullish = false;
bool isBearish = false;
bool lowShadowPassed = false;
bool highShadowPassed = false;
ENUM_X_DIRECTION dir = X_DIRECTION_NONE;
int end = start + maxAllowedLoopbackLength;
for (int i = start; i < end; i++)
{
//
// Cleanup ...
iBar.Clean();
zone.Clean();
dir = X_DIRECTION_NONE;
//
// Reading HK Buffesr ...
has = bar.BarAt(i, iBar);
if (!has)
{
continue;
}
//
// Check Direction ...
isBullish = iBar.open < iBar.close;
isBearish = iBar.open > iBar.close;
dir =
(isBullish && !isBearish)
? X_DIRECTION_BULLISH
: (isBearish && !isBullish)
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
has = HasDirection(dir);
if (!has)
{
continue;
}
//
// Low Shadow ...
lowShadowPassed = iBar.GetLowShadow() >= (shadowMultiplier * iBar.GetHighShadow());
//
// High Shadow ...
highShadowPassed = iBar.GetHighShadow() >= (shadowMultiplier * iBar.GetLowShadow());
//
has = (lowShadowPassed && !highShadowPassed) ||
(highShadowPassed && !lowShadowPassed);
if (!has)
{
continue;
}
//
// Filling Zone ...
//
zone.symbol = symbol;
zone.period = period;
zone.from = GetBarTime(
zone.symbol,
zone.period,
i //
);
zone.dir = lowShadowPassed
? X_DIRECTION_BULLISH
: highShadowPassed
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
//
zone.upper =
IsXBullish(zone.dir)
? iBar.GetDown()
: IsXBearish(zone.dir)
? iBar.high
: EMPTY_VALUE;
//
zone.lower =
IsXBullish(zone.dir)
? iBar.low
: IsXBearish(zone.dir)
? iBar.GetUp()
: EMPTY_VALUE;
//
zone.to = bar.time;
zone.type = "XBar_" + (IsXBullish(zone.dir) ? "Support" : IsXBearish(zone.dir) ? "Resistance"
: "") +
"_" + ToXString(TimeToSeconds(zone.from));
//
// Validate ...
has =
zone.IsValid() &&
HasDirection(zone.dir) &&
NotEmptyZero(zone.upper) &&
NotEmptyZero(zone.lower) &&
(zone.IsBullish()
? bar.low > zone.upper
: bar.high < zone.lower) &&
(zone.upper - zone.lower) >= minAllowedStrength &&
ValidateBarZone(zone, validationLength, breakValidLength, validateFakeBreakes);
if (has)
{
//
AddIfNotExists(
zone,
zones //
);
}
//
// Cleanup Resources ...
zone.Clean();
//
// Validating ...
result = ArraySize(zones);
has = IsValidSize(result) &&
result >= requiredNumberOFZones;
if (has)
{
break;
}
}
//
// Cleanup Resources ...
bar.Clean();
iBar.Clean();
zone.Clean();
//
return result;
}
/**
* Validate Bar Zone ...
*
* @param zone: XBoxZone, reference to Specified Zone ...
* @param validationLength: int, Validation Length of Zones ...
* @param breakValidLength: int, Break Validation Length of Zones ...
* @param validateFakeBreakes: bool, Validation Fake Breaked Zones ...
*
* @return ( bool )
*/
bool ValidateBarZone(
XBoxZone &zone,
int validationLength = 1,
int breakValidLength = 3,
bool validateFakeBreakes = true //
)
{
//
bool result = false;
//
// Normalize ...
validationLength = NormalizeInt(validationLength, 1);
breakValidLength = NormalizeInt(breakValidLength, 2);
//
// Validate ...
result = zone.IsValid();
if (!result)
{
return result;
}
//
// Requirements ...
XOHCL iBar;
int count = 0;
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
int start = zone.FromIndex() + 1;
int end = start + validationLength;
//
// Validate Before ...
for (int i = start; i < end; i++)
{
//
// Initialize Indexed Bar ...
iBar.Clean();
result = iBar.Init(
symbol,
period,
i //
);
if (!result)
{
break;
}
//
result = zone.IsBullish()
? iBar.low > zone.lower
: iBar.high < zone.upper;
if (!result)
{
break;
}
}
//
// Validating After ...
if (result)
{
//
start = zone.ToIndex() + 1;
count = zone.FromIndex() - start;
end = start + count;
for (int i = start; i < end; i++)
{
//
// Initialized Indexed Bar ...
iBar.Clean();
result = iBar.Init(
symbol,
period,
i //
);
if (!result)
{
break;
}
//
result = zone.IsBullish()
? iBar.low > zone.lower
: iBar.high < zone.upper;
if (!result)
{
//
// Check For Fake Breake ...
if (validateFakeBreakes && breakValidLength > 0)
{
//
result = i - 1 >= 0;
if (result)
{
//
for (int j = i - 1; j >= zone.ToIndex(); j--)
{
//
// Initialized Indexed Bar ...
iBar.Clean();
result = iBar.Init(
symbol,
period,
j //
);
if (!result)
{
break;
}
//
result = zone.IsBullish()
? iBar.close > zone.upper
: iBar.close < zone.lower;
if (result)
{
//
result = MathAbs(j - i) <= breakValidLength;
if (result)
{
break;
}
}
}
}
}
//
if (!result)
{
break;
}
}
}
}
//
// Cleanup Resource ...
iBar.Clean();
//
return result;
}
// //
// Protected ... // Protected ...
protected: protected:
@@ -869,7 +869,6 @@ void AnalyseMarket(int barIndex = 0)
// //
detectorConfig.analyseFIMAPVPivots = true; detectorConfig.analyseFIMAPVPivots = true;
detectorConfig.analyseFIMAMAPivots = false;
detectorConfig.analyseFIMASARPivots = false; detectorConfig.analyseFIMASARPivots = false;
detectorConfig.analyseFIMAZigZagPivots = true; detectorConfig.analyseFIMAZigZagPivots = true;
@@ -905,13 +904,6 @@ void AnalyseMarket(int barIndex = 0)
marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisTrends = true; marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisTrends = true;
marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisPivots = true; marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisPivots = true;
//
// XMA ...
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysis = false;
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisZones = false;
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisTrends = false;
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisPivots = false;
// //
// XSAR ... // XSAR ...
marketStructureDrawerConfig.drawFIMASARPivotsAnalysis = false; marketStructureDrawerConfig.drawFIMASARPivotsAnalysis = false;
+227 -146
View File
@@ -1260,8 +1260,8 @@ class XCXFIMAHelper : public XCBaseHelper
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ... * @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified Bar Index ... * @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ... * @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
* @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ... * @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ...
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
* *
* @return ( int ) * @return ( int )
*/ */
@@ -1269,8 +1269,8 @@ class XCXFIMAHelper : public XCBaseHelper
XPivot &pivots[], XPivot &pivots[],
int barIndex = 0, int barIndex = 0,
int requiredNumberOFPivots = 50, int requiredNumberOFPivots = 50,
int maxAllowedLoopbackLength = 1500, int validationLength = 0,
int validationLength = 0 // int maxAllowedLoopbackLength = 1500 //
) )
{ {
// //
@@ -1295,13 +1295,15 @@ class XCXFIMAHelper : public XCBaseHelper
} }
// //
XOHCL iBar; double fast[];
XOHCL pBar; double slow[];
XPivot iPivot; XPivot iPivot;
int count = 0;
double upper[];
double lower[];
bool has = false; bool has = false;
double tmpFastMaBuffer[];
double tmpSlowMaBuffer[];
int idx = barIndex - 1; int idx = barIndex - 1;
datetime iPivotTime = NULL;
string symbol = GetSymbol(); string symbol = GetSymbol();
double iFValue = EMPTY_VALUE; double iFValue = EMPTY_VALUE;
double pFValue = EMPTY_VALUE; double pFValue = EMPTY_VALUE;
@@ -1322,11 +1324,11 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Prepare ... // Prepare ...
iBar.Clean();
pBar.Clean();
iPivot.Clean(); iPivot.Clean();
SpecifiedClean(tmpFastMaBuffer); SpecifiedClean(fast);
SpecifiedClean(tmpSlowMaBuffer); SpecifiedClean(slow);
SpecifiedClean(upper);
SpecifiedClean(lower);
// //
// Ignore First Item ... // Ignore First Item ...
@@ -1335,56 +1337,28 @@ class XCXFIMAHelper : public XCBaseHelper
continue; continue;
} }
//
// Initialize Bar ...
has = iBar.Init(
symbol,
period,
idx //
);
has =
has &&
iBar.GetPreviousBar(pBar);
if (!has)
{
continue;
}
// //
// Reading Buffer ... // Reading Buffer ...
count = ReadMAValues(
// fast,
// FAST ... slow,
CopyBuffer( upper,
mHandler, // Handler ... lower,
XFIMA_MA_FAST_LINE, // Handler Buffer Number ... idx,
idx, // Bar Index ... 2 //
2, // Number of Requirements ...
tmpFastMaBuffer // Buffer ...
); );
ArraySetAsSeries(tmpFastMaBuffer, true); has = IsValidSize(count);
//
// SLOW ...
CopyBuffer(
mHandler, // Handler ...
XFIMA_MA_SLOW_LINE, // Handler Buffer Number ...
idx, // Bar Index ...
2, // Number of Requirements ...
tmpSlowMaBuffer // Buffer ...
);
ArraySetAsSeries(tmpSlowMaBuffer, true);
// //
// Reading Values ... // Reading Values ...
// //
iFValue = tmpFastMaBuffer[0]; iFValue = fast[0];
pFValue = tmpFastMaBuffer[1]; pFValue = fast[1];
// //
iSValue = tmpSlowMaBuffer[0]; iSValue = slow[0];
pSValue = tmpSlowMaBuffer[1]; pSValue = slow[1];
// //
// Validate Value ... // Validate Value ...
@@ -1432,81 +1406,19 @@ class XCXFIMAHelper : public XCBaseHelper
validationLength > 0) validationLength > 0)
{ {
// //
// Looping to Validate ... // Validate ...
double tmp[];
bool isValid = false;
int start = pBar.Index();
double iFast = EMPTY_VALUE;
double iSlow = EMPTY_VALUE;
int end = start + validationLength;
for (int i = start; i < end; i++)
{
//
// Initialize iBar ...
isValid = iBar.Init(
symbol,
period,
i //
);
if (!isValid)
{
break;
}
//
// Reading Fast and Slow Values ...
//
SpecifiedClean(tmp);
CopyBuffer(
mHandler, // Handler ...
XFIMA_MA_FAST_LINE, // Handler Buffer Number ...
i, // Bar Index ...
1, // Number of Requirements ...
tmp // Buffer ...
);
ArraySetAsSeries(tmp, true);
iFast = tmp[0];
//
SpecifiedClean(tmp);
CopyBuffer(
mHandler, // Handler ...
XFIMA_MA_SLOW_LINE, // Handler Buffer Number ...
i, // Bar Index ...
1, // Number of Requirements ...
tmp // Buffer ...
);
ArraySetAsSeries(tmp, true);
iSlow = tmp[0];
//
// Validate ...
isValid =
IsXPeak(iType)
? (iBar.low > MathMin(iFast, iSlow) ||
iBar.GetDown() > MathMin(iFast, iSlow))
: (iBar.high < MathMax(iFast, iSlow) ||
iBar.GetUp() < MathMax(iFast, iSlow));
if (!isValid)
{
break;
}
//
// Cleanup Resources ...
SpecifiedClean(tmp);
}
//
// Cleanup Resources ...
iBar.Clean();
SpecifiedClean(tmp);
} }
// //
if (has) if (has)
{ {
//
iPivotTime = GetBarTime(
symbol,
period,
idx //
);
// //
// Select Value based on Pivot Type ... // Select Value based on Pivot Type ...
iSelectedValue = IsXPeak(iType) iSelectedValue = IsXPeak(iType)
@@ -1517,7 +1429,7 @@ class XCXFIMAHelper : public XCBaseHelper
// Initialize and Validate Pivot ... // Initialize and Validate Pivot ...
has = iPivot.Init( has = iPivot.Init(
iSelectedValue, iSelectedValue,
iBar.time, iPivotTime,
symbol, symbol,
iDir, iDir,
period, period,
@@ -1542,11 +1454,11 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Cleanup Resources ... // Cleanup Resources ...
iBar.Clean();
pBar.Clean();
iPivot.Clean(); iPivot.Clean();
SpecifiedClean(tmpFastMaBuffer); SpecifiedClean(fast);
SpecifiedClean(tmpSlowMaBuffer); SpecifiedClean(slow);
SpecifiedClean(upper);
SpecifiedClean(lower);
// //
// Check Moving Forward Condition ... // Check Moving Forward Condition ...
@@ -1564,11 +1476,11 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Cleanup Resources ... // Cleanup Resources ...
iBar.Clean();
pBar.Clean();
iPivot.Clean(); iPivot.Clean();
SpecifiedClean(tmpFastMaBuffer); SpecifiedClean(fast);
SpecifiedClean(tmpSlowMaBuffer); SpecifiedClean(slow);
SpecifiedClean(upper);
SpecifiedClean(lower);
// //
return result; return result;
@@ -1972,6 +1884,8 @@ class XCXFIMAHelper : public XCBaseHelper
* @param zones: XBoxZone, collection reference to holds results ... * @param zones: XBoxZone, collection reference to holds results ...
* @param barIndex: int, Specified Bar Index ... * @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFZones: int, required Number of Zones ... * @param requiredNumberOFZones: int, required Number of Zones ...
* @param breakValidLength: int, Breake Validation Length of Zones ...
* @param validateFakeBreakes: bool, Validation Fake Breaked Zones ...
* @param shadowMultiplier: double a Shadow Multiplier for Validation ... * @param shadowMultiplier: double a Shadow Multiplier for Validation ...
* @param validationStrength: double, Minimum Strngth Multiplier in Point to Validate ... * @param validationStrength: double, Minimum Strngth Multiplier in Point to Validate ...
* @param validationLength: int, Validation Length of Zones ... * @param validationLength: int, Validation Length of Zones ...
@@ -1983,6 +1897,8 @@ class XCXFIMAHelper : public XCBaseHelper
XBoxZone &zones[], XBoxZone &zones[],
int barIndex = 0, int barIndex = 0,
int requiredNumberOFZones = 50, int requiredNumberOFZones = 50,
int breakValidLength = 3,
bool validateFakeBreakes = true,
double shadowMultiplier = 3, double shadowMultiplier = 3,
double validationStrength = 1, double validationStrength = 1,
int validationLength = 21, int validationLength = 21,
@@ -2022,6 +1938,8 @@ class XCXFIMAHelper : public XCBaseHelper
double hkHighs[]; double hkHighs[];
double hkCloses[]; double hkCloses[];
int start = barIndex; int start = barIndex;
bool isBullish = false;
bool isBearish = false;
double up = EMPTY_VALUE; double up = EMPTY_VALUE;
double down = EMPTY_VALUE; double down = EMPTY_VALUE;
double body = EMPTY_VALUE; double body = EMPTY_VALUE;
@@ -2060,6 +1978,7 @@ class XCXFIMAHelper : public XCBaseHelper
} }
// //
// Initialized Start Bar ...
if (i == start) if (i == start)
{ {
// //
@@ -2071,8 +1990,8 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Check Direction ... // Check Direction ...
bool isBullish = hkOpens[0] < hkCloses[0]; isBullish = hkOpens[0] < hkCloses[0];
bool isBearish = hkOpens[0] > hkCloses[0]; isBearish = hkOpens[0] > hkCloses[0];
dir = dir =
(isBullish && !isBearish) (isBullish && !isBearish)
? X_DIRECTION_BULLISH ? X_DIRECTION_BULLISH
@@ -2086,7 +2005,7 @@ class XCXFIMAHelper : public XCBaseHelper
} }
// //
// Check High Shadows and Low Shadows ... // Calculate Requirements for Processing ...
up = isBullish up = isBullish
? hkCloses[0] ? hkCloses[0]
: hkOpens[0]; : hkOpens[0];
@@ -2166,8 +2085,8 @@ class XCXFIMAHelper : public XCBaseHelper
(zone.IsBullish() (zone.IsBullish()
? startHKLow > zone.upper ? startHKLow > zone.upper
: startHKHigh < zone.lower) && : startHKHigh < zone.lower) &&
ValidateHKZone(zone, validationLength) && (zone.upper - zone.lower) >= minAllowedStrength &&
(zone.upper - zone.lower) >= minAllowedStrength; ValidateHKZone(zone, validationLength, breakValidLength, validateFakeBreakes);
if (has) if (has)
{ {
// //
@@ -2185,7 +2104,7 @@ class XCXFIMAHelper : public XCBaseHelper
// Validating ... // Validating ...
result = ArraySize(zones); result = ArraySize(zones);
has = IsValidSize(result) && has = IsValidSize(result) &&
count >= requiredNumberOFZones; result >= requiredNumberOFZones;
if (has) if (has)
{ {
break; break;
@@ -4212,11 +4131,25 @@ class XCXFIMAHelper : public XCBaseHelper
// //
int result = 0; int result = 0;
//
// Prepare ...
SpecifiedClean(low);
SpecifiedClean(open);
SpecifiedClean(high);
SpecifiedClean(close);
// //
// Normalize ... // Normalize ...
count = NormalizeInt(count, 1); count = NormalizeInt(count, 1);
barIndex = NormalizeInt(barIndex, 0); barIndex = NormalizeInt(barIndex, 0);
//
// Validate ...
if (mHandler == INVALID_HANDLE)
{
return result;
}
// //
// Open ... // Open ...
CopyBuffer( CopyBuffer(
@@ -4257,6 +4190,12 @@ class XCXFIMAHelper : public XCBaseHelper
close // close //
); );
//
ArraySetAsSeries(low, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(close, true);
// //
// Min Number of Array Sizes ... // Min Number of Array Sizes ...
result = MathMin(ArraySize(open), ArraySize(high)); result = MathMin(ArraySize(open), ArraySize(high));
@@ -4267,10 +4206,21 @@ class XCXFIMAHelper : public XCBaseHelper
return result; return result;
} }
// /**
* Validate HK Zone ...
*
* @param zone: XBoxZone, reference to Specified Zone ...
* @param validationLength: int, Validation Length of Zones ...
* @param breakValidLength: int, Break Validation Length of Zones ...
* @param validateFakeBreakes: bool, Validation Fake Breaked Zones ...
*
* @return ( bool )
*/
bool ValidateHKZone( bool ValidateHKZone(
XBoxZone &zone, XBoxZone &zone,
int validationLength = 1 // int validationLength = 1,
int breakValidLength = 3,
bool validateFakeBreakes = true //
) )
{ {
// //
@@ -4279,6 +4229,7 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Normalize ... // Normalize ...
validationLength = NormalizeInt(validationLength, 1); validationLength = NormalizeInt(validationLength, 1);
breakValidLength = NormalizeInt(breakValidLength, 2);
// //
// Validate ... // Validate ...
@@ -4289,6 +4240,7 @@ class XCXFIMAHelper : public XCBaseHelper
} }
// //
// Requirements ...
double low[]; double low[];
double open[]; double open[];
double high[]; double high[];
@@ -4296,9 +4248,11 @@ class XCXFIMAHelper : public XCBaseHelper
double close[]; double close[];
// //
// Validating Before ...
int start = zone.FromIndex() + 1; int start = zone.FromIndex() + 1;
int end = start + validationLength; int end = start + validationLength;
//
// Validate Before ...
for (int i = start; i < end; i++) for (int i = start; i < end; i++)
{ {
// //
@@ -4311,8 +4265,6 @@ class XCXFIMAHelper : public XCBaseHelper
i, i,
1 // 1 //
); );
//
result = IsValidSize(count); result = IsValidSize(count);
if (!result) if (!result)
{ {
@@ -4321,8 +4273,8 @@ class XCXFIMAHelper : public XCBaseHelper
// //
result = zone.IsBullish() result = zone.IsBullish()
? low[0] > zone.upper ? low[0] > zone.lower
: high[0] < zone.lower; : high[0] < zone.upper;
if (!result) if (!result)
{ {
break; break;
@@ -4349,8 +4301,6 @@ class XCXFIMAHelper : public XCBaseHelper
i, i,
1 // 1 //
); );
//
result = IsValidSize(count); result = IsValidSize(count);
if (!result) if (!result)
{ {
@@ -4363,7 +4313,55 @@ class XCXFIMAHelper : public XCBaseHelper
: high[0] < zone.upper; : high[0] < zone.upper;
if (!result) if (!result)
{ {
break; //
// Check For Fake Breake ...
if (validateFakeBreakes && breakValidLength > 0)
{
//
result = i - 1 >= 0;
if (result)
{
//
for (int j = i - 1; j >= zone.ToIndex(); j--)
{
//
// Reading HK ...
count = ReadHKBars(
open,
high,
low,
close,
j,
1 //
);
result = IsValidSize(count);
if (!result)
{
break;
}
//
result = zone.IsBullish()
? close[0] > zone.upper
: close[0] < zone.lower;
if (result)
{
//
result = MathAbs(j - i) <= breakValidLength;
if (result)
{
break;
}
}
}
}
}
//
if (!result)
{
break;
}
} }
} }
} }
@@ -4379,6 +4377,89 @@ class XCXFIMAHelper : public XCBaseHelper
return result; return result;
} }
//
int ReadMAValues(
double &fast[],
double &slow[],
double &upper[],
double &lower[],
int barIndex = 0,
int count = 0 //
)
{
//
int result = 0;
//
// Prepare ...
SpecifiedClean(fast);
SpecifiedClean(slow);
SpecifiedClean(upper);
SpecifiedClean(lower);
//
// Normalize ...
count = NormalizeInt(count, 1);
barIndex = NormalizeInt(barIndex, 0);
//
// Validate ...
if (mHandler == INVALID_HANDLE)
{
return result;
}
//
CopyBuffer(
mHandler,
XFIMA_MA_FAST_LINE,
barIndex,
count,
fast //
);
//
CopyBuffer(
mHandler,
XFIMA_MA_SLOW_LINE,
barIndex,
count,
slow //
);
//
CopyBuffer(
mHandler,
XFIMA_MA_BAND_UPPER_LINE,
barIndex,
count,
upper //
);
//
CopyBuffer(
mHandler,
XFIMA_MA_BAND_LOWER_LINE,
barIndex,
count,
lower //
);
//
ArraySetAsSeries(fast, true);
ArraySetAsSeries(slow, true);
ArraySetAsSeries(upper, true);
ArraySetAsSeries(lower, true);
//
result = MathMin(ArraySize(fast), ArraySize(slow));
result = MathMin(result, ArraySize(upper));
result = MathMin(result, ArraySize(lower));
//
return result;
}
// //
}; };
@@ -1163,6 +1163,42 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Calling Without Candlestick Patterns Strategies ... // Calling Without Candlestick Patterns Strategies ...
//
// Testing Bar Zones ...
XBoxZone barZones[];
int barCounts = fima2Signaller.fimaHelper.ExtractBarZones(
barZones,
1, // Bar Index ...
50, // Number of Zones ...
3, // Break Validation Length ...
true, // Validate Fake Breakes ...
5, // Shadow Multiplier ...
1, // Strength ...
14 // Validation Length ...
);
if (IsValidSize(barCounts))
{
//
XCBoxObject *iObj;
for (int i = 0; i < barCounts; i++)
{
//
iObj = NULL;
bool isCreated = fima2Signaller.poiDrawer.DrawBox(
barZones[i],
iObj,
true, // Ignore At ...
barZones[i].type // Name ...
);
//
ZeroMemory(iObj);
}
// //
// Print("Bar Zones Detected ...");
}
// //
// Testing HK Zones ... // Testing HK Zones ...
XBoxZone hkZones[]; XBoxZone hkZones[];
@@ -1172,29 +1208,51 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
50, // Number of Zones ... 50, // Number of Zones ...
5, // Shadow Multiplier ... 5, // Shadow Multiplier ...
1, // Strength ... 1, // Strength ...
21 // Validation Length ... 14 // Validation Length ...
); );
if (IsValidSize(hkCounts)) if (IsValidSize(hkCounts))
{ {
// // //
XCBoxObject *iObj; // XCBoxObject *iObj;
for (int i = 0; i < hkCounts; i++) // for (int i = 0; i < hkCounts; i++)
{ // {
// // //
iObj = NULL; // iObj = NULL;
bool isCreated = fima2Signaller.poiDrawer.DrawBox( // bool isCreated = fima2Signaller.poiDrawer.DrawBox(
hkZones[i], // hkZones[i],
iObj, // iObj,
true, // Ignore At ... // true, // Ignore At ...
hkZones[i].type // Name ... // hkZones[i].type // Name ...
); // );
// // //
ZeroMemory(iObj); // ZeroMemory(iObj);
} // }
// //
// Print("HK Zones Detected ...");
}
//
// Testing XFIMA MA Pivots ...
XPivot maPivots[];
int maPivotsCount = fimaHelper.ExtractMAPivots(
maPivots,
1, // Bar Index ...
50, // Number of Pivots ...
0 // Validation Length ...
);
if (IsValidSize(maPivotsCount))
{
//
CArrayObj *iPivotsObj;
maPivotsCount = poiDrawer.DrawPivots(
maPivots,
iPivotsObj //
);
// //
Print("HK Zones Detected ..."); Print("MA Pivots Detected ...");
} }
// //
@@ -1312,7 +1370,7 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Do all Draws Here ... // Do all Draws Here ...
bool canDraw = true; bool canDraw = false;
if (canDraw && has) if (canDraw && has)
{ {
// //
@@ -938,25 +938,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
} }
} }
//
// Analyse Based on MA ...
if (config.analyseFIMAMAPivots)
{
//
XPivotAnalysis analysis;
has = AnalyseMAPivots(
analysis, // Result ...
forBar.Index(), // Bar Index ...
config.numberOfRequiredPivotsForAnalysis, // Required Number of Pivots ...
config.maxAllowedLoopbackLengthForAnalysis, // Max Allowed Loopback ...
config.pvPivotsValidationLength // Validation Length ...
);
if (has)
{
structure.maAnalysis = analysis;
}
}
// //
// Analyse Based on SAR ... // Analyse Based on SAR ...
if (config.analyseFIMASARPivots) if (config.analyseFIMASARPivots)
@@ -1246,33 +1246,6 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer
} }
} }
//
// XFIMA MA Analysis ...
if (config.drawFIMAMAPivotsAnalysis)
{
//
// Validate ...
has = structure.maAnalysis.IsValid();
if (has)
{
//
XCPivotAnalysisObject *iObj;
has = DrawPivotAnalysis(
structure.pvAnalysis,
iObj,
config.drawFIMAMAPivotsAnalysisTrends,
config.drawFIMAMAPivotsAnalysisZones,
config.drawFIMAMAPivotsAnalysisPivots,
bearArrowCode,
bullArrowCode //
);
if (has)
{
objects.Add(iObj);
}
}
}
// //
// XFIMA Sar Analysis ... // XFIMA Sar Analysis ...
if (config.drawFIMASARPivotsAnalysis) if (config.drawFIMASARPivotsAnalysis)
@@ -66,7 +66,6 @@ struct XFIMAPatternDetectorConfig
// //
bool analyseFIMAPVPivots; bool analyseFIMAPVPivots;
bool analyseFIMAMAPivots;
bool analyseFIMASARPivots; bool analyseFIMASARPivots;
bool analyseFIMAZigZagPivots; bool analyseFIMAZigZagPivots;
@@ -123,7 +122,6 @@ struct XFIMAPatternDetectorConfig
// //
// Analyser ... // Analyser ...
int pvPivotsValidationLength; int pvPivotsValidationLength;
int maPivotsValidationLength;
int numberOfRequiredPivotsForAnalysis; int numberOfRequiredPivotsForAnalysis;
int maxAllowedLoopbackLengthForAnalysis; int maxAllowedLoopbackLengthForAnalysis;
@@ -158,7 +156,6 @@ struct XFIMAPatternDetectorConfig
detectEngulfed = false; detectEngulfed = false;
detectTrueGaped = false; detectTrueGaped = false;
analyseFIMAPVPivots = false; analyseFIMAPVPivots = false;
analyseFIMAMAPivots = false;
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
@@ -185,7 +182,6 @@ struct XFIMAPatternDetectorConfig
signalKeyBarMinimumPinBarRangeMultiplier = 0; signalKeyBarMinimumPinBarRangeMultiplier = 0;
signalKeyBarForceDirection = false; signalKeyBarForceDirection = false;
pvPivotsValidationLength = 0; pvPivotsValidationLength = 0;
maPivotsValidationLength = 0;
numberOfRequiredPivotsForAnalysis = 0; numberOfRequiredPivotsForAnalysis = 0;
maxAllowedLoopbackLengthForAnalysis = 0; maxAllowedLoopbackLengthForAnalysis = 0;
@@ -227,7 +223,6 @@ struct XFIMAPatternDetectorConfig
// //
// Analysers ... // Analysers ...
analyseFIMAPVPivots = false; analyseFIMAPVPivots = false;
analyseFIMAMAPivots = false;
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
@@ -279,7 +274,6 @@ struct XFIMAPatternDetectorConfig
// //
// Length ... // Length ...
pvPivotsValidationLength = 10; pvPivotsValidationLength = 10;
maPivotsValidationLength = 0;
numberOfRequiredPivotsForAnalysis = 50; numberOfRequiredPivotsForAnalysis = 50;
maxAllowedLoopbackLengthForAnalysis = 1500; maxAllowedLoopbackLengthForAnalysis = 1500;
} }
@@ -318,7 +312,6 @@ struct XFIMAPatternDetectorConfig
// //
// Analysers ... // Analysers ...
analyseFIMAPVPivots = true; analyseFIMAPVPivots = true;
analyseFIMAMAPivots = true;
analyseFIMASARPivots = true; analyseFIMASARPivots = true;
analyseFIMAZigZagPivots = true; analyseFIMAZigZagPivots = true;
} }
@@ -357,7 +350,6 @@ struct XFIMAPatternDetectorConfig
// //
// Analysers ... // Analysers ...
analyseFIMAPVPivots = false; analyseFIMAPVPivots = false;
analyseFIMAMAPivots = false;
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
} }
@@ -413,7 +405,6 @@ struct XFIMAMarketStructure
// //
// Analysis ... // Analysis ...
XPivotAnalysis pvAnalysis; XPivotAnalysis pvAnalysis;
XPivotAnalysis maAnalysis;
XPivotAnalysis sarAnalysis; XPivotAnalysis sarAnalysis;
XPivotAnalysis zigzagAnalysis; XPivotAnalysis zigzagAnalysis;
@@ -467,7 +458,6 @@ struct XFIMAMarketStructure
// //
pvAnalysis.Clean(); pvAnalysis.Clean();
maAnalysis.Clean();
sarAnalysis.Clean(); sarAnalysis.Clean();
zigzagAnalysis.Clean(); zigzagAnalysis.Clean();
@@ -567,13 +557,6 @@ struct XFIMAMarketStructureDrawerConfig
bool drawFIMAPVPivotsAnalysisTrends; bool drawFIMAPVPivotsAnalysisTrends;
bool drawFIMAPVPivotsAnalysisPivots; bool drawFIMAPVPivotsAnalysisPivots;
//
// XMA ...
bool drawFIMAMAPivotsAnalysis;
bool drawFIMAMAPivotsAnalysisZones;
bool drawFIMAMAPivotsAnalysisTrends;
bool drawFIMAMAPivotsAnalysisPivots;
// //
// XSAR ... // XSAR ...
bool drawFIMASARPivotsAnalysis; bool drawFIMASARPivotsAnalysis;
@@ -633,12 +616,6 @@ struct XFIMAMarketStructureDrawerConfig
drawFIMAPVPivotsAnalysisTrends = false; drawFIMAPVPivotsAnalysisTrends = false;
drawFIMAPVPivotsAnalysisPivots = false; drawFIMAPVPivotsAnalysisPivots = false;
//
drawFIMAMAPivotsAnalysis = false;
drawFIMAMAPivotsAnalysisZones = false;
drawFIMAMAPivotsAnalysisTrends = false;
drawFIMAMAPivotsAnalysisPivots = false;
// //
drawFIMASARPivotsAnalysis = false; drawFIMASARPivotsAnalysis = false;
drawFIMASARPivotsAnalysisZones = false; drawFIMASARPivotsAnalysisZones = false;
@@ -689,12 +666,6 @@ struct XFIMAMarketStructureDrawerConfig
drawFIMAPVPivotsAnalysisTrends = true; drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true; drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMAMAPivotsAnalysis = true;
drawFIMAMAPivotsAnalysisZones = true;
drawFIMAMAPivotsAnalysisTrends = true;
drawFIMAMAPivotsAnalysisPivots = true;
// //
drawFIMASARPivotsAnalysis = true; drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true; drawFIMASARPivotsAnalysisZones = true;
@@ -746,12 +717,6 @@ struct XFIMAMarketStructureDrawerConfig
drawFIMAPVPivotsAnalysisTrends = true; drawFIMAPVPivotsAnalysisTrends = true;
drawFIMAPVPivotsAnalysisPivots = true; drawFIMAPVPivotsAnalysisPivots = true;
//
drawFIMAMAPivotsAnalysis = true;
drawFIMAMAPivotsAnalysisZones = true;
drawFIMAMAPivotsAnalysisTrends = true;
drawFIMAMAPivotsAnalysisPivots = true;
// //
drawFIMASARPivotsAnalysis = true; drawFIMASARPivotsAnalysis = true;
drawFIMASARPivotsAnalysisZones = true; drawFIMASARPivotsAnalysisZones = true;