last works on pattern detector ...
This commit is contained in:
@@ -1268,6 +1268,194 @@ class XCMarketPatternDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasSupport(
|
||||
XOHCL &bar,
|
||||
XOHCL &support,
|
||||
int validationLength = 21,
|
||||
int maxAllowedLoopback = 1500 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
support.Clean();
|
||||
|
||||
//
|
||||
// Normalizing ...
|
||||
validationLength = NormalizeInt(validationLength, 7);
|
||||
maxAllowedLoopback = NormalizeInt(maxAllowedLoopback, 21, 1500);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Support Swing ...
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
int lookupIDX = bar.Index();
|
||||
while (!IsValidIndex(idx) &&
|
||||
lookupIDX < maxAllowedLoopback)
|
||||
{
|
||||
//
|
||||
// Detect Swing ...
|
||||
idx = FindXSwing(
|
||||
X_SWING_LOW,
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
lookupIDX,
|
||||
validationLength //
|
||||
);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
lookupIDX++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Swing Bar ...
|
||||
has = support.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
idx //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
idx = -1;
|
||||
lookupIDX++;
|
||||
support.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Suppor Low Shadow ...
|
||||
has = support.GetDown() < bar.low;
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
idx = -1;
|
||||
lookupIDX++;
|
||||
support.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = support.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasResistance(
|
||||
XOHCL &bar,
|
||||
XOHCL &resistence,
|
||||
int validationLength = 21,
|
||||
int maxAllowedLoopback = 1500 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
resistence.Clean();
|
||||
|
||||
//
|
||||
// Normalizing ...
|
||||
validationLength = NormalizeInt(validationLength, 7);
|
||||
maxAllowedLoopback = NormalizeInt(maxAllowedLoopback, 21, 1500);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Support Swing ...
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
int lookupIDX = bar.Index();
|
||||
while (!IsValidIndex(idx) &&
|
||||
lookupIDX < maxAllowedLoopback)
|
||||
{
|
||||
//
|
||||
// Detect Swing ...
|
||||
idx = FindXSwing(
|
||||
X_SWING_HIGH,
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
lookupIDX,
|
||||
validationLength //
|
||||
);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
lookupIDX++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Swing Bar ...
|
||||
has = resistence.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
idx //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
idx = -1;
|
||||
lookupIDX++;
|
||||
resistence.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance High Shadow ...
|
||||
has = resistence.GetUp() > bar.high;
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
idx = -1;
|
||||
lookupIDX++;
|
||||
resistence.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = resistence.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user