589 lines
12 KiB
Plaintext
589 lines
12 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCBaseX5Provider
|
|
// Description: provides all Base Provider
|
|
// requirements For X5 ...
|
|
//
|
|
//
|
|
// 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 "../Helpers/x-saherelm.xct.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xtm.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xama.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xlh.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xtd.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xfi.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xts.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xrsi.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xobd.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchlh.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchma.helper.mq5"
|
|
|
|
//
|
|
#include "../Classes/x-saherelm.xprovider.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
enum ENUM_X5_SIGNAL_PROVIDERS
|
|
{
|
|
//
|
|
// XSP Expert Support Mechanism ...
|
|
XSP,
|
|
//
|
|
// XTD ...
|
|
XTD,
|
|
//
|
|
// XTAM ...
|
|
XTAM,
|
|
//
|
|
// XSI ...
|
|
XSI,
|
|
//
|
|
// XTSFI ...
|
|
XTSFI,
|
|
//
|
|
// XOBDLH ...
|
|
XOBDLH,
|
|
//
|
|
// XCHMACC ...
|
|
XCHMACC,
|
|
//
|
|
// XCHMACMN ...
|
|
XCHMAMN,
|
|
//
|
|
// XCHMACMX ...
|
|
XCHMAMX,
|
|
};
|
|
|
|
//
|
|
// X5 Provider Inputs ...
|
|
class X5ProviderInputs : public XSCBaseProviderInpts
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
XTSInputs tsInputs;
|
|
XTMInputs tmInputs;
|
|
XLHInputs lhInputs;
|
|
XTDInputs tdInputs;
|
|
XFIInputs fiInputs;
|
|
XCTInputs ctInputs;
|
|
XCCInputs ccInputs;
|
|
XOBDInputs obdInputs;
|
|
XAMAInputs amaInputs;
|
|
XRSIInputs rsiInputs;
|
|
XCHLHInputs chlhInputs;
|
|
XCHMAInputs chmaInputs;
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Validate ...
|
|
virtual bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = tsInputs.IsValid();
|
|
if (!result) {
|
|
return result;
|
|
}
|
|
|
|
result = ctInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = ccInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = tmInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = lhInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = tdInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = fiInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = obdInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = amaInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = rsiInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = chlhInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = chmaInputs.IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
virtual void Clean()
|
|
{
|
|
//
|
|
tsInputs.Clean();
|
|
ctInputs.Clean();
|
|
ccInputs.Clean();
|
|
tmInputs.Clean();
|
|
lhInputs.Clean();
|
|
tdInputs.Clean();
|
|
fiInputs.Clean();
|
|
obdInputs.Clean();
|
|
amaInputs.Clean();
|
|
rsiInputs.Clean();
|
|
chlhInputs.Clean();
|
|
chmaInputs.Clean();
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
virtual void Default()
|
|
{
|
|
//
|
|
tsInputs.Default();
|
|
ctInputs.Default();
|
|
ccInputs.Default();
|
|
tmInputs.Default();
|
|
lhInputs.Default();
|
|
tdInputs.Default();
|
|
fiInputs.Default();
|
|
obdInputs.Default();
|
|
amaInputs.Default();
|
|
rsiInputs.Default();
|
|
chlhInputs.Default();
|
|
chmaInputs.Default();
|
|
}
|
|
|
|
//
|
|
// Max ...
|
|
virtual int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
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());
|
|
result = MathMax(result, fiInputs.Max());
|
|
result = MathMax(result, obdInputs.Max());
|
|
result = MathMax(result, amaInputs.Max());
|
|
result = MathMax(result, rsiInputs.Max());
|
|
result = MathMax(result, chlhInputs.Max());
|
|
result = MathMax(result, chmaInputs.Max());
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// X5 Provider Market Conditions ...
|
|
class X5MarketConditions : public XSCBaseProviderMarketConditions
|
|
{
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// Generate Score ...
|
|
virtual void GenerateScore(
|
|
double &bullishScore, // Bullish Score
|
|
double &bearishScore, // Bearish Score
|
|
const double multiplier = 1 // Score Multiplier
|
|
)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Generate Summary ...
|
|
virtual string GenerateSummary(
|
|
const double multiplier = 1, // Score Multiplier
|
|
const bool ignoreFalseConditions = true // Ignore False Conditions
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
|
|
//
|
|
// X5 Provider Class ...
|
|
class XSCX5Provider : public XSCBaseProvider
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
XSCXTSHelper *tsHelper;
|
|
XSCXFIHelper *fiHelper;
|
|
XSCXTDHelper *tdHelper;
|
|
XSCXLHHelper *lhHelper;
|
|
XSCXTMHelper *tmHelper;
|
|
XSCXCCHelper *ccHelper;
|
|
XSCXCTHelper *ctHelper;
|
|
XSCXOBDHelper *obdHelper;
|
|
XSCXRSIHelper *rsiHelper;
|
|
XSCXAMAHelper *amaHelper;
|
|
XSCXCHMAHelper *chmaHelper;
|
|
XSCXCHLHHelper *chlhHelper;
|
|
|
|
//
|
|
// Constructor ...
|
|
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();
|
|
}
|
|
|
|
//
|
|
// Properties Gettr(s) / Setter(s) ...
|
|
|
|
//
|
|
// Inheritance ...
|
|
|
|
//
|
|
// Init all Requirements ...
|
|
virtual bool Init(X5ProviderInputs &inputs)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate ...
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
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;
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
// Functions ...
|
|
|
|
//
|
|
virtual bool GetMarketConditions(
|
|
X5MarketConditions &conditions, // Market Conditions Result
|
|
int barIndex = 0 // Specified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Market For Signal ...
|
|
virtual bool HasSignal(
|
|
int barIndex,
|
|
XSignal &signal, // Hold's Signal if Exists ...
|
|
X5MarketConditions &conditions // Hold's Market Conditions ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
X5ProviderInputs mInputs;
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Tools ...
|
|
};
|