Files
xMQL5/BKPS/14030505/Test/x-saherelm.test.setup.mq5
2024-08-03 07:54:08 +03:30

1779 lines
39 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XTestSetup
// Description: provides implementation of Test
// Setup ...
//
//
// 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 "../Libraries/x-saherelm.xtrade.lib.mq5"
#include "../Classes/x-saherelm.xalert.class.mq5"
//
#include "../Helpers/x-saherelm.xrl.helper.mq5"
#include "../Helpers/x-saherelm.xmc.helper.mq5"
#include "../Helpers/x-saherelm.xpv.helper.mq5"
#include "../Helpers/x-saherelm.xtd.helper.mq5"
#include "../Helpers/x-saherelm.xhk.helper.mq5"
#include "../Helpers/x-saherelm.xsln.helper.mq5"
#include "../Helpers/x-saherelm.xstr.helper.mq5"
#include "../Helpers/x-saherelm.xche.helper.mq5"
#include "../Helpers/x-saherelm.xich.helper.mq5"
#include "../Helpers/x-saherelm.xmrb.helper.mq5"
#include "../Helpers/x-saherelm.xosc.helper.mq5"
#include "../Helpers/x-saherelm.xvlm.helper.mq5"
#include "../Helpers/x-saherelm.xhtd.helper.mq5"
#include "../Helpers/x-saherelm.xchma.helper.mq5"
#include "../Helpers/x-saherelm.xatsl.helper.mq5"
#include "../Helpers/x-saherelm.xdmnt.helper.mq5"
#include "../Helpers/x-saherelm.xasct.helper.mq5"
#include "../Helpers/x-saherelm.xsslc.helper.mq5"
#include "../Helpers/x-saherelm.xhull.helper.mq5"
#include "../Helpers/x-saherelm.xadxtd.helper.mq5"
//
struct XTestInputs
{
//
// Props ...
//
// Commons ...
string symbol; // Symbol
ENUM_TIMEFRAMES period; // Time Frame
//
double volume; //
double tpPoint; //
double slPoint; //
//
// Helpers Inputs ...
XRLInputs rlInputs; // XRL Inputs
XMCInputs mcInputs; // XMC Inputs
XPVInputs pvInputs; // XPV Inputs
XTDInputs tdInputs; // XTD Inputs
XHKInputs hkInputs; // XHK Inputs
XHTDInputs htdInputs; // XHTD Inputs
XCHEInputs cheInputs; // XCHE Inputs
XICHInputs ichInputs; // XICH Inputs
XSTRInputs strInputs; // XSTR Inputs
XMRBInputs mrbInputs; // XMRB Inputs
XOSCInputs oscInputs; // XOSC Inputs
XVLMInputs vlmInputs; // XVLM Inputs
XSLNInputs slnInputs; // XSLN Inputs
XCHMAInputs chmaInputs; // XCHMA Inputs
XATSLInputs atslInputs; // XATSL Inputs
XDMNTInputs dmntInputs; // XDMNT Inputs
XASCTInputs asctInputs; // XASCT Inputs
XSSLCInputs sslcInputs; // XSSLC Inputs
XHULLInputs hullInputs; // XHULL Inputs
XADXTDInputs adxtdInputs; // XADXTD Inputs
//
// Constructor ...
XTestInputs()
{
Clean();
}
//
// Tools ...
//
bool Init()
{
//
Default();
//
bool result = IsValid();
//
return result;
}
bool Init(
string _symbol, // Symbol
ENUM_TIMEFRAMES _period, // Time Frame
XRLInputs &_rlInputs, // XRL Inputs
XMCInputs &_mcInputs, // XMC Inputs
XPVInputs &_pvInputs, // XPV Inputs
XTDInputs &_tdInputs, // XTD Inputs
XHKInputs &_hkInputs, // XHK Inputs
XHTDInputs &_htdInputs, // XHTD Inputs
XCHEInputs &_cheInputs, // XCHE Inputs
XICHInputs &_ichInputs, // XICH Inputs
XSTRInputs &_strInputs, // XSTR Inputs
XMRBInputs &_mrbInputs, // XMRB Inputs
XOSCInputs &_oscInputs, // XOSC Inputs
XVLMInputs &_vlmInputs, // XVLM Inputs
XSLNInputs &_slnInputs, // XSLN Inputs
XCHMAInputs &_chmaInputs, // XCHMA Inputs
XATSLInputs &_atslInputs, // XATSL Inputs
XDMNTInputs &_dmntInputs, // XDMNT Inputs
XASCTInputs &_asctInputs, // XASCT Inputs
XSSLCInputs &_sslcInputs, // XSSLC Inputs
XHULLInputs &_hullInputs, // XHULL Inputs
XADXTDInputs &_adxtdInputs // XADXTD Inputs
)
{
//
this.symbol = _symbol;
this.period = _period;
//
// Helpers Inputs ...
this.rlInputs = _rlInputs;
this.mcInputs = _mcInputs;
this.pvInputs = _pvInputs;
this.tdInputs = _tdInputs;
this.hkInputs = _hkInputs;
this.htdInputs = _htdInputs;
this.cheInputs = _cheInputs;
this.ichInputs = _ichInputs;
this.strInputs = _strInputs;
this.mrbInputs = _mrbInputs;
this.oscInputs = _oscInputs;
this.vlmInputs = _vlmInputs;
this.chmaInputs = _chmaInputs;
this.atslInputs = _atslInputs;
this.dmntInputs = _dmntInputs;
this.asctInputs = _asctInputs;
this.sslcInputs = _sslcInputs;
this.hullInputs = _hullInputs;
this.adxtdInputs = _adxtdInputs;
//
bool result = IsValid();
//
return result;
}
//
// Cleanup ...
void Clean()
{
//
symbol = NULL;
period = NULL;
//
tpPoint = 0;
slPoint = 0;
//
rlInputs.Clean();
mcInputs.Clean();
pvInputs.Clean();
tdInputs.Clean();
hkInputs.Clean();
cheInputs.Clean();
ichInputs.Clean();
strInputs.Clean();
mrbInputs.Clean();
oscInputs.Clean();
vlmInputs.Clean();
slnInputs.Clean();
htdInputs.Clean();
chmaInputs.Clean();
asctInputs.Clean();
sslcInputs.Clean();
hullInputs.Clean();
atslInputs.Clean();
dmntInputs.Clean();
adxtdInputs.Clean();
}
//
// Default ...
void Default()
{
//
tpPoint = 0;
slPoint = 0;
//
rlInputs.Default();
mcInputs.Default();
pvInputs.Default();
tdInputs.Default();
hkInputs.Default();
cheInputs.Default();
ichInputs.Default();
strInputs.Default();
mrbInputs.Default();
oscInputs.Default();
vlmInputs.Default();
slnInputs.Default();
htdInputs.Default();
chmaInputs.Default();
asctInputs.Default();
sslcInputs.Default();
hullInputs.Default();
atslInputs.Default();
dmntInputs.Default();
adxtdInputs.Default();
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(symbol) &&
IsValid(period)
//
;
if (!result)
{
return result;
}
//
result = rlInputs.IsValid();
if (!result)
{
return result;
}
//
result = chmaInputs.IsValid();
if (!result)
{
return result;
}
//
result = tdInputs.IsValid();
if (!result)
{
return result;
}
//
result = slnInputs.IsValid();
if (!result)
{
return result;
}
//
result = pvInputs.IsValid();
if (!result)
{
return result;
}
//
result = hkInputs.IsValid();
if (!result)
{
return result;
}
//
result = cheInputs.IsValid();
if (!result)
{
return result;
}
//
result = ichInputs.IsValid();
if (!result)
{
return result;
}
//
result = strInputs.IsValid();
if (!result)
{
return result;
}
//
result = mrbInputs.IsValid();
if (!result)
{
return result;
}
//
result = oscInputs.IsValid();
if (!result)
{
return result;
}
//
result = vlmInputs.IsValid();
if (!result)
{
return result;
}
//
result = mcInputs.IsValid();
if (!result)
{
return result;
}
//
result = asctInputs.IsValid();
if (!result)
{
return result;
}
//
result = sslcInputs.IsValid();
if (!result)
{
return result;
}
//
result = hullInputs.IsValid();
if (!result)
{
return result;
}
//
result = adxtdInputs.IsValid();
if (!result)
{
return result;
}
//
result = htdInputs.IsValid();
if (!result)
{
return result;
}
//
result = atslInputs.IsValid();
if (!result)
{
return result;
}
//
result = dmntInputs.IsValid();
if (!result)
{
return result;
}
//
return result;
}
};
//
struct XTestConditions
{
//
// Props ...
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Conditions ...
XRLConditions rlConditions;
XMCConditions mcConditions;
XPVConditions pvConditions;
XTDConditions tdConditions;
XHKConditions hkConditions;
XCHEConditions cheConditions;
XICHConditions ichConditions;
XSTRConditions strConditions;
XMRBConditions mrbConditions;
XVLMConditions vlmConditions;
XHTDConditions htdConditions;
XSLNConditions slnConditions;
XCHMAConditions chmaConditions;
XATSLConditions atslConditions;
XASCTConditions asctConditions;
XSSLCConditions sslcConditions;
XHULLConditions hullConditions;
XDMNTConditions dmntConditions;
XADXTDConditions adxtdConditions;
//
// Oscillators ...
double cci[];
double rsi[];
double macd[];
double macdSignal[];
//
// Signal ...
//
// Conditions Provided Signal ...
XSignal signal;
//
// Signal Verifications ...
int pushers;
//
// Signal Providers ....
string providers[];
//
// Conditions Verifications ...
int longVerifications;
int shortVerifications;
//
void CleanSignal()
{
//
signal.Clean();
Clean(providers);
//
pushers = 0;
longVerifications = 0;
shortVerifications = 0;
}
//
// Generate Conditions Based Signals ...
bool GenerateSignal(
double &tp,
double &sl,
double volume,
double tpPoint,
double slPoint //
)
{
//
bool result = false;
//
bool hasLong = GenerateLongSignal(
tp,
sl,
volume,
tpPoint,
slPoint //
);
if (hasLong)
{
//
result = hasLong;
return result;
}
//
bool hasShort = GenerateShortSignal(
tp,
sl,
volume,
tpPoint,
slPoint //
);
if (hasShort)
{
//
result = hasShort;
return result;
}
//
return result;
}
//
bool GenerateLongSignal(
double &tp,
double &sl,
double volume,
double tpPoint,
double slPoint //
)
{
//
bool result = false;
//
double mTP = 0;
double mSL = 0;
double mR2R = 1.5;
double mEntry = 0;
//
ENUM_POSITION_TYPE mType = POSITION_TYPE_BUY;
ENUM_X_ORDER_MODES mMode = X_ORDER_MODE_MARKET;
//
mEntry = GetEntry(
symbol,
mType //
);
//
// XATRL ...
bool long1 =
//
// Start Conditions ...
(rlConditions.isVerifierSwitchedToBullish &&
rlConditions.isFastBullish &&
rlConditions.isSlowBearish &&
rlConditions.isFastOverSlow)
//
&&
//
// Verifications ...
// XSTR ...
(strConditions.isTrendBullish ||
strConditions.isTrendSwitchedToBullish)
//
&&
//
// XATSL ...
(atslConditions.isBullish ||
atslConditions.isSwitchedToBullish)
//
&&
//
// XHTD ...
(htdConditions.isBullish ||
htdConditions.isSwitchedToBullish)
//
&&
//
// XVLM ...
(vlmConditions.isVolumeBullish ||
vlmConditions.isVolumeChangedToBullish)
//
&&
//
// XCHE ...
(cheConditions.isBullish ||
cheConditions.isStrongBullish ||
cheConditions.isSwitchedToBullish ||
cheConditions.isStrongSwitchedToBullish)
//
&&
//
// XHK ...
(hkConditions.isHKBullish ||
hkConditions.isSMHKBullish ||
hkConditions.isHKSwitchedToBullish ||
hkConditions.isSMHKSwitchedToBullish)
//
;
if (long1)
{
//
Add(
"XATRL",
providers //
);
//
pushers++;
//
// Calculate TP and SL ...
//
mSL = atslConditions.atsl[1];
//
double risk = MathAbs(mSL - mEntry);
double reward = risk * mR2R;
//
mTP = mEntry + reward;
//
tp = mTP;
sl = mSL;
}
//
result =
//
long1
//
;
if (result)
{
//
result = signal.Prepare(
symbol,
"XATRL",
period,
mType,
mMode,
mEntry,
volume,
0, // mSL,
mTP //
);
// if (result)
// {
// //
// XSignal opposit;
// bool canSupport = signal.GenerateOpposit(opposit);
// if (canSupport)
// {
// //
// AddRef(
// opposit,
// signal.supports //
// );
// }
// }
}
//
return result;
}
//
bool GenerateShortSignal(
double &tp,
double &sl,
double volume,
double tpPoint,
double slPoint //
)
{
//
bool result = false;
//
return result;
//
double mTP = 0;
double mSL = 0;
double mR2R = 1.5;
double mEntry = 0;
//
ENUM_POSITION_TYPE mType = POSITION_TYPE_SELL;
ENUM_X_ORDER_MODES mMode = X_ORDER_MODE_MARKET;
//
mEntry = GetEntry(
symbol,
mType //
);
//
// XATRL ...
bool long1 =
//
(rlConditions.isVerifierSwitchedToBullish &&
rlConditions.isFastBullish &&
rlConditions.isSlowBearish &&
rlConditions.isFastOverSlow &&
atslConditions.isBullish)
//
;
if (long1)
{
//
Add(
"XATRL",
providers //
);
//
pushers++;
//
// Calculate TP and SL ...
//
mSL = atslConditions.atsl[1];
//
double risk = MathAbs(mSL - mEntry);
double reward = risk * mR2R;
//
mSL = mEntry + risk;
mTP = mEntry - reward;
//
tp = mTP;
sl = mSL;
}
//
result =
//
long1
//
;
if (result)
{
//
result = signal.Prepare(
symbol,
"XATRL",
period,
mType,
mMode,
mEntry,
volume,
mSL,
mTP //
);
}
//
return result;
}
//
// Generate Supports ...
// TODO:
//
// Tools ...
//
// Cleanup ...
void Clean()
{
//
time = NULL;
symbol = NULL;
period = NULL;
//
Clean(cci);
Clean(rsi);
Clean(macd);
Clean(macdSignal);
//
rlConditions.Clean();
mcConditions.Clean();
tdConditions.Clean();
hkConditions.Clean();
cheConditions.Clean();
ichConditions.Clean();
strConditions.Clean();
mrbConditions.Clean();
vlmConditions.Clean();
slnConditions.Clean();
htdConditions.Clean();
chmaConditions.Clean();
atslConditions.Clean();
asctConditions.Clean();
sslcConditions.Clean();
hullConditions.Clean();
dmntConditions.Clean();
adxtdConditions.Clean();
//
CleanSignal();
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
double tempBullishScore = 0;
double tempBearishScore = 0;
//
rlConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
mcConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
pvConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
slnConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
adxtdConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
strConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
cheConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
asctConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
tdConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
ichConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
hkConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
mrbConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
vlmConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
sslcConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
chmaConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
hullConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
htdConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
atslConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
dmntConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string pvSummary = pvConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string rlSummary = rlConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string mcSummary = mcConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string tdSummary = tdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string hkSummary = hkConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string strSummary = strConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string cheSummary = cheConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string ichSummary = ichConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string mrbSummary = mrbConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string vlmSummary = vlmConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string slnSummary = slnConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string htdSummary = htdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string chmaSummary = chmaConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string atslSummary = atslConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string asctSummary = asctConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string sslcSummary = sslcConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string hullSummary = hullConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string dmntSummary = dmntConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string adxtdSummary = adxtdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
//
string conditionsStr =
//
pvSummary + separator +
rlSummary + separator +
mcSummary + separator +
tdSummary + separator +
hkSummary + separator +
ichSummary + separator +
mrbSummary + separator +
vlmSummary + separator +
slnSummary + separator +
strSummary + separator +
cheSummary + separator +
asctSummary + separator +
sslcSummary + separator +
hullSummary + separator +
adxtdSummary + separator +
htdSummary + separator +
atslSummary + separator +
dmntSummary + separator +
chmaSummary + separator +
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XTestSetup";
}
//
};
//
// Class ...
class XSCXTestSetup : public XSCBaseAlert
{
//
// Public ...
public:
//
// Props ...
XSCXRLHelper *rlHelper;
XSCXMCHelper *mcHelper;
XSCXPVHelper *pvHelper;
XSCXTDHelper *tdHelper;
XSCXHKHelper *hkHelper;
XSCXCHEHelper *cheHelper;
XSCXICHHelper *ichHelper;
XSCXSTRHelper *strHelper;
XSCXMRBHelper *mrbHelper;
XSCXOSCHelper *oscHelper;
XSCXVLMHelper *vlmHelper;
XSCXSLNHelper *slnHelper;
XSCXHTDHelper *hdtHelper;
XSCXASCTHelper *asctHelper;
XSCXSSLCHelper *sslcHelper;
XSCXHULLHelper *hullHelper;
XSCXATSLHelper *atslHelper;
XSCXCHMAHelper *chmaHelper;
XSCXDMNTHelper *dmntHelper;
XSCXADXTDHelper *adxtdHelper;
//
XBarTracker barTracker;
//
// Constructor(s) ...
void XSCXTestSetup() {}
//
// Deconstructor ...
void ~XSCXTestSetup()
{
//
delete rlHelper;
delete mcHelper;
delete pvHelper;
delete tdHelper;
delete hkHelper;
delete cheHelper;
delete ichHelper;
delete strHelper;
delete mrbHelper;
delete oscHelper;
delete vlmHelper;
delete hdtHelper;
delete asctHelper;
delete sslcHelper;
delete hullHelper;
delete atslHelper;
delete chmaHelper;
delete dmntHelper;
delete adxtdHelper;
}
//
// Initializer ...
bool Init(
XTestInputs &_inputs // Configurations
)
{
//
bool result = false;
//
result = _inputs.IsValid();
if (!result)
{
return result;
}
//
inputs = _inputs;
//
// Initialize Helpers ...
//
// XRL ...
rlHelper = new XSCXRLHelper();
result = rlHelper.Init(
inputs.symbol,
inputs.period,
inputs.rlInputs //
);
if (!result)
{
return result;
}
//
// XPV ...
pvHelper = new XSCXPVHelper();
result = pvHelper.Init(
inputs.symbol,
inputs.period,
inputs.pvInputs //
);
if (!result)
{
return result;
}
//
// XCHMA ...
chmaHelper = new XSCXCHMAHelper();
result = chmaHelper.Init(
inputs.symbol,
inputs.period,
inputs.chmaInputs //
);
if (!result)
{
return result;
}
//
// XSLN ...
slnHelper = new XSCXSLNHelper();
result = slnHelper.Init(
inputs.symbol,
inputs.period,
inputs.slnInputs //
);
if (!result)
{
return result;
}
//
// XTD ...
tdHelper = new XSCXTDHelper();
result = tdHelper.Init(
inputs.symbol,
inputs.period,
inputs.tdInputs //
);
if (!result)
{
return result;
}
//
// XHTD ...
hdtHelper = new XSCXHTDHelper();
result = hdtHelper.Init(
inputs.symbol,
inputs.period,
inputs.htdInputs //
);
if (!result)
{
return result;
}
//
// XATSL ...
atslHelper = new XSCXATSLHelper();
result = atslHelper.Init(
inputs.symbol,
inputs.period,
inputs.atslInputs //
);
if (!result)
{
return result;
}
//
// XDMNT ...
dmntHelper = new XSCXDMNTHelper();
result = dmntHelper.Init(
inputs.symbol,
inputs.period,
inputs.dmntInputs //
);
if (!result)
{
return result;
}
//
// XHK ...
hkHelper = new XSCXHKHelper();
result = hkHelper.Init(
inputs.symbol,
inputs.period,
inputs.hkInputs //
);
if (!result)
{
return result;
}
//
// XCHE ...
cheHelper = new XSCXCHEHelper();
result = cheHelper.Init(
inputs.symbol,
inputs.period,
inputs.cheInputs //
);
if (!result)
{
return result;
}
//
// XICH ...
ichHelper = new XSCXICHHelper();
result = ichHelper.Init(
inputs.symbol,
inputs.period,
inputs.ichInputs //
);
if (!result)
{
return result;
}
//
// XSTR ...
strHelper = new XSCXSTRHelper();
result = strHelper.Init(
inputs.symbol,
inputs.period,
inputs.strInputs //
);
if (!result)
{
return result;
}
//
// XMRB ...
mrbHelper = new XSCXMRBHelper();
result = mrbHelper.Init(
inputs.symbol,
inputs.period,
inputs.mrbInputs //
);
if (!result)
{
return result;
}
//
// XOSC ...
oscHelper = new XSCXOSCHelper();
result = oscHelper.Init(
inputs.symbol,
inputs.period,
inputs.oscInputs //
);
if (!result)
{
return result;
}
//
// XVLM ...
vlmHelper = new XSCXVLMHelper();
result = vlmHelper.Init(
inputs.symbol,
inputs.period,
inputs.vlmInputs //
);
if (!result)
{
return result;
}
//
// XMC ...
mcHelper = new XSCXMCHelper();
result = mcHelper.Init(
inputs.symbol,
inputs.period,
inputs.mcInputs //
);
if (!result)
{
return result;
}
//
// XASCT ...
asctHelper = new XSCXASCTHelper();
result = asctHelper.Init(
inputs.symbol,
inputs.period,
inputs.asctInputs //
);
if (!result)
{
return result;
}
//
// XSSLC ...
sslcHelper = new XSCXSSLCHelper();
result = sslcHelper.Init(
inputs.symbol,
inputs.period,
inputs.sslcInputs //
);
if (!result)
{
return result;
}
//
// XHULL ...
hullHelper = new XSCXHULLHelper();
result = hullHelper.Init(
inputs.symbol,
inputs.period,
inputs.hullInputs //
);
if (!result)
{
return result;
}
//
// XADXTD ...
adxtdHelper = new XSCXADXTDHelper();
result = adxtdHelper.Init(
inputs.symbol,
inputs.period,
inputs.adxtdInputs //
);
if (!result)
{
return result;
}
//
// Initial Bar Tracker ...
result = barTracker.Init(
inputs.symbol,
inputs.period //
);
if (!result)
{
return result;
}
//
return result;
}
//
// Getter(s) / Setter(s) ...
//
string GetSymbol()
{
return inputs.symbol;
}
//
ENUM_TIMEFRAMES GetPeriod()
{
return inputs.period;
}
//
XTestInputs GetInputs()
{
return inputs;
}
//
bool SetInputs(
XTestInputs &_inputs // Configurations
)
{
return Init(_inputs);
}
//
// Tools ...
//
// Retrieve Conditions ...
bool GetConditions(
XTestConditions &conditions, //
int barIndex = 0, //
int loopback = 5 //
)
{
//
bool result = false;
//
conditions.Clean();
//
conditions.symbol = GetSymbol();
conditions.period = GetPeriod();
conditions.time = TimeCurrent();
//
// Checking Can Process Bar ...
result = barTracker.CanProcessBar();
if (!result)
{
return result;
}
//
result = rlHelper.GetConditions(
conditions.rlConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = hdtHelper.GetConditions(
conditions.htdConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = slnHelper.GetConditions(
conditions.slnConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = chmaHelper.GetConditions(
conditions.chmaConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = atslHelper.GetConditions(
conditions.atslConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = dmntHelper.GetConditions(
conditions.dmntConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = pvHelper.GetConditions(
conditions.pvConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = tdHelper.GetConditions(
conditions.tdConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = hkHelper.GetConditions(
conditions.hkConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = cheHelper.GetConditions(
conditions.cheConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = ichHelper.GetConditions(
conditions.ichConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = strHelper.GetConditions(
conditions.strConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = mrbHelper.GetConditions(
conditions.mrbConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = mcHelper.GetConditions(
conditions.mcConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = asctHelper.GetConditions(
conditions.asctConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = vlmHelper.GetConditions(
conditions.vlmConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = sslcHelper.GetConditions(
conditions.sslcConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = hullHelper.GetConditions(
conditions.hullConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = adxtdHelper.GetConditions(
conditions.adxtdConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
oscHelper.CopyCCI(
barIndex,
loopback,
conditions.cci //
);
oscHelper.CopyRSI(
barIndex,
loopback,
conditions.rsi //
);
oscHelper.CopyMACD(
barIndex,
loopback,
conditions.macd //
);
oscHelper.CopyMACDSignal(
barIndex,
loopback,
conditions.macdSignal //
);
//
// Generating Signal ...
double mTP = 0;
double mSL = 0;
bool hasSignal = conditions.GenerateSignal(
mTP,
mSL,
inputs.volume,
inputs.tpPoint,
inputs.slPoint //
);
if (hasSignal)
{
barTracker.Waits();
}
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XTestInputs inputs; // Setup Configurations ...
};
//