start developing X5 provider and testing it ...

This commit is contained in:
2024-05-19 02:35:48 +03:30
parent 9c6cd61f2b
commit 4c1b97e805
6 changed files with 496 additions and 309 deletions
+195 -3
View File
@@ -84,6 +84,7 @@ class X5ProviderInputs : public XSCBaseProviderInpts
public:
//
// Props ...
XTSInputs tsInputs;
XTMInputs tmInputs;
XLHInputs lhInputs;
XTDInputs tdInputs;
@@ -107,6 +108,11 @@ public:
bool result = false;
//
result = tsInputs.IsValid();
if (!result) {
return result;
}
result = ctInputs.IsValid();
if (!result)
{
@@ -188,6 +194,7 @@ public:
virtual void Clean()
{
//
tsInputs.Clean();
ctInputs.Clean();
ccInputs.Clean();
tmInputs.Clean();
@@ -206,6 +213,7 @@ public:
virtual void Default()
{
//
tsInputs.Default();
ctInputs.Default();
ccInputs.Default();
tmInputs.Default();
@@ -230,6 +238,7 @@ public:
result = MathMax(lhInputs.Max(), tmInputs.Max());
//
result = MathMax(result, tsInputs.Max());
result = MathMax(result, ctInputs.Max());
result = MathMax(result, ccInputs.Max());
result = MathMax(result, tdInputs.Max());
@@ -286,7 +295,7 @@ class X5MarketConditions : public XSCBaseProviderMarketConditions
//
// X5 Provider Class ...
class XSC5Provider : public XSCBaseProvider
class XSCX5Provider : public XSCBaseProvider
{
//
// Public ...
@@ -298,6 +307,8 @@ public:
XSCXTDHelper *tdHelper;
XSCXLHHelper *lhHelper;
XSCXTMHelper *tmHelper;
XSCXCCHelper *ccHelper;
XSCXCTHelper *ctHelper;
XSCXOBDHelper *obdHelper;
XSCXRSIHelper *rsiHelper;
XSCXAMAHelper *amaHelper;
@@ -306,12 +317,24 @@ public:
//
// Constructor ...
XSC5Provider(
XSCX5Provider(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading PEriod
) : XSCBaseProvider(symbol, period)
{
//
tsHelper = new XSCXTSHelper();
fiHelper = new XSCXFIHelper();
tdHelper = new XSCXTDHelper();
lhHelper = new XSCXLHHelper();
tmHelper = new XSCXTMHelper();
ccHelper = new XSCXCCHelper();
ctHelper = new XSCXCTHelper();
obdHelper = new XSCXOBDHelper();
rsiHelper = new XSCXRSIHelper();
amaHelper = new XSCXAMAHelper();
chmaHelper = new XSCXCHMAHelper();
chlhHelper = new XSCXCHLHHelper();
}
//
@@ -338,6 +361,162 @@ public:
//
mInputs = inputs;
//
string mSymbol = GetSymbol();
ENUM_TIMEFRAMES mPeriod = GetPeriod();
//
result = tsHelper
.Init(
mSymbol,
mPeriod,
mInputs.tsInputs
//
);
if (!result)
{
return result;
}
//
result = fiHelper
.Init(
mSymbol,
mPeriod,
mInputs.fiInputs
//
);
if (!result)
{
return result;
}
//
result = tdHelper
.Init(
mSymbol,
mPeriod,
mInputs.tdInputs
//
);
if (!result)
{
return result;
}
//
result = lhHelper
.Init(
mSymbol,
mPeriod,
mInputs.lhInputs
//
);
if (!result)
{
return result;
}
//
result = tmHelper
.Init(
mSymbol,
mPeriod,
mInputs.tmInputs
//
);
if (!result)
{
return result;
}
//
result = ccHelper
.Init(
mSymbol,
mPeriod,
mInputs.ccInputs
//
);
if (!result)
{
return result;
}
//
result = ctHelper
.Init(
mSymbol,
mPeriod,
mInputs.ctInputs
//
);
if (!result)
{
return result;
}
//
result = obdHelper
.Init(
mSymbol,
mPeriod,
mInputs.obdInputs
//
);
if (!result)
{
return result;
}
//
result = rsiHelper
.Init(
mSymbol,
mPeriod,
mInputs.rsiInputs
//
);
if (!result)
{
return result;
}
//
result = amaHelper
.Init(
mSymbol,
mPeriod,
mInputs.amaInputs
//
);
if (!result)
{
return result;
}
//
result = chmaHelper
.Init(
mSymbol,
mPeriod,
mInputs.chmaInputs
//
);
if (!result)
{
return result;
}
//
result = chlhHelper
.Init(
mSymbol,
mPeriod,
mInputs.chlhInputs
//
);
//
return result;
}
@@ -346,6 +525,19 @@ public:
// DeInit all Requirements ...
virtual void DeInit()
{
//
delete tsHelper;
delete fiHelper;
delete tdHelper;
delete lhHelper;
delete tmHelper;
delete ccHelper;
delete ctHelper;
delete obdHelper;
delete rsiHelper;
delete amaHelper;
delete chmaHelper;
delete chlhHelper;
}
//
@@ -383,7 +575,7 @@ public:
// Protected ...
protected:
//
// X5MarketConditions mInputs;
X5ProviderInputs mInputs;
//
// Private ...
+3 -20
View File
@@ -133,31 +133,15 @@ public:
//
// Init all Requirements ...
virtual bool Init(XSCBaseProviderInpts &inputs)
{
//
mInputs = inputs;
//
bool result = false;
//
return result;
}
virtual bool Init(XSCBaseProviderInpts &inputs);
//
// Get Inputs ...
virtual void GetInputs(XSCBaseProviderInpts &inputs)
{
inputs = mInputs;
}
virtual void GetInputs(XSCBaseProviderInpts &inputs);
//
// Set Inputs and Reinitial ...
virtual bool setInputs(XSCBaseProviderInpts &inputs)
{
return Init(inputs);
}
virtual bool setInputs(XSCBaseProviderInpts &inputs);
//
// DeInit all Requirements ...
@@ -218,7 +202,6 @@ protected:
//
XMarketCycle mCycle;
XSCBaseProviderInpts mInputs;
//
bool mWaitsUntilNewBar;
-280
View File
@@ -1,280 +0,0 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXZGHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XZG_BUFFERS
{
XZG_MAIN_LINE = 0
};
//
// Input Models ...
struct XZGInputs
{
//
// Props ...
//
// Constructor(s) ...
XZGInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
}
//
// Default ...
void Default()
{
//
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
false
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(0, 0);
//
return result;
}
};
//
// Class ...
class XSCXZGHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXZGHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XZGInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
// ArraySetAsSeries(mainBuffer, true);
// mHandler = iCustom(
// mSymbol,
// mPeriod,
// "x-saherelm.xsslc",
// //
// // Inputs ...
// //
// );
// result = mHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
//
return result;
}
//
// Inputs ...
//
XZGInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XZGInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
// //
// double GetMain(
// int barIndex // Bar Index
// )
// {
// //
// if (barIndex < 0)
// {
// barIndex = 0;
// }
// //
// Calculate();
// //
// int count = ArraySize(mainBuffer);
// if (barIndex >= count)
// {
// barIndex = count - 1;
// }
// //
// return mainBuffer[barIndex];
// }
// //
// // Copy Required Items ...
// int CopyMain(
// int start, // Start
// int count, // Number of Items for read
// double &buffer[], // Dest Buffer
// bool forceClean = true // Force To Clean buffer
// )
// {
// //
// // Update Calculations ...
// Calculate();
// //
// // Copy Items ...
// return Copy(
// start,
// count,
// mainBuffer,
// buffer,
// forceClean
// //
// );
// }
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XZGInputs mInputs; // Inputs ...
//
// Buffers ...
// double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
// //
// // Main Buffer ...
// CopyBuffer(
// mHandler,
// XZG_MAIN_LINE,
// 0,
// totalBars,
// mainBuffer
// //
// );
}
}
//
// Tools ...
+133
View File
@@ -0,0 +1,133 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center X5EA MQL5 Expert Advisor
// -------------------------------------------------
// Name: X5EA
// Description: an Exper Advisor which used RSI and MA
// to Analyse Market ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////x
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm X5EA"
#property strict
//
#define ShortName "X5EA"
//
#include "../Libraries/x-saherelm.log.lib.mq5"
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xtrade.class.mq5"
//
// Inputs ...
long x5EAMagicNumber = 78692110; // Magic Number
int x5EASlippage = 10; // Slippgae
//
double x5EAVolume = 0.01;
//
// Vars ...
string x5EASymbol;
ENUM_TIMEFRAMES x5EAPeriod;
//
MqlTick x5EATick;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (x5EASymbol == NULL || StringLen(x5EASymbol) <= 0)
{
x5EASymbol = _Symbol;
}
//
if (x5EAPeriod == NULL)
{
x5EAPeriod = _Period;
}
//
// Validate Inputs ...
if (!X5EAValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
logTag = ShortName;
drawPrefix = ShortName;
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// De Initialize X5EA Providers ...
}
//
// On Tick Handler ...
void OnTick()
{
//
// Reading Tick ...
if (!SymbolInfoTick(x5EASymbol, x5EATick))
{
return;
}
}
//
// Custom Functions ...
//
// Validate Variables nd Inputs ...
bool X5EAValidateInputs()
{
//
bool result = false;
//
result =
//
x5EASlippage > 0 &&
x5EAMagicNumber > 0
//
;
//
return result;
}
+159
View File
@@ -0,0 +1,159 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center X5EA MQL5 Expert Advisor
// -------------------------------------------------
// Name: X5EA
// Description: an Exper Advisor which used RSI and MA
// to Analyse Market ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////x
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm X5EA"
#property strict
//
#define ShortName "X5EA"
//
#include "../Libraries/x-saherelm.log.lib.mq5"
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xtrade.class.mq5"
#include "../Classes/x-saherelm.x5.provider.class.mq5"
//
// Inputs ...
long x5EAMagicNumber = 78692110; // Magic Number
int x5EASlippage = 10; // Slippgae
//
double x5EAVolume = 0.01;
//
// Vars ...
string x5EASymbol;
ENUM_TIMEFRAMES x5EAPeriod;
//
MqlTick x5EATick;
//
// X5Provider ...
X5ProviderInputs x5Inputs;
XSCX5Provider *x5Provider;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (x5EASymbol == NULL || StringLen(x5EASymbol) <= 0)
{
x5EASymbol = _Symbol;
}
//
if (x5EAPeriod == NULL)
{
x5EAPeriod = _Period;
}
//
// Validate Inputs ...
if (!X5EAValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
logTag = ShortName;
drawPrefix = ShortName;
//
// Set Default and Validate X5Provider Inputs ...
x5Inputs.Default();
if (!x5Inputs.IsValid())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Init X5Provider Class ...
x5Provider = new XSCX5Provider(
x5EASymbol,
x5EAPeriod
//
);
if (!x5Provider.Init(x5Inputs))
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// De Initialize X5EA Providers ...
}
//
// On Tick Handler ...
void OnTick()
{
//
// Reading Tick ...
if (!SymbolInfoTick(x5EASymbol, x5EATick))
{
return;
}
}
//
// Custom Functions ...
//
// Validate Variables nd Inputs ...
bool X5EAValidateInputs()
{
//
bool result = false;
//
result =
//
x5EASlippage > 0 &&
x5EAMagicNumber > 0
//
;
//
return result;
}
+6 -6
View File
@@ -38,7 +38,7 @@ enum ENUM_XTS_BUFFERS
//
// Input Models ...
struct XXTSInputs
struct XTSInputs
{
//
// Props ...
@@ -63,7 +63,7 @@ struct XXTSInputs
//
// Constructor(s) ...
XXTSInputs()
XTSInputs()
{
//
Clean();
@@ -180,7 +180,7 @@ public:
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XXTSInputs &inputs // Inputs
XTSInputs &inputs // Inputs
)
{
//
@@ -251,14 +251,14 @@ public:
// Inputs ...
//
XXTSInputs GetInputs()
XTSInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XXTSInputs &inputs // Configs
XTSInputs &inputs // Configs
)
{
//
@@ -481,7 +481,7 @@ protected:
private:
//
// Props ...
XXTSInputs mInputs; // Inputs ...
XTSInputs mInputs; // Inputs ...
//
// Buffers ...