last works on supporting ...

This commit is contained in:
2024-06-20 00:05:45 +03:30
parent 7bae4c6723
commit 0ef22df67b
11 changed files with 2440 additions and 494 deletions
+107 -5
View File
@@ -42,7 +42,7 @@ struct XTradeInfo
double volume; // Volume
string provider; // Signaller
ENUM_TIMEFRAMES period; // Trading Timeframe
ENUM_X_POSITION_TYPE type; // Position Type
ENUM_X_POSITION_TYPES type; // Position Type
//
ulong ticket; // Position Ticket
@@ -3851,7 +3851,7 @@ public:
{
//
// Select Signal Opposit Positions ...
ENUM_X_POSITION_TYPE iOpposit = GetOppositPositionType(iSignal.type);
ENUM_X_POSITION_TYPES iOpposit = GetOppositPositionType(iSignal.type);
//
XPosition iPositions[];
@@ -3995,9 +3995,8 @@ public:
//
// Signal Info Manager ...
XSignal tSignal = signal;
bool isSupport = ExtractSupportedTicket(signal.comment) > 0;
bool isEQMSupport = ExtractEQMSupportedTicket(signal.comment) > 0;
if (!isSupport && !isEQMSupport)
bool isSupport = IsSupport(signal.comment);
if (!isSupport)
{
mTradeHandler.Update(tSignal);
}
@@ -4019,6 +4018,13 @@ public:
mTradeHandler.Sync();
}
//
// Handle Support of Supports here ...
void OnPositionsChangedHandler(int count) override
{
EQMHandleSupportProtection(count);
}
//
void OnPositionClosed(
const XPosition &position,
@@ -4739,6 +4745,102 @@ private:
}
}
//
void EQMHandleSupportProtection(int positionsCount)
{
//
if (!IsValidSize(positionsCount))
{
return;
}
//
ulong ticket = mTrader.GetLastOpenPositionTicket();
XPosition position;
bool hasPosition = mTrader.GetPosition(
ticket,
position //
);
if (!hasPosition)
{
return;
}
//
bool isSupport = IsSupport(position.comment);
if (!isSupport)
{
return;
}
//
bool isDIRInDIRSupport = position.provider == XEQMSupportToken + XDirectionalToken ||
position.provider == XEQMSupportToken + XINDirectionalToken;
if (!isDIRInDIRSupport)
{
return;
}
//
ulong parentTicket = ExtractParentTicket(position.comment);
XPosition parent;
bool hasParent = mTrader.GetPosition(
parentTicket,
parent //
);
if (!hasParent)
{
return;
}
//
// Remove Parent TP SL ...
if (parent.tp > 0 || parent.sl > 0)
{
//
string comment = XEQMSupportToken + "Remoove TPSL due Protect ...";
bool isModeified = mTrader.Modify(
parentTicket,
0,
0,
comment //
);
if (isModeified)
{
//
string message = XEQMSupportToken + " Removes Position (" + ToString(parentTicket) + ")' TP/SL Due Start Supporting ...";
//
Alert(message);
}
}
//
XSignal signal;
X121SignalGenerator signalGenerator;
bool hasSupport = signalGenerator.UpdateSupportSignals(
position,
parent,
signal //
);
if (!hasSupport)
{
return;
}
//
XSignal signals[];
//
AddRef(
signal,
signals //
);
//
EQMExecuteSignals(signals);
}
//
};