apply trail stop and break even ...
This commit is contained in:
@@ -41,7 +41,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
|
||||
XCAccount mAccount;
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCX121SMCBaseStrategy(
|
||||
|
||||
@@ -106,6 +106,183 @@ 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 ...
|
||||
|
||||
@@ -462,14 +639,18 @@ class XC121SMCCycleHelper : public XCBase
|
||||
);
|
||||
|
||||
// //
|
||||
// XCConsolidationZoneObject *czObj;
|
||||
// bool isCreated = mPOIDrawer.CreateConsolidationZone(
|
||||
// mActiveConsolidationZone,
|
||||
// czObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// if (GetPeriod() == PERIOD_M5)
|
||||
// {
|
||||
// mConsolidationObjects.Add(czObj);
|
||||
// //
|
||||
// XCConsolidationZoneObject *czObj;
|
||||
// bool isCreated = mPOIDrawer.CreateConsolidationZone(
|
||||
// mActiveConsolidationZone,
|
||||
// czObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// mConsolidationObjects.Add(czObj);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
@@ -551,7 +732,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
ENUM_TIMEFRAMES mPeriod;
|
||||
|
||||
//
|
||||
CArrayObj mConsolidationObjects;
|
||||
// CArrayObj mConsolidationObjects;
|
||||
XConsolidationZone mActiveConsolidationZone;
|
||||
XConsolidationZone mConsolidationZones[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user