last ...
This commit is contained in:
@@ -96,7 +96,9 @@ class XCBaseHelper : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
virtual void Free() {}
|
||||
virtual void Free()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Tag ...
|
||||
@@ -123,6 +125,374 @@ class XCBaseHelper : public XCBase
|
||||
//
|
||||
// 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:
|
||||
|
||||
@@ -869,7 +869,6 @@ void AnalyseMarket(int barIndex = 0)
|
||||
|
||||
//
|
||||
detectorConfig.analyseFIMAPVPivots = true;
|
||||
detectorConfig.analyseFIMAMAPivots = false;
|
||||
detectorConfig.analyseFIMASARPivots = false;
|
||||
detectorConfig.analyseFIMAZigZagPivots = true;
|
||||
|
||||
@@ -905,13 +904,6 @@ void AnalyseMarket(int barIndex = 0)
|
||||
marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisTrends = true;
|
||||
marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisPivots = true;
|
||||
|
||||
//
|
||||
// XMA ...
|
||||
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysis = false;
|
||||
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisZones = false;
|
||||
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisTrends = false;
|
||||
marketStructureDrawerConfig.drawFIMAMAPivotsAnalysisPivots = false;
|
||||
|
||||
//
|
||||
// XSAR ...
|
||||
marketStructureDrawerConfig.drawFIMASARPivotsAnalysis = false;
|
||||
|
||||
+227
-146
@@ -1260,8 +1260,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @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 maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
@@ -1269,8 +1269,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
XPivot &pivots[],
|
||||
int barIndex = 0,
|
||||
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;
|
||||
XOHCL pBar;
|
||||
double fast[];
|
||||
double slow[];
|
||||
XPivot iPivot;
|
||||
int count = 0;
|
||||
double upper[];
|
||||
double lower[];
|
||||
bool has = false;
|
||||
double tmpFastMaBuffer[];
|
||||
double tmpSlowMaBuffer[];
|
||||
int idx = barIndex - 1;
|
||||
datetime iPivotTime = NULL;
|
||||
string symbol = GetSymbol();
|
||||
double iFValue = EMPTY_VALUE;
|
||||
double pFValue = EMPTY_VALUE;
|
||||
@@ -1322,11 +1324,11 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
iBar.Clean();
|
||||
pBar.Clean();
|
||||
iPivot.Clean();
|
||||
SpecifiedClean(tmpFastMaBuffer);
|
||||
SpecifiedClean(tmpSlowMaBuffer);
|
||||
SpecifiedClean(fast);
|
||||
SpecifiedClean(slow);
|
||||
SpecifiedClean(upper);
|
||||
SpecifiedClean(lower);
|
||||
|
||||
//
|
||||
// Ignore First Item ...
|
||||
@@ -1335,56 +1337,28 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Bar ...
|
||||
has = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
idx //
|
||||
);
|
||||
has =
|
||||
has &&
|
||||
iBar.GetPreviousBar(pBar);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Buffer ...
|
||||
|
||||
//
|
||||
// FAST ...
|
||||
CopyBuffer(
|
||||
mHandler, // Handler ...
|
||||
XFIMA_MA_FAST_LINE, // Handler Buffer Number ...
|
||||
idx, // Bar Index ...
|
||||
2, // Number of Requirements ...
|
||||
tmpFastMaBuffer // Buffer ...
|
||||
count = ReadMAValues(
|
||||
fast,
|
||||
slow,
|
||||
upper,
|
||||
lower,
|
||||
idx,
|
||||
2 //
|
||||
);
|
||||
ArraySetAsSeries(tmpFastMaBuffer, true);
|
||||
|
||||
//
|
||||
// SLOW ...
|
||||
CopyBuffer(
|
||||
mHandler, // Handler ...
|
||||
XFIMA_MA_SLOW_LINE, // Handler Buffer Number ...
|
||||
idx, // Bar Index ...
|
||||
2, // Number of Requirements ...
|
||||
tmpSlowMaBuffer // Buffer ...
|
||||
);
|
||||
ArraySetAsSeries(tmpSlowMaBuffer, true);
|
||||
has = IsValidSize(count);
|
||||
|
||||
//
|
||||
// Reading Values ...
|
||||
|
||||
//
|
||||
iFValue = tmpFastMaBuffer[0];
|
||||
pFValue = tmpFastMaBuffer[1];
|
||||
iFValue = fast[0];
|
||||
pFValue = fast[1];
|
||||
|
||||
//
|
||||
iSValue = tmpSlowMaBuffer[0];
|
||||
pSValue = tmpSlowMaBuffer[1];
|
||||
iSValue = slow[0];
|
||||
pSValue = slow[1];
|
||||
|
||||
//
|
||||
// Validate Value ...
|
||||
@@ -1432,81 +1406,19 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
validationLength > 0)
|
||||
{
|
||||
//
|
||||
// Looping to 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);
|
||||
// Validate ...
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iPivotTime = GetBarTime(
|
||||
symbol,
|
||||
period,
|
||||
idx //
|
||||
);
|
||||
|
||||
//
|
||||
// Select Value based on Pivot Type ...
|
||||
iSelectedValue = IsXPeak(iType)
|
||||
@@ -1517,7 +1429,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
// Initialize and Validate Pivot ...
|
||||
has = iPivot.Init(
|
||||
iSelectedValue,
|
||||
iBar.time,
|
||||
iPivotTime,
|
||||
symbol,
|
||||
iDir,
|
||||
period,
|
||||
@@ -1542,11 +1454,11 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
pBar.Clean();
|
||||
iPivot.Clean();
|
||||
SpecifiedClean(tmpFastMaBuffer);
|
||||
SpecifiedClean(tmpSlowMaBuffer);
|
||||
SpecifiedClean(fast);
|
||||
SpecifiedClean(slow);
|
||||
SpecifiedClean(upper);
|
||||
SpecifiedClean(lower);
|
||||
|
||||
//
|
||||
// Check Moving Forward Condition ...
|
||||
@@ -1564,11 +1476,11 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
pBar.Clean();
|
||||
iPivot.Clean();
|
||||
SpecifiedClean(tmpFastMaBuffer);
|
||||
SpecifiedClean(tmpSlowMaBuffer);
|
||||
SpecifiedClean(fast);
|
||||
SpecifiedClean(slow);
|
||||
SpecifiedClean(upper);
|
||||
SpecifiedClean(lower);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1972,6 +1884,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
* @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 ...
|
||||
@@ -1983,6 +1897,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
XBoxZone &zones[],
|
||||
int barIndex = 0,
|
||||
int requiredNumberOFZones = 50,
|
||||
int breakValidLength = 3,
|
||||
bool validateFakeBreakes = true,
|
||||
double shadowMultiplier = 3,
|
||||
double validationStrength = 1,
|
||||
int validationLength = 21,
|
||||
@@ -2022,6 +1938,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
double hkHighs[];
|
||||
double hkCloses[];
|
||||
int start = barIndex;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
double up = EMPTY_VALUE;
|
||||
double down = EMPTY_VALUE;
|
||||
double body = EMPTY_VALUE;
|
||||
@@ -2060,6 +1978,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
}
|
||||
|
||||
//
|
||||
// Initialized Start Bar ...
|
||||
if (i == start)
|
||||
{
|
||||
//
|
||||
@@ -2071,8 +1990,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
// Check Direction ...
|
||||
bool isBullish = hkOpens[0] < hkCloses[0];
|
||||
bool isBearish = hkOpens[0] > hkCloses[0];
|
||||
isBullish = hkOpens[0] < hkCloses[0];
|
||||
isBearish = hkOpens[0] > hkCloses[0];
|
||||
dir =
|
||||
(isBullish && !isBearish)
|
||||
? X_DIRECTION_BULLISH
|
||||
@@ -2086,7 +2005,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
}
|
||||
|
||||
//
|
||||
// Check High Shadows and Low Shadows ...
|
||||
// Calculate Requirements for Processing ...
|
||||
up = isBullish
|
||||
? hkCloses[0]
|
||||
: hkOpens[0];
|
||||
@@ -2166,8 +2085,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
(zone.IsBullish()
|
||||
? startHKLow > zone.upper
|
||||
: startHKHigh < zone.lower) &&
|
||||
ValidateHKZone(zone, validationLength) &&
|
||||
(zone.upper - zone.lower) >= minAllowedStrength;
|
||||
(zone.upper - zone.lower) >= minAllowedStrength &&
|
||||
ValidateHKZone(zone, validationLength, breakValidLength, validateFakeBreakes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
@@ -2185,7 +2104,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
// Validating ...
|
||||
result = ArraySize(zones);
|
||||
has = IsValidSize(result) &&
|
||||
count >= requiredNumberOFZones;
|
||||
result >= requiredNumberOFZones;
|
||||
if (has)
|
||||
{
|
||||
break;
|
||||
@@ -4212,11 +4131,25 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
SpecifiedClean(low);
|
||||
SpecifiedClean(open);
|
||||
SpecifiedClean(high);
|
||||
SpecifiedClean(close);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
count = NormalizeInt(count, 1);
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
if (mHandler == INVALID_HANDLE)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Open ...
|
||||
CopyBuffer(
|
||||
@@ -4257,6 +4190,12 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
close //
|
||||
);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
|
||||
//
|
||||
// Min Number of Array Sizes ...
|
||||
result = MathMin(ArraySize(open), ArraySize(high));
|
||||
@@ -4267,10 +4206,21 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
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(
|
||||
XBoxZone &zone,
|
||||
int validationLength = 1 //
|
||||
int validationLength = 1,
|
||||
int breakValidLength = 3,
|
||||
bool validateFakeBreakes = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -4279,6 +4229,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 1);
|
||||
breakValidLength = NormalizeInt(breakValidLength, 2);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
@@ -4289,6 +4240,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
}
|
||||
|
||||
//
|
||||
// Requirements ...
|
||||
double low[];
|
||||
double open[];
|
||||
double high[];
|
||||
@@ -4296,9 +4248,11 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
double close[];
|
||||
|
||||
//
|
||||
// Validating Before ...
|
||||
int start = zone.FromIndex() + 1;
|
||||
int end = start + validationLength;
|
||||
|
||||
//
|
||||
// Validate Before ...
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
@@ -4311,8 +4265,6 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
@@ -4321,8 +4273,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
result = zone.IsBullish()
|
||||
? low[0] > zone.upper
|
||||
: high[0] < zone.lower;
|
||||
? low[0] > zone.lower
|
||||
: high[0] < zone.upper;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
@@ -4349,8 +4301,6 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
@@ -4363,7 +4313,55 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
: high[0] < zone.upper;
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
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 ...
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
XBoxZone hkZones[];
|
||||
@@ -1172,29 +1208,51 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
|
||||
50, // Number of Zones ...
|
||||
5, // Shadow Multiplier ...
|
||||
1, // Strength ...
|
||||
21 // Validation Length ...
|
||||
14 // Validation Length ...
|
||||
);
|
||||
if (IsValidSize(hkCounts))
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
for (int i = 0; i < hkCounts; i++)
|
||||
{
|
||||
//
|
||||
iObj = NULL;
|
||||
bool isCreated = fima2Signaller.poiDrawer.DrawBox(
|
||||
hkZones[i],
|
||||
iObj,
|
||||
true, // Ignore At ...
|
||||
hkZones[i].type // Name ...
|
||||
);
|
||||
// //
|
||||
// XCBoxObject *iObj;
|
||||
// for (int i = 0; i < hkCounts; i++)
|
||||
// {
|
||||
// //
|
||||
// iObj = NULL;
|
||||
// bool isCreated = fima2Signaller.poiDrawer.DrawBox(
|
||||
// hkZones[i],
|
||||
// iObj,
|
||||
// true, // Ignore At ...
|
||||
// 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 ...
|
||||
bool canDraw = true;
|
||||
bool canDraw = false;
|
||||
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 ...
|
||||
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 ...
|
||||
if (config.drawFIMASARPivotsAnalysis)
|
||||
|
||||
@@ -66,7 +66,6 @@ struct XFIMAPatternDetectorConfig
|
||||
|
||||
//
|
||||
bool analyseFIMAPVPivots;
|
||||
bool analyseFIMAMAPivots;
|
||||
bool analyseFIMASARPivots;
|
||||
bool analyseFIMAZigZagPivots;
|
||||
|
||||
@@ -123,7 +122,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analyser ...
|
||||
int pvPivotsValidationLength;
|
||||
int maPivotsValidationLength;
|
||||
int numberOfRequiredPivotsForAnalysis;
|
||||
int maxAllowedLoopbackLengthForAnalysis;
|
||||
|
||||
@@ -158,7 +156,6 @@ struct XFIMAPatternDetectorConfig
|
||||
detectEngulfed = false;
|
||||
detectTrueGaped = false;
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMAMAPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
@@ -185,7 +182,6 @@ struct XFIMAPatternDetectorConfig
|
||||
signalKeyBarMinimumPinBarRangeMultiplier = 0;
|
||||
signalKeyBarForceDirection = false;
|
||||
pvPivotsValidationLength = 0;
|
||||
maPivotsValidationLength = 0;
|
||||
numberOfRequiredPivotsForAnalysis = 0;
|
||||
maxAllowedLoopbackLengthForAnalysis = 0;
|
||||
|
||||
@@ -227,7 +223,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMAMAPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
|
||||
@@ -279,7 +274,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Length ...
|
||||
pvPivotsValidationLength = 10;
|
||||
maPivotsValidationLength = 0;
|
||||
numberOfRequiredPivotsForAnalysis = 50;
|
||||
maxAllowedLoopbackLengthForAnalysis = 1500;
|
||||
}
|
||||
@@ -318,7 +312,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = true;
|
||||
analyseFIMAMAPivots = true;
|
||||
analyseFIMASARPivots = true;
|
||||
analyseFIMAZigZagPivots = true;
|
||||
}
|
||||
@@ -357,7 +350,6 @@ struct XFIMAPatternDetectorConfig
|
||||
//
|
||||
// Analysers ...
|
||||
analyseFIMAPVPivots = false;
|
||||
analyseFIMAMAPivots = false;
|
||||
analyseFIMASARPivots = false;
|
||||
analyseFIMAZigZagPivots = false;
|
||||
}
|
||||
@@ -413,7 +405,6 @@ struct XFIMAMarketStructure
|
||||
//
|
||||
// Analysis ...
|
||||
XPivotAnalysis pvAnalysis;
|
||||
XPivotAnalysis maAnalysis;
|
||||
XPivotAnalysis sarAnalysis;
|
||||
XPivotAnalysis zigzagAnalysis;
|
||||
|
||||
@@ -467,7 +458,6 @@ struct XFIMAMarketStructure
|
||||
|
||||
//
|
||||
pvAnalysis.Clean();
|
||||
maAnalysis.Clean();
|
||||
sarAnalysis.Clean();
|
||||
zigzagAnalysis.Clean();
|
||||
|
||||
@@ -567,13 +557,6 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
bool drawFIMAPVPivotsAnalysisTrends;
|
||||
bool drawFIMAPVPivotsAnalysisPivots;
|
||||
|
||||
//
|
||||
// XMA ...
|
||||
bool drawFIMAMAPivotsAnalysis;
|
||||
bool drawFIMAMAPivotsAnalysisZones;
|
||||
bool drawFIMAMAPivotsAnalysisTrends;
|
||||
bool drawFIMAMAPivotsAnalysisPivots;
|
||||
|
||||
//
|
||||
// XSAR ...
|
||||
bool drawFIMASARPivotsAnalysis;
|
||||
@@ -633,12 +616,6 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
drawFIMAPVPivotsAnalysisTrends = false;
|
||||
drawFIMAPVPivotsAnalysisPivots = false;
|
||||
|
||||
//
|
||||
drawFIMAMAPivotsAnalysis = false;
|
||||
drawFIMAMAPivotsAnalysisZones = false;
|
||||
drawFIMAMAPivotsAnalysisTrends = false;
|
||||
drawFIMAMAPivotsAnalysisPivots = false;
|
||||
|
||||
//
|
||||
drawFIMASARPivotsAnalysis = false;
|
||||
drawFIMASARPivotsAnalysisZones = false;
|
||||
@@ -689,12 +666,6 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
drawFIMAPVPivotsAnalysisTrends = true;
|
||||
drawFIMAPVPivotsAnalysisPivots = true;
|
||||
|
||||
//
|
||||
drawFIMAMAPivotsAnalysis = true;
|
||||
drawFIMAMAPivotsAnalysisZones = true;
|
||||
drawFIMAMAPivotsAnalysisTrends = true;
|
||||
drawFIMAMAPivotsAnalysisPivots = true;
|
||||
|
||||
//
|
||||
drawFIMASARPivotsAnalysis = true;
|
||||
drawFIMASARPivotsAnalysisZones = true;
|
||||
@@ -746,12 +717,6 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
drawFIMAPVPivotsAnalysisTrends = true;
|
||||
drawFIMAPVPivotsAnalysisPivots = true;
|
||||
|
||||
//
|
||||
drawFIMAMAPivotsAnalysis = true;
|
||||
drawFIMAMAPivotsAnalysisZones = true;
|
||||
drawFIMAMAPivotsAnalysisTrends = true;
|
||||
drawFIMAMAPivotsAnalysisPivots = true;
|
||||
|
||||
//
|
||||
drawFIMASARPivotsAnalysis = true;
|
||||
drawFIMASARPivotsAnalysisZones = true;
|
||||
|
||||
Reference in New Issue
Block a user