This commit is contained in:
2025-09-11 14:20:21 +03:30
parent 1ac14ada0c
commit 07d56d4f8b
2 changed files with 46 additions and 25 deletions
+45 -25
View File
@@ -26,6 +26,7 @@
#include "../Classes/x-saherelm.x-guard.class.mq5"
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../Classes/x-saherelm.x-trade.class.mq5"
#include "../Classes/x-saherelm.x-volume.class.mq5"
//
// Implementation ...
@@ -39,6 +40,7 @@ class XCTradeManager : public XCBase
XCAlert *alert;
XCGuard *guard;
XCTrade *trader;
XCVolume *volume;
XTimeTracker timeTracker;
XCDataCollector *collector;
@@ -50,12 +52,14 @@ class XCTradeManager : public XCBase
XCTradeManager(
XCAlert *_alert,
XCTrade *_trader,
XCVolume *_volume,
XCGuard *_guard //
)
{
//
alert = _alert;
guard = _guard;
volume = _volume;
trader = _trader;
//
@@ -666,12 +670,12 @@ class XCTradeManager : public XCBase
if (canPC)
{
//
double volume = jTarget.volumeMultiplier * iPosition.volume;
volume = NormalizeVolume(volume, iPosition.symbol);
double _volume = jTarget.volumeMultiplier * iPosition.volume;
_volume = NormalizeVolume(_volume, iPosition.symbol);
string comment = "RF On Target ...";
isPCDone = trader.ClosePartial(
iPosition.ticket,
volume,
_volume,
comment //
);
}
@@ -803,7 +807,8 @@ class XCTradeManager : public XCBase
//
// Check Trade Permission ...
if (!allowTrade)
result = AllowTrade(signal.type);
if (!result)
{
//
result = false;
@@ -814,34 +819,21 @@ class XCTradeManager : public XCBase
}
//
bool isLong = IsLong(signal.type);
bool isShort = IsShort(signal.type);
//
bool isLongAndAllowed =
isLong &&
allowLongs;
//
bool isShortAndAllowed =
isShort &&
allowShorts;
//
result = isLongAndAllowed ||
isShortAndAllowed;
// Check Sessions and Restrictions ...
result = CanAnalyse(
signal.symbol,
signal.period,
signal.time //
);
if (!result)
{
//
executionResult = X_SIGNAL_EXECUTION_FAILED_NOT_ALLOWED;
executionResult = X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED;
//
return result;
}
//
// TODO: Complete this ...
//
return result;
}
@@ -1079,6 +1071,7 @@ class XCTradeManager : public XCBase
//
// Check Signal ...
bool isExecuted = false;
ENUM_X_SIGNAL_EXECUTION_RESULT signalExecutionResult;
bool canExecute = CheckSignal(
signal,
@@ -1086,7 +1079,9 @@ class XCTradeManager : public XCBase
);
if (canExecute)
{
bool isExecuted = Execute(signal);
//
HandleSignalVolume(signal);
isExecuted = Execute(signal);
}
//
@@ -1491,6 +1486,31 @@ class XCTradeManager : public XCBase
{
}
/**
* Apply Signal Volume ...
*
* @param signal: XSignal
*/
void HandleSignalVolume(XSignal &signal)
{
//
// Validate ...
if (!signal.IsValid())
{
return;
}
//
// Handle Volume Management ...
double iVolume = volume.CalculateVolume(signal);
bool has = iVolume > X_MIN_VOLUME &&
iVolume != signal.volume;
if (has)
{
signal.volume = iVolume;
}
}
/**
* Find Executed Trade by Providing Position Ticket ...
*
+1
View File
@@ -507,6 +507,7 @@ class XCXOM1EAExpert : public XCBase
eaTradeManager = new XCTradeManager(
eaAlert,
eaTrade,
eaVolume,
eaGuard //
);