last works ...

This commit is contained in:
2025-10-01 17:59:26 +03:30
parent 2669790493
commit abd377c7fb
7 changed files with 79 additions and 23 deletions
@@ -23,7 +23,8 @@
#include "../Classes/x-saherelm.base.class.mq5" #include "../Classes/x-saherelm.base.class.mq5"
#include "../Classes/x-saherelm.x-alert.class.mq5" #include "../Classes/x-saherelm.x-alert.class.mq5"
#include "../Classes/x-saherelm.x-chart.helper.class.mq5" #include "../Classes/x-saherelm.x-chart.helper.class.mq5"
#include "../Classes/x-saherelm.x-target.manager.class.mq5" #include "../Classes/x-saherelm.x-guard.class.mq5"
#include "../Classes/x-saherelm.x-target.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" #include "../Classes/x-saherelm.x-volume.class.mq5"
@@ -83,7 +84,7 @@ class XCBackTesterEA : public XCBase
// //
XCAlert *eaAlert; // EA Scope Alert Handler ... XCAlert *eaAlert; // EA Scope Alert Handler ...
XCTrade *eaTrader; // EA Scope Trade Handler ... XCTrade *eaTrader; // EA Scope Trade Handler ...
XCTargetManager *eaTargetManager; // EA Scope Target Manager ... XCTarget *eaTarget; // EA Scope Target Manager ...
// //
XCChartHelper *eaChartHelper; // Chart Helper Class ... XCChartHelper *eaChartHelper; // Chart Helper Class ...
@@ -292,7 +293,7 @@ class XCBackTesterEA : public XCBase
// //
// Init Target Managers ... // Init Target Managers ...
eaTargetManager = new XCTargetManager(eaTrader); eaTarget = new XCTarget(eaTrader, eaAlert);
// //
// Initial GUI ... // Initial GUI ...
@@ -316,9 +317,9 @@ class XCBackTesterEA : public XCBase
void HandleOnDeInit() void HandleOnDeInit()
{ {
// //
eaTargetManager.Destroy(); eaTarget.Destroy();
delete eaTargetManager; delete eaTarget;
ZeroMemory(eaTargetManager); ZeroMemory(eaTarget);
// //
delete eaTrader; delete eaTrader;
@@ -357,7 +358,7 @@ class XCBackTesterEA : public XCBase
// //
// Managing Targets ... // Managing Targets ...
eaTargetManager.Manage(); eaTarget.Manage();
} }
/** /**
@@ -428,7 +429,7 @@ class XCBackTesterEA : public XCBase
UpdatePositionButtons(); UpdatePositionButtons();
// //
eaTargetManager.HandleOnStopLossTriggered(deal); eaTarget.HandleOnStopLossTriggered(deal);
} }
/** /**
@@ -443,7 +444,7 @@ class XCBackTesterEA : public XCBase
UpdatePositionButtons(); UpdatePositionButtons();
// //
eaTargetManager.HandleOnTakeProfitTriggered(deal); eaTarget.HandleOnTakeProfitTriggered(deal);
} }
/** /**
@@ -464,7 +465,7 @@ class XCBackTesterEA : public XCBase
UpdatePositionButtons(); UpdatePositionButtons();
// //
eaTargetManager.HandleOnPositionForceClosed( eaTarget.HandleOnPositionForceClosed(
ticket, ticket,
position, position,
comment // comment //
@@ -571,7 +572,7 @@ class XCBackTesterEA : public XCBase
*/ */
void HandleOnSignalExecuted(XSignal &signal) void HandleOnSignalExecuted(XSignal &signal)
{ {
eaTargetManager.AddExecutedSignal(signal); eaTarget.AddExecutedSignal(signal);
} }
// //
+3 -1
View File
@@ -268,13 +268,15 @@ class XCBaseSignaller : public XCBase
/** /**
* Check Guards Based on MarketConditions ... * Check Guards Based on MarketConditions ...
* *
* @param guards: XGuard[] * @param guards: XGuard, reference collection to holds result ...
* @param positions: XPosition, reference collection to provides positions ...
* @param barIndex: int * @param barIndex: int
* *
* @return ( int ) * @return ( int )
*/ */
int virtual CheckForGuard( int virtual CheckForGuard(
XGuard &guards[], XGuard &guards[],
XPosition &positions[],
int barIndex = 0 // int barIndex = 0 //
) )
{ {
@@ -2,7 +2,7 @@
// //
// SaherElm IT Center MQL5 Class Library // SaherElm IT Center MQL5 Class Library
// ---------------------------------------------- // ----------------------------------------------
// Name: XCTargetManager // Name: XCTarget
// Description: provides all Positions Target requirements ... // Description: provides all Positions Target requirements ...
// //
// //
@@ -26,29 +26,34 @@
// //
// Implementation ... // Implementation ...
class XCTargetManager : public XCBase class XCTarget : public XCBase
{ {
// //
// Public ... // Public ...
public: public:
// //
XCTrade *trader; XCTrade *trader;
XCAlert *alert;
XSignal signals[]; XSignal signals[];
// //
// Constructor ... // Constructor ...
XCTargetManager( XCTarget(
XCTrade *_trader // XCTrade *_trader, //
XCAlert *_alert //
) : XCBase() ) : XCBase()
{ {
// //
alert = _alert;
trader = _trader; trader = _trader;
//
XClean(signals); XClean(signals);
} }
// //
// Deconstructor ... // Deconstructor ...
~XCTargetManager() ~XCTarget()
{ {
Destroy(); Destroy();
} }
@@ -568,6 +573,7 @@ class XCTargetManager : public XCBase
// //
// Apply Target ... // Apply Target ...
string comment = NULL; string comment = NULL;
string message = NULL;
// //
// Do Risk Free if Provided ... // Do Risk Free if Provided ...
@@ -581,6 +587,11 @@ class XCTargetManager : public XCBase
position.tp, // TP ... position.tp, // TP ...
comment // comment //
); );
//
// Handle Alert ...
message = "Target Manager do RF " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") on: " + ToXString(position.price);
alert.SendAlert(message);
} }
// //
@@ -598,6 +609,11 @@ class XCTargetManager : public XCBase
volume, volume,
comment // comment //
); );
//
// Handle Alert ...
message = "Target Manager do Partial Close " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") by: " + ToXString(volume);
alert.SendAlert(message);
} }
} }
+4 -1
View File
@@ -1753,7 +1753,10 @@ class XCTradeManager : public XCBase
// Check For Guards ... // Check For Guards ...
if (checkForGuardEventListener != NULL) if (checkForGuardEventListener != NULL)
{ {
result = checkForGuardEventListener(dest); //
XPosition positions[];
trader.GetPositions(positions);
result = checkForGuardEventListener(dest, positions, 0);
} }
// //
@@ -612,6 +612,32 @@ void OnSignalExecuted(XSignal &signal)
eaExpert.HandleOnSignalExecuted(signal); eaExpert.HandleOnSignalExecuted(signal);
} }
/**
* Check For Guard ...
*
* @param guards: XGuard, reference Collection to holds result ...
* @param positions: XPosition, refrence collection to Provides Positions ...
* @param barIndex: int, Specified Bar index ...
*
* @return ( int )
*/
int CheckForGuard(
XGuard &guards[],
XPosition &positions[],
int barIndex = 0 //
)
{
//
int result = fima1Signaller.CheckForGuard(
guards,
positions,
barIndex //
);
//
return result;
}
// //
// Trade Event Handlers ... // Trade Event Handlers ...
+5 -1
View File
@@ -3809,7 +3809,11 @@ typedef void (*TOnGuarded)(
XPosition &positions[]); XPosition &positions[]);
// //
typedef int (*TCheckForGuard)(XGuard &guards[]); typedef int (*TCheckForGuard)(
XGuard &guards[],
XPosition &positions[],
int barIndex = 0 //
);
// //
typedef void (*TOnDealsChanged)(int count); typedef void (*TOnDealsChanged)(int count);
@@ -162,13 +162,15 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
/** /**
* Check Guards Based on MarketConditions ... * Check Guards Based on MarketConditions ...
* *
* @param guards: XGuard[] * @param guards: XGuard, reference collection to holds result ...
* @param positions: XPosition, reference collection to provides positions ...
* @param barIndex: int * @param barIndex: int
* *
* @return ( int ) * @return ( int )
*/ */
int virtual CheckForGuard( int virtual CheckForGuard(
XGuard &guards[], XGuard &guards[],
XPosition &positions[],
int barIndex = 0 // int barIndex = 0 //
) )
{ {
@@ -647,13 +649,15 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
/** /**
* Check Guards Based on MarketConditions ... * Check Guards Based on MarketConditions ...
* *
* @param guards: XGuard[] * @param guards: XGuard, reference collection to holds result ...
* @param positions: XPosition, reference collection to provides positions ...
* @param barIndex: int * @param barIndex: int
* *
* @return ( int ) * @return ( int )
*/ */
int virtual CheckForGuard( int virtual CheckForGuard(
XGuard &guards[], XGuard &guards[],
XPosition &positions[],
int barIndex = 0 // int barIndex = 0 //
) )
{ {