last ...
This commit is contained in:
@@ -438,7 +438,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -448,8 +447,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsPinnedBar(bar, dir) &&
|
||||
IsXBullish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -477,7 +478,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -487,8 +487,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsPinnedBar(bar, dir) &&
|
||||
IsXBearish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -550,7 +552,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -560,8 +561,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsMomentumBar(bar, dir) &&
|
||||
IsXBullish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -588,7 +591,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -598,8 +600,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsMomentumBar(bar, dir) &&
|
||||
IsXBearish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -1208,6 +1212,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
int loopback = 50,
|
||||
bool forceValidation = true,
|
||||
int validationLength = 7,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
string forSymbol = NULL,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
@@ -1284,6 +1291,8 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
tmpValue = tmpBar.FindLowest(validationLength, MODE_LOW);
|
||||
has = NotEmptyZero(tmpValue) &&
|
||||
tmpValue == tmpBar.low;
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
@@ -1325,7 +1334,14 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
// Validate ...
|
||||
if (HasChild(zones) && forceValidation)
|
||||
{
|
||||
ValidateZones(zones, barIndex);
|
||||
//
|
||||
ValidateZones(
|
||||
zones,
|
||||
barIndex,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1341,6 +1357,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
int loopback = 50,
|
||||
bool forceValidation = true,
|
||||
int validationLength = 7,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
string forSymbol = NULL,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
@@ -1458,7 +1477,14 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
// Validate ...
|
||||
if (HasChild(zones) && forceValidation)
|
||||
{
|
||||
ValidateZones(zones, barIndex);
|
||||
//
|
||||
ValidateZones(
|
||||
zones,
|
||||
barIndex,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1471,6 +1497,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
void ValidateZones(
|
||||
XBoxZone &zones[],
|
||||
int barIndex = 0,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
ENUM_X_BOUNDARY_PRICE forPriceType = X_BOUNDARY_PRICE_UP_DOWN //
|
||||
)
|
||||
{
|
||||
@@ -1478,9 +1507,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
barIndex = kiParser.NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validation ...
|
||||
has = HasChild(zones) &&
|
||||
IsXValid(forPriceType);
|
||||
if (!has)
|
||||
@@ -1488,6 +1515,13 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalizetion ...
|
||||
barIndex = kiParser.NormalizeBarIndex(barIndex);
|
||||
minimumRetests = NormalizeInt(minimumRetests, 0);
|
||||
retestLoopback = NormalizeInt(retestLoopback, 50);
|
||||
retestThreshold = NormalizeDouble(retestThreshold, 5, 10);
|
||||
|
||||
//
|
||||
XOHCL tmpBar;
|
||||
XBoxZone tmp;
|
||||
@@ -1498,6 +1532,17 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
tmp = zones[i];
|
||||
|
||||
//
|
||||
if (minimumRetests > 0)
|
||||
{
|
||||
//
|
||||
int retests = CounteZoneTouches(tmp, retestThreshold, retestLoopback);
|
||||
if (retests < minimumRetests)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Zone ...
|
||||
has = false;
|
||||
@@ -1575,7 +1620,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
ENUM_TIMEFRAMES forPeriod = NULL,
|
||||
int loopback = 50,
|
||||
int minorValidation = 7,
|
||||
int majorValidation = 14 //
|
||||
int majorValidation = 14,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1618,6 +1666,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
minorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1644,6 +1695,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
minorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1677,6 +1731,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
majorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1703,6 +1760,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
majorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1726,6 +1786,121 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
XClean(tmpSupports);
|
||||
XClean(tmpResistances);
|
||||
}
|
||||
|
||||
int CounteZoneTouches(
|
||||
XBoxZone &zone,
|
||||
double threshold = 10,
|
||||
int loopback = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
loopback = NormalizeInt(loopback, 50);
|
||||
threshold = NormalizeDouble(threshold, 10);
|
||||
|
||||
//
|
||||
if (!zone.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpBar;
|
||||
int start = zone.ToIndex();
|
||||
bool isUpperTouched = false;
|
||||
bool isLowerTouched = false;
|
||||
double points = GetPoints(zone.symbol);
|
||||
double distance = points * threshold;
|
||||
int end = MathMin(start + loopback, zone.FromIndex());
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
if (tmpBar.Init(zone.symbol, zone.period, i))
|
||||
{
|
||||
//
|
||||
isUpperTouched = MathAbs(tmpBar.high - zone.upper) <= distance;
|
||||
isLowerTouched = MathAbs(tmpBar.low - zone.lower) <= distance;
|
||||
|
||||
//
|
||||
if (
|
||||
(zone.IsBullish() &&
|
||||
(isLowerTouched ||
|
||||
MathAbs(tmpBar.close - zone.lower) <= distance)) ||
|
||||
(zone.IsBearish() &&
|
||||
(isUpperTouched ||
|
||||
MathAbs(tmpBar.close - zone.upper) <= distance)))
|
||||
{
|
||||
//
|
||||
result++;
|
||||
Add(
|
||||
tmpBar.time,
|
||||
zone.tests //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
tmpBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
tmpBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasNearZone(
|
||||
int &index,
|
||||
double price,
|
||||
double threshold,
|
||||
XBoxZone &zones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = HasChild(zones) &&
|
||||
NotEmptyZero(price) &&
|
||||
NotEmptyZero(threshold) &&
|
||||
price > 0 &&
|
||||
threshold > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(zones[0].symbol);
|
||||
double distance = points * threshold;
|
||||
for (int i = 0; i < ArraySize(zones); i++)
|
||||
{
|
||||
//
|
||||
// Check Price Distance by Upper ...
|
||||
result = price >= zones[i].lower - distance &&
|
||||
price <= zones[i].upper + distance;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user