apply trail stop and break even ...

This commit is contained in:
2025-02-11 23:28:28 +03:30
parent fe129c3288
commit 4a70a3ef4f
11 changed files with 2682 additions and 1063 deletions
@@ -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[];