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-guard.class.mq5"
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../Classes/x-saherelm.x-trade.class.mq5" #include "../Classes/x-saherelm.x-trade.class.mq5"
#include "../Classes/x-saherelm.x-volume.class.mq5"
// //
// Implementation ... // Implementation ...
@@ -39,6 +40,7 @@ class XCTradeManager : public XCBase
XCAlert *alert; XCAlert *alert;
XCGuard *guard; XCGuard *guard;
XCTrade *trader; XCTrade *trader;
XCVolume *volume;
XTimeTracker timeTracker; XTimeTracker timeTracker;
XCDataCollector *collector; XCDataCollector *collector;
@@ -50,12 +52,14 @@ class XCTradeManager : public XCBase
XCTradeManager( XCTradeManager(
XCAlert *_alert, XCAlert *_alert,
XCTrade *_trader, XCTrade *_trader,
XCVolume *_volume,
XCGuard *_guard // XCGuard *_guard //
) )
{ {
// //
alert = _alert; alert = _alert;
guard = _guard; guard = _guard;
volume = _volume;
trader = _trader; trader = _trader;
// //
@@ -666,12 +670,12 @@ class XCTradeManager : public XCBase
if (canPC) if (canPC)
{ {
// //
double volume = jTarget.volumeMultiplier * iPosition.volume; double _volume = jTarget.volumeMultiplier * iPosition.volume;
volume = NormalizeVolume(volume, iPosition.symbol); _volume = NormalizeVolume(_volume, iPosition.symbol);
string comment = "RF On Target ..."; string comment = "RF On Target ...";
isPCDone = trader.ClosePartial( isPCDone = trader.ClosePartial(
iPosition.ticket, iPosition.ticket,
volume, _volume,
comment // comment //
); );
} }
@@ -803,7 +807,8 @@ class XCTradeManager : public XCBase
// //
// Check Trade Permission ... // Check Trade Permission ...
if (!allowTrade) result = AllowTrade(signal.type);
if (!result)
{ {
// //
result = false; result = false;
@@ -814,34 +819,21 @@ class XCTradeManager : public XCBase
} }
// //
bool isLong = IsLong(signal.type); // Check Sessions and Restrictions ...
bool isShort = IsShort(signal.type); result = CanAnalyse(
signal.symbol,
// signal.period,
bool isLongAndAllowed = signal.time //
isLong && );
allowLongs;
//
bool isShortAndAllowed =
isShort &&
allowShorts;
//
result = isLongAndAllowed ||
isShortAndAllowed;
if (!result) if (!result)
{ {
// //
executionResult = X_SIGNAL_EXECUTION_FAILED_NOT_ALLOWED; executionResult = X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED;
// //
return result; return result;
} }
//
// TODO: Complete this ...
// //
return result; return result;
} }
@@ -1079,6 +1071,7 @@ class XCTradeManager : public XCBase
// //
// Check Signal ... // Check Signal ...
bool isExecuted = false;
ENUM_X_SIGNAL_EXECUTION_RESULT signalExecutionResult; ENUM_X_SIGNAL_EXECUTION_RESULT signalExecutionResult;
bool canExecute = CheckSignal( bool canExecute = CheckSignal(
signal, signal,
@@ -1086,7 +1079,9 @@ class XCTradeManager : public XCBase
); );
if (canExecute) 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 ... * Find Executed Trade by Providing Position Ticket ...
* *
+1
View File
@@ -507,6 +507,7 @@ class XCXOM1EAExpert : public XCBase
eaTradeManager = new XCTradeManager( eaTradeManager = new XCTradeManager(
eaAlert, eaAlert,
eaTrade, eaTrade,
eaVolume,
eaGuard // eaGuard //
); );