add support of Consolidation Zone ibside XPOIDetector and XPOIState ...
This commit is contained in:
@@ -106,183 +106,6 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
// Getter/Setter(s) ...
|
||||
|
||||
//
|
||||
int CountConsolidationZones()
|
||||
{
|
||||
return ArraySize(mConsolidationZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasConsolidationZones()
|
||||
{
|
||||
return HasChild(mConsolidationZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConsolidationZone(
|
||||
int idx,
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
result = HasConsolidationZones();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = CountConsolidationZones();
|
||||
result = idx >= 0 &&
|
||||
idx < count;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
zone = mConsolidationZones[idx];
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetLastDirectionalConsolidationZone(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
result = HasDirection(forDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasZones = HasConsolidationZones();
|
||||
int zonesCount = CountConsolidationZones();
|
||||
result = hasZones;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = zonesCount - 1; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XConsolidationZone iZone = mConsolidationZones[i];
|
||||
|
||||
//
|
||||
if (!iZone.IsBreaked())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (!HasDirection(iZone.breakDir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (iZone.breakDir != forDir)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
zone = iZone;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetActiveConsolidationZone(
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone = mActiveConsolidationZone;
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int FillConsolidationZones(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XConsolidationZone &zones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(zones);
|
||||
|
||||
//
|
||||
bool hasZones = HasConsolidationZones();
|
||||
if (!hasZones)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = CountConsolidationZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XConsolidationZone iZone = mConsolidationZones[i];
|
||||
|
||||
//
|
||||
bool isDirPassed =
|
||||
(forDir == X_DIRECTION_ALL ||
|
||||
forDir == X_DIRECTION_NONE)
|
||||
? true
|
||||
: forDir == iZone.breakDir;
|
||||
if (isDirPassed)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iZone,
|
||||
zones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(zones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
@@ -618,7 +441,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
Update();
|
||||
// Update();
|
||||
|
||||
//
|
||||
result = conditions.IsValid();
|
||||
@@ -627,87 +450,6 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
void Update()
|
||||
{
|
||||
//
|
||||
int czRange = 50; // Consolidation min Range Points ...
|
||||
int czLoopback = 5;
|
||||
int maxAllowed = 20;
|
||||
bool isActiveConsolidationZoneBreaked = false;
|
||||
bool hasActiveConsolidationZone = mActiveConsolidationZone.IsValid();
|
||||
|
||||
//
|
||||
if (hasActiveConsolidationZone)
|
||||
{
|
||||
//
|
||||
isActiveConsolidationZoneBreaked = mActiveConsolidationZone.IsBreaked();
|
||||
|
||||
//
|
||||
if (isActiveConsolidationZoneBreaked)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
mActiveConsolidationZone,
|
||||
mConsolidationZones //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
mConsolidationZones,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
mActiveConsolidationZone.Clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
mActiveConsolidationZone.Update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
XOHCL mBar;
|
||||
bool hasBar = GetBar(
|
||||
mBar,
|
||||
0 //
|
||||
);
|
||||
if (hasBar)
|
||||
{
|
||||
//
|
||||
double upper = 0;
|
||||
double lower = 0;
|
||||
bool hasConsolidationZone =
|
||||
mBarAnalyser.IsConsolidate(
|
||||
mBar,
|
||||
upper,
|
||||
lower,
|
||||
czLoopback,
|
||||
czRange //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
mActiveConsolidationZone.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
upper,
|
||||
lower,
|
||||
czLoopback //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
mBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
@@ -729,11 +471,6 @@ class XC121SMCCycleHelper : public XCBase
|
||||
string mSymbol;
|
||||
ENUM_TIMEFRAMES mPeriod;
|
||||
|
||||
//
|
||||
// CArrayObj mConsolidationObjects;
|
||||
XConsolidationZone mActiveConsolidationZone;
|
||||
XConsolidationZone mConsolidationZones[];
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
@@ -751,10 +488,6 @@ class XC121SMCCycleHelper : public XCBase
|
||||
delete mX121Helper;
|
||||
delete mPOIDetector;
|
||||
delete mBarAnalyser;
|
||||
|
||||
//
|
||||
Clean(mConsolidationZones);
|
||||
mActiveConsolidationZone.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user