last works on EA all Requirements Prepare as Template and Implement it's Testing Usage as XFIMA EA ...

This commit is contained in:
2025-09-17 22:22:12 +03:30
parent b11e4f7f4b
commit 177d115de6
11 changed files with 4555 additions and 31 deletions
@@ -0,0 +1,117 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class
// -------------------------------------------------
// Name: XCXFIMAExpret ...
// Description: XFIMA Expert Class ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XFIMA Expert Class"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.x-expert.class.mq5"
#include "../Classes/x-saherelm.xfima.signaller.class.mq5"
//
// Definitions ...
//
// Implementation ...
class XCXFIMAExpret : public XCBaseExpert
{
//
// Public ...
public:
//
//
// Overrides ...
/**
* Prepare Signallers per Symbol Config ...
*
* @param symbolConfig: XSymbolTradeConfig, Symbol Trade Configurations ...
*/
void PrepareSignallers(XSymbolTradeConfig &symbolConfig) override
{
//
// Validate ...
if (!symbolConfig.IsValid())
{
return;
}
//
// Instantiate Signaller ...
//
// XFIMA Inputs ...
//
XFIMAInputs fimaInputs;
fimaInputs.Default();
fimaInputs.Hide();
//
// Instantiate Signaller Class ...
XCXFIMAStrategy1Signaller *fima1Signaller = new XCXFIMAStrategy1Signaller(
symbolConfig.symbol,
symbolConfig.period,
fimaInputs,
false // Process All Ticks ...
);
if (!fima1Signaller.IsValid())
{
//
fima1Signaller.Destroy();
delete fima1Signaller;
ZeroMemory(fima1Signaller);
return;
}
//
// Register Signaller ...
RegisterSignaller((XCBaseSignaller *)fima1Signaller);
//
// Cleanup Resources ...
fimaInputs.Clean();
ZeroMemory(fima1Signaller);
}
/**
* Additional On Tick Processing if Required ...
*
* @param barIndex: int, Specified Bar Index ...
*/
void virtual HandleOnTickAdditional(int barIndex = 0)
{
//
// Implement this if required ...
}
//
// Protected ...
protected:
//
//
// Private ...
private:
//
};
//
@@ -5,7 +5,7 @@
// Name: XCXFIMASignaller ...
// Description: XFIMA Signaller Class ...
//
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
@@ -17,8 +17,341 @@
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm Base Signaller Class"
#property description "SaherElm XFIMA Signaller Class"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
//
// Implementation ...
//
// Base XFIMA base Signaller ...
class XCXFIMABaseSignaller : public XCBaseSignaller
{
//
// Public ...
public:
//
// Props ...
//
XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
//
// Constructor ...
XCXFIMABaseSignaller(
string _name, // Name ...
string _symbol, // Symbol ...
ENUM_TIMEFRAMES _period, // Period ...
XFIMAInputs &_fimaInputs, // XFIMAInputs ...
bool _processAllTicks = false, // Process All Ticks ...
double _defaultSignalR2R = 1.5, // Default Signal Risk To Reward Ratio ...
double _defaultSignalRiskInPoint = 50, // Default Signal Risk In Point ...
double _defaultSignalVolume = 0.01 // Default Signal Volume ...
) : XCBaseSignaller(_name,
_symbol,
_period,
_processAllTicks,
_defaultSignalR2R,
_defaultSignalRiskInPoint,
_defaultSignalVolume //
)
{
//
// Instantiating XFIMA Indicator Helper Class ...
if (_fimaInputs.IsValid())
{
//
fimaHelper = new XCXFIMAHelper();
bool isInited = fimaHelper.Init(
_symbol,
_period,
_fimaInputs //
);
if (isInited)
{
fimaInputs = _fimaInputs;
}
else
{
//
delete fimaHelper;
ZeroMemory(fimaHelper);
}
}
}
//
// Deconstructor ...
~XCXFIMABaseSignaller()
{
Destroy();
}
//
// Overrides ...
//
// Actions ...
/**
* Destroy ...
*/
void Destroy()
{
//
BeforeDestroy();
//
fimaInputs.Clean();
//
delete fimaHelper;
ZeroMemory(fimaHelper);
}
//
// Virtuals ...
/**
* Before Destroy ...
*/
void virtual BeforeDestroy()
{
}
/**
* Processing Tick ...
*
* @param barIndex: int, Specified Bar Index ...
*/
virtual void ProcessTick(int barIndex = 0)
{
}
/**
* Processing New Bar ...
*
* @param barIndex: int, Specified Bar Index ...
*/
virtual void ProcessNewBar(int barIndex = 0)
{
}
/**
* Check Guards Based on MarketConditions ...
*
* @param guards: XGuard[]
* @param barIndex: int
*
* @return ( int )
*/
int virtual CheckForGuard(
XGuard &guards[],
int barIndex = 0 //
)
{
//
int result = 0;
//
SpecifiedClean(guards);
//
result = ArraySize(guards);
//
return result;
}
/**
* Check Additional Validations on Childs Instances ...
*
* @return ( bool virtual )
*/
bool virtual CheckAdditionslSignallerValidations()
{
//
bool result = false;
//
// Validate Fima Helper Requirements ...
result = fimaInputs.IsValid() &&
fimaHelper != NULL;
//
return result;
}
//
// Protected ...
protected:
//
//
// Private ...
private:
//
};
//
// XFIMA Strategy 1 Signaller Class ...
class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
{
//
// Public ...
public:
//
// Props ...
//
// Constructor ...
XCXFIMAStrategy1Signaller(
string _symbol, // Symbol ...
ENUM_TIMEFRAMES _period, // Period ...
XFIMAInputs &_fimaInputs, // XFIMAInputs ...
bool _processAllTicks = false, // Process All Ticks ...
double _defaultSignalR2R = 1.5, // Default Signal Risk To Reward Ratio ...
double _defaultSignalRiskInPoint = 50, // Default Signal Risk In Point ...
double _defaultSignalVolume = 0.01 // Default Signal Volume ...
) : XCXFIMABaseSignaller("XFIMA1",
_symbol,
_period,
_fimaInputs,
_processAllTicks,
_defaultSignalR2R,
_defaultSignalRiskInPoint,
_defaultSignalVolume //
)
{
}
//
// Overrides ...
/**
* Processing Tick ...
*
* @param barIndex: int, Specified Bar Index ...
*/
virtual void ProcessTick(int barIndex = 0)
{
}
/**
* Processing New Bar ...
*
* @param barIndex: int, Specified Bar Index ...
*/
virtual void ProcessNewBar(int barIndex = 0)
{
//
// Normalize ...
barIndex = NormalizeInt(barIndex, 0);
//
// Update Helper ...
fimaHelper.Update(barIndex);
//
XOHCL bar;
XSignal signal;
bool has = false;
ENUM_X_DIRECTION signalDir = X_DIRECTION_NONE;
//
// Initialize Bar ...
has = bar.Init(
symbol,
period,
barIndex //
);
if (!has)
{
//
bar.Clean();
return;
}
//
// Retrieve Conditions ...
XFIMAConditions fimaConditions;
has = fimaHelper.GetConditions(
fimaConditions,
barIndex,
10 // Loopback ...
);
if (!has)
{
//
bar.Clean();
fimaConditions.Clean();
//
return;
}
//
// Analyse Conditions for Finding Signal ...
//
// Check Signal Founded ...
has = HasDirection(signalDir);
if (has)
{
//
// Prepare Founded Signal ...
has = PrepareSignal(
signal,
signalDir //
);
if (has)
{
//
// Notify On Signal Event ...
NotifySignalEventListeners(signal);
}
}
//
// Cleanup Resources ...
bar.Clean();
signal.Clean();
fimaConditions.Clean();
}
/**
* Check Guards Based on MarketConditions ...
*
* @param guards: XGuard[]
* @param barIndex: int
*
* @return ( int )
*/
int virtual CheckForGuard(
XGuard &guards[],
int barIndex = 0 //
)
{
//
int result = 0;
//
SpecifiedClean(guards);
//
result = ArraySize(guards);
//
return result;
}
//
};
//