This commit is contained in:
2024-06-12 09:45:57 +03:30
parent 6da0c05cdf
commit a34d471d6e
6 changed files with 690 additions and 37 deletions
+161 -3
View File
@@ -632,6 +632,39 @@ public:
//
// Add Event Listeners ...
//
void AddOnModifyPositionEventHandler(TOnModify handler)
{
//
Add(
handler,
mOnModifyEventHandlers
//
);
}
//
void AddOnForceClosePositionEventHandler(TOnForceClose handler)
{
//
Add(
handler,
mOnForceCloseEventHandlers
//
);
}
//
void AddOnPartialClosePositionEventHandler(TOnPartialClose handler)
{
//
Add(
handler,
mOnPartialCloseEventHandlers
//
);
}
//
// Add New Deals Changed Event Handler ...
void AddOnTradeStateChangedEventHandler(TOnTradeStateChanged handler)
@@ -1742,8 +1775,12 @@ public:
//
// Validate Args ...
XPosition position;
result =
IsOpen(ticket) &&
GetPosition(
ticket,
position //
) &&
(tp >= 0 || sl >= 0);
if (!result)
{
@@ -1768,6 +1805,15 @@ public:
comment
//
);
if (result)
{
//
NotifyModifyEvent(
ticket,
position.profit,
comment //
);
}
//
return result;
@@ -1785,7 +1831,11 @@ public:
//
// Check Position Open ...
result = IsOpen(ticket);
XPosition position;
result = GetPosition(
ticket,
position //
);
if (!result)
{
return result;
@@ -1806,6 +1856,15 @@ public:
comment
//
);
if (result)
{
//
NotifyForceCloseEvent(
ticket,
position,
comment //
);
}
//
return result;
@@ -1912,7 +1971,11 @@ public:
bool result = false;
//
result = IsOpen(ticket);
XPosition position;
result = GetPosition(
ticket,
position //
);
if (!result)
{
return result;
@@ -1934,6 +1997,15 @@ public:
comment
//
);
if (result)
{
//
NotifyPartialCloseEvent(
ticket,
position.profit,
comment //
);
}
//
return result;
@@ -3384,6 +3456,87 @@ protected:
}
}
//
void NotifyModifyEvent(
ulong ticket,
double profit,
string comment //
)
{
//
int count = ArraySize(mOnModifyEventHandlers);
if (count <= 0)
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
TOnModify iHandler = mOnModifyEventHandlers[i];
iHandler(
ticket,
profit,
comment //
);
}
}
//
void NotifyForceCloseEvent(
ulong ticket,
XPosition &position,
string comment //
)
{
//
int count = ArraySize(mOnForceCloseEventHandlers);
if (count <= 0)
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
TOnForceClose iHandler = mOnForceCloseEventHandlers[i];
iHandler(
ticket,
position,
comment //
);
}
}
//
void NotifyPartialCloseEvent(
ulong ticket,
double profit,
string comment //
)
{
//
int count = ArraySize(mOnPartialCloseEventHandlers);
if (count <= 0)
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
TOnModify iHandler = mOnPartialCloseEventHandlers[i];
iHandler(
ticket,
profit,
comment //
);
}
}
//
// Tools ...
@@ -3579,6 +3732,11 @@ private:
// Trade State Changed Event Handlers ...
TOnTradeStateChanged mTradeStateChangedEventHandlers[];
//
TOnModify mOnModifyEventHandlers[];
TOnForceClose mOnForceCloseEventHandlers[];
TOnPartialClose mOnPartialCloseEventHandlers[];
//
// TPSL ...
TOnStopLoss mStopLossEventHandlers[];