2782 lines
62 KiB
Plaintext
2782 lines
62 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCX121Setup
|
|
// Description: provides implementation of X121
|
|
// 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"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
enum ENUM_X121_SIGNAL_PROVIDER
|
|
{
|
|
//
|
|
PROVIDER_UNKNOWN = 0,
|
|
PROVIDER_XCHMA_CROSS = 1,
|
|
};
|
|
|
|
//
|
|
string ToString(ENUM_X121_SIGNAL_PROVIDER value)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
string vStr = EnumToString(value);
|
|
if (!IsValid(vStr))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string parts[];
|
|
int partsCount = SplitContent(
|
|
parts,
|
|
vStr,
|
|
"_"
|
|
//
|
|
);
|
|
if (partsCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool hasLastPart = GetLastItem(
|
|
result,
|
|
parts
|
|
//
|
|
);
|
|
if (!hasLastPart)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDER FromString(string value)
|
|
{
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDER result = PROVIDER_UNKNOWN;
|
|
|
|
//
|
|
if (!IsValid(value))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (Contains(value, (EnumToString(PROVIDER_XCHMA_CROSS))))
|
|
{
|
|
result = PROVIDER_XCHMA_CROSS;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
struct X121SetupInputs
|
|
{
|
|
//
|
|
// Commons ...
|
|
string symbol; // Symbol
|
|
ENUM_TIMEFRAMES period; // Time Frame
|
|
|
|
//
|
|
// 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 ...
|
|
void X121SetupInputs()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
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.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;
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
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();
|
|
atslInputs.Clean();
|
|
asctInputs.Clean();
|
|
sslcInputs.Clean();
|
|
hullInputs.Clean();
|
|
dmntInputs.Clean();
|
|
adxtdInputs.Clean();
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
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();
|
|
atslInputs.Default();
|
|
asctInputs.Default();
|
|
sslcInputs.Default();
|
|
hullInputs.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 = 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 = chmaInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = atslInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = dmntInputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Conditions ...
|
|
struct X121SetupConditions
|
|
{
|
|
//
|
|
// 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[];
|
|
|
|
//
|
|
// 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();
|
|
}
|
|
|
|
//
|
|
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;
|
|
|
|
//
|
|
hullConditions.GenerateScore(
|
|
tempBullishScore,
|
|
tempBearishScore //
|
|
);
|
|
bullishScore += tempBullishScore;
|
|
bearishScore += tempBearishScore;
|
|
|
|
//
|
|
htdConditions.GenerateScore(
|
|
tempBullishScore,
|
|
tempBearishScore //
|
|
);
|
|
bullishScore += tempBullishScore;
|
|
bearishScore += tempBearishScore;
|
|
|
|
//
|
|
atslConditions.GenerateScore(
|
|
tempBullishScore,
|
|
tempBearishScore //
|
|
);
|
|
bullishScore += tempBullishScore;
|
|
bearishScore += tempBearishScore;
|
|
|
|
//
|
|
chmaConditions.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;
|
|
}
|
|
|
|
//
|
|
// Add Combine Conditions ...
|
|
|
|
//
|
|
bool IsTrendBullish()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
(strConditions.isTrendSwitchedToBullish &&
|
|
slnConditions.isBullish &&
|
|
htdConditions.isBullish &&
|
|
atslConditions.isBullish &&
|
|
cheConditions.isStrongBullish)
|
|
//
|
|
||
|
|
//
|
|
(slnConditions.isSwitchedToBullish &&
|
|
strConditions.isTrendBullish &&
|
|
htdConditions.isBullish &&
|
|
atslConditions.isBullish &&
|
|
cheConditions.isStrongBullish)
|
|
//
|
|
||
|
|
//
|
|
(htdConditions.isSwitchedToBullish &&
|
|
strConditions.isTrendBullish &&
|
|
slnConditions.isBullish &&
|
|
atslConditions.isBullish &&
|
|
cheConditions.isStrongBullish)
|
|
//
|
|
||
|
|
//
|
|
(atslConditions.isSwitchedToBullish &&
|
|
strConditions.isTrendBullish &&
|
|
htdConditions.isBullish &&
|
|
slnConditions.isBullish &&
|
|
cheConditions.isStrongBullish)
|
|
//
|
|
||
|
|
//
|
|
(cheConditions.isStrongSwitchedToBullish &&
|
|
strConditions.isTrendBullish &&
|
|
htdConditions.isBullish &&
|
|
slnConditions.isBullish &&
|
|
atslConditions.isBullish)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsTrendBearish()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
(strConditions.isTrendSwitchedToBearish &&
|
|
slnConditions.isBearish &&
|
|
htdConditions.isBearish &&
|
|
atslConditions.isBearish &&
|
|
cheConditions.isStrongBearish)
|
|
//
|
|
||
|
|
//
|
|
(slnConditions.isSwitchedToBearish &&
|
|
strConditions.isTrendBearish &&
|
|
htdConditions.isBearish &&
|
|
atslConditions.isBearish &&
|
|
cheConditions.isStrongBearish)
|
|
//
|
|
||
|
|
//
|
|
(htdConditions.isSwitchedToBearish &&
|
|
strConditions.isTrendBearish &&
|
|
slnConditions.isBearish &&
|
|
atslConditions.isBearish &&
|
|
cheConditions.isStrongBearish)
|
|
//
|
|
||
|
|
//
|
|
(atslConditions.isSwitchedToBearish &&
|
|
strConditions.isTrendBearish &&
|
|
htdConditions.isBearish &&
|
|
slnConditions.isBearish &&
|
|
cheConditions.isStrongBearish)
|
|
//
|
|
||
|
|
//
|
|
(cheConditions.isStrongSwitchedToBearish &&
|
|
strConditions.isTrendBearish &&
|
|
htdConditions.isBearish &&
|
|
slnConditions.isBearish &&
|
|
atslConditions.isBearish)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return "X121Setup";
|
|
}
|
|
};
|
|
|
|
//
|
|
// Condition Parser ...
|
|
struct X121SignalGenerator
|
|
{
|
|
//
|
|
// Symbol Parser Instance ...
|
|
XSymbolParser symbolParser;
|
|
|
|
//
|
|
// Constructor ...
|
|
void X121SignalGenerator()
|
|
{
|
|
}
|
|
|
|
//
|
|
// Check Conditions for Generating Possible Signals ...
|
|
bool HasSignal(
|
|
X121SetupConditions &conditions, // Conditions
|
|
XSignal &signal, // Signal if Exists
|
|
int &pusher, // Pushers
|
|
string &provider, // Signal Provider Name
|
|
double &tp, // Provided TP
|
|
double &sl, // Provided SL
|
|
bool _useSupport, // Generate Support Signals
|
|
bool _allowLong, // Allow Long Signals
|
|
bool _allowShort, // Allow Short Signals
|
|
double _volume = 0.01, // Volume
|
|
double _slPoint = 0, // SL Point
|
|
bool _ignoreSL = false, // Ignore Calculated SL
|
|
double _tpPoint = 30, // TP Point
|
|
bool _ignoreTP = false // Ignore Calculated TP
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
signal.Clean();
|
|
|
|
//
|
|
result = _allowLong || _allowShort;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool hasLong = false;
|
|
bool hasShort = false;
|
|
|
|
//
|
|
if (_allowLong)
|
|
{
|
|
//
|
|
hasLong =
|
|
HasLongConditions(
|
|
conditions,
|
|
pusher,
|
|
provider,
|
|
tp,
|
|
sl //
|
|
);
|
|
|
|
//
|
|
if (hasLong)
|
|
{
|
|
//
|
|
hasLong = FilterLongConditions(
|
|
conditions,
|
|
pusher,
|
|
provider //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_allowShort && !hasLong)
|
|
{
|
|
//
|
|
hasShort =
|
|
HasShortConditions(
|
|
conditions,
|
|
pusher,
|
|
provider,
|
|
tp,
|
|
sl //
|
|
);
|
|
|
|
//
|
|
if (hasShort)
|
|
{
|
|
//
|
|
hasShort = FilterShortConditions(
|
|
conditions,
|
|
pusher,
|
|
provider //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
result = hasLong || hasShort;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string mProvider =
|
|
IsValid(provider)
|
|
? provider
|
|
: GetTag();
|
|
|
|
//
|
|
// Prepare Signals ...
|
|
ENUM_POSITION_TYPE mType =
|
|
hasLong
|
|
? POSITION_TYPE_BUY
|
|
: POSITION_TYPE_SELL;
|
|
|
|
//
|
|
double mEntry = GetEntry(
|
|
conditions.symbol,
|
|
mType //
|
|
);
|
|
|
|
//
|
|
double mSL = 0;
|
|
double mTP = 0;
|
|
double mPointValue =
|
|
GetPoints(conditions.symbol);
|
|
result = CalculateTPSLByPoint(
|
|
mSL,
|
|
mTP,
|
|
mType,
|
|
mEntry,
|
|
mPointValue,
|
|
1,
|
|
_slPoint,
|
|
_tpPoint //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = signal.Prepare(
|
|
conditions.symbol,
|
|
mProvider,
|
|
conditions.period,
|
|
mType,
|
|
X_ORDER_MODE_MARKET,
|
|
mEntry,
|
|
_volume,
|
|
_ignoreSL
|
|
? 0
|
|
: mSL,
|
|
_ignoreTP
|
|
? 0
|
|
: mTP //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Long Specified Functions ...
|
|
|
|
//
|
|
// Check Market Conditions for Long Signals ...
|
|
bool HasLongConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int &pusher, // Pushers
|
|
string &provider, // Provider
|
|
double &tp, // Provided TP
|
|
double &sl // Provided SL
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
tp = 0;
|
|
sl = 0;
|
|
pusher = 0;
|
|
|
|
//
|
|
bool isOSCShortVerified = IsOSCShortVerified(conditions);
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
// XCHMA ...
|
|
|
|
//
|
|
// XCHMACROSS ...
|
|
// When Fast Crossed Over Slow ...
|
|
bool cond1 =
|
|
//
|
|
// Start Conditions ...
|
|
conditions.chmaConditions.isFastCrossedOverSlow &&
|
|
//
|
|
// Verifications ...
|
|
conditions.chmaConditions.isCLoseOverFast
|
|
//
|
|
;
|
|
if (cond1)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCHMA_CROSS);
|
|
|
|
//
|
|
// TP/SL ...
|
|
}
|
|
|
|
//
|
|
// XCHMARETEST ...
|
|
// When Retest Upper Line and Close Over it ...
|
|
|
|
//
|
|
result =
|
|
//
|
|
pusher >= 1 &&
|
|
(
|
|
//
|
|
cond1
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Filter Long Conditions ...
|
|
bool FilterLongConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int pusher, // Pushers
|
|
string provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Generating Conditions Score ...
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
bool isGBPUSD = symbolParser.IsGBPUSD(conditions.symbol);
|
|
|
|
//
|
|
bool isM5Period = conditions.period == PERIOD_M5;
|
|
bool isM15Period = conditions.period == PERIOD_M15;
|
|
bool isH1Period = conditions.period == PERIOD_H1;
|
|
bool isH4Period = conditions.period == PERIOD_H4;
|
|
|
|
//
|
|
// Set Default Result to True ...
|
|
result = true;
|
|
|
|
// //
|
|
// result =
|
|
// //
|
|
// result &&
|
|
// !(
|
|
// //
|
|
// //
|
|
// )
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Apply Filter ...
|
|
// Based On Symbol and Period ...
|
|
// if necessary ...
|
|
if (isGBPUSD)
|
|
{
|
|
//
|
|
// MEDIUM ...
|
|
if (isH1Period)
|
|
{
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve Long Verifications ...
|
|
bool HasLongVerifications(
|
|
X121SetupConditions &conditions[] // Conditions Collection
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int count = ArraySize(conditions);
|
|
result = IsValidSize(count);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Loop through Conditions to Get Verifications ...
|
|
for (int i = count - 1; i >= 0; i--)
|
|
{
|
|
//
|
|
X121SetupConditions iConditions = conditions[i];
|
|
|
|
//
|
|
result = IsConditionsValidForLong(iConditions);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Count Number of Long Validations ...
|
|
int CountLongValidations(
|
|
X121SetupConditions &conditions // Conditions
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// 1
|
|
// XTD ...
|
|
bool isTDPassed =
|
|
//
|
|
conditions.tdConditions.isBullish ||
|
|
conditions.tdConditions.isSwitchedToBullish
|
|
//
|
|
;
|
|
if (isTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 2
|
|
// XHK ...
|
|
bool isHKPassed =
|
|
//
|
|
(conditions.hkConditions.isHKBullish ||
|
|
conditions.hkConditions.isHKSwitchedToBullish)
|
|
//
|
|
||
|
|
//
|
|
(conditions.hkConditions.isSMHKBullish ||
|
|
conditions.hkConditions.isSMHKSwitchedToBullish)
|
|
//
|
|
;
|
|
if (isHKPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 3
|
|
// XCHE ...
|
|
bool isCHEPassed =
|
|
//
|
|
conditions.cheConditions.isBullish ||
|
|
conditions.cheConditions.isStrongBullish ||
|
|
conditions.cheConditions.isSwitchedToBullish ||
|
|
conditions.cheConditions.isStrongSwitchedToBullish
|
|
//
|
|
;
|
|
if (isCHEPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 4
|
|
// XICH ...
|
|
bool isICHPassed =
|
|
//
|
|
(conditions.ichConditions.isTenkanSenOverKijunSen ||
|
|
conditions.ichConditions.isTenkanSenCrossedOverKijunSen)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.ichConditions.isSenkouSpanAOverB ||
|
|
conditions.ichConditions.isSenkouSpanAOverLast ||
|
|
conditions.ichConditions.isSenkouSpanACrossedOverB ||
|
|
conditions.ichConditions.isSenkouSpanACrossedOverLast)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.ichConditions.isFutureSenkouSpanAOverB ||
|
|
conditions.ichConditions.isFutureSenkouSpanAOverLast ||
|
|
conditions.ichConditions.isFutureSenkouSpanACrossedOverB ||
|
|
conditions.ichConditions.isFutureSenkouSpanACrossedOverLast)
|
|
//
|
|
;
|
|
if (isICHPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 5
|
|
// XSTR ...
|
|
bool isSTRPassed =
|
|
//
|
|
conditions.strConditions.isTrendBullish ||
|
|
conditions.strConditions.isTrendSwitchedToBullish
|
|
//
|
|
;
|
|
if (isSTRPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 6
|
|
// XMRB ...
|
|
bool isMRBPassed =
|
|
//
|
|
conditions.mrbConditions.isFastOverSlow ||
|
|
conditions.mrbConditions.isFastCrossedOverSlow
|
|
//
|
|
;
|
|
if (isMRBPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 7
|
|
// XVLM ...
|
|
bool isVLMPassed =
|
|
//
|
|
conditions.vlmConditions.isVolumeBullish ||
|
|
conditions.vlmConditions.isVolumeOverLast ||
|
|
conditions.vlmConditions.isVolumeChangedToBullish
|
|
//
|
|
;
|
|
if (isVLMPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 8
|
|
// XSSLC ...
|
|
bool isSSLCPassed =
|
|
//
|
|
conditions.sslcConditions.isBullish ||
|
|
conditions.sslcConditions.isSwitchedToBullish
|
|
//
|
|
;
|
|
if (isSSLCPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 9
|
|
// XHULL ...
|
|
bool isHULLPassed =
|
|
//
|
|
conditions.hullConditions.isBullish ||
|
|
conditions.hullConditions.isUpBullish ||
|
|
conditions.hullConditions.isDownBullish ||
|
|
conditions.hullConditions.isSwitchedToBullish
|
|
//
|
|
;
|
|
if (isHULLPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 10
|
|
// XADX ...
|
|
bool isADXTDPassed =
|
|
//
|
|
conditions.adxtdConditions.isBullish ||
|
|
conditions.adxtdConditions.isSwitchedToBullish ||
|
|
conditions.adxtdConditions.isStrongSwitchedToBullish
|
|
//
|
|
;
|
|
if (isADXTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 11
|
|
// XMC ...
|
|
bool isMCPassed =
|
|
//
|
|
((conditions.mcConditions.isBullish ||
|
|
conditions.mcConditions.isSwitchedToBullish)
|
|
//
|
|
||
|
|
//
|
|
((conditions.mcConditions.isFastOverVerifier ||
|
|
conditions.mcConditions.isFastCrossedOverVerifier)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.mcConditions.isSlowOverVerifier ||
|
|
conditions.mcConditions.isSlowCrossedOverVerifier)))
|
|
//
|
|
||
|
|
//
|
|
(conditions.mcConditions.isSARBullish ||
|
|
conditions.mcConditions.isSARSwitchedToBullish)
|
|
//
|
|
;
|
|
if (isMCPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 12
|
|
// XSLN ...
|
|
bool isXSLNPassed =
|
|
//
|
|
(conditions.slnConditions.isBullish ||
|
|
conditions.slnConditions.isSwitchedToBullish)
|
|
//
|
|
;
|
|
if (isXSLNPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 13
|
|
// XHTD ...
|
|
bool isXHTDPassed =
|
|
//
|
|
(conditions.htdConditions.isBullish ||
|
|
conditions.htdConditions.isSwitchedToBullish)
|
|
//
|
|
;
|
|
if (isXHTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 14
|
|
// XATSL ...
|
|
bool isXATSLPassed =
|
|
//
|
|
(conditions.atslConditions.isBullish ||
|
|
conditions.atslConditions.isSwitchedToBullish)
|
|
//
|
|
;
|
|
if (isXATSLPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsConditionsValidForLong(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int verifications = 10 // Number of Verifications
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int signs = CountLongValidations(conditions);
|
|
|
|
//
|
|
result =
|
|
//
|
|
verifications <= 0
|
|
? signs > 0
|
|
: signs >= verifications
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve OSC Based Long Verifications ...
|
|
bool IsOSCLongVerified(
|
|
X121SetupConditions &conditions // Conditions
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
result =
|
|
//
|
|
// CCI ...
|
|
conditions.cci[cIndex] < 96 &&
|
|
conditions.cci[cIndex] > conditions.cci[pIndex]
|
|
//
|
|
&&
|
|
//
|
|
// RSI ...
|
|
conditions.rsi[cIndex] < 70 &&
|
|
conditions.rsi[cIndex] > conditions.rsi[pIndex]
|
|
//
|
|
&&
|
|
//
|
|
// MACD ...
|
|
conditions.macd[cIndex] > 0 &&
|
|
conditions.macdSignal[cIndex] > 0 &&
|
|
conditions.macd[cIndex] > conditions.macdSignal[cIndex]
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Short Specified Functions ...
|
|
|
|
//
|
|
// Check Market Conditions for Short Signals ...
|
|
bool HasShortConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int &pusher, // Pushers
|
|
string &provider, // Provider
|
|
double &tp, // Provided TP
|
|
double &sl // Provided SL
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
tp = 0;
|
|
sl = 0;
|
|
pusher = 0;
|
|
|
|
//
|
|
bool isOSCLongVerified = IsOSCLongVerified(conditions);
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
// XCHAM ...
|
|
|
|
//
|
|
// XCHMACROSS ...
|
|
// When Fast Crossed Under Slow ...
|
|
bool cond1 =
|
|
//
|
|
// Start Conditions ...
|
|
conditions.chmaConditions.isFastCrossedUnderSlow &&
|
|
//
|
|
// Verifications ...
|
|
conditions.chmaConditions.isCLoseUnderFast
|
|
//
|
|
;
|
|
if (cond1)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCHMA_CROSS);
|
|
|
|
//
|
|
// TP/SL ...
|
|
}
|
|
|
|
//
|
|
// XCHMARETEST ...
|
|
// When Retest Lower Line and Close Over it ...
|
|
|
|
//
|
|
result =
|
|
//
|
|
pusher >= 1 &&
|
|
(
|
|
//
|
|
cond1
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Filter Short Conditions ...
|
|
bool FilterShortConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int pusher, // Pushers
|
|
string provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Generating Conditions Score ...
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
bool isGBPUSD = symbolParser.IsGBPUSD(conditions.symbol);
|
|
|
|
//
|
|
bool isM5Period = conditions.period == PERIOD_M5;
|
|
bool isM15Period = conditions.period == PERIOD_M15;
|
|
bool isH1Period = conditions.period == PERIOD_H1;
|
|
bool isH4Period = conditions.period == PERIOD_H4;
|
|
|
|
//
|
|
// Set Default Result to True ...
|
|
result = true;
|
|
|
|
// //
|
|
// result =
|
|
// //
|
|
// result &&
|
|
// !(
|
|
// //
|
|
// //
|
|
// )
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Apply Filter ...
|
|
// Based On Symbol and Period ...
|
|
// if necessary ...
|
|
if (isGBPUSD)
|
|
{
|
|
//
|
|
// MEDIUM ...
|
|
if (isH1Period)
|
|
{
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve Short Verifications ...
|
|
bool HasShortVerifications(
|
|
X121SetupConditions &conditions[] // Conditions Collection
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int count = ArraySize(conditions);
|
|
result = IsValidSize(count);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Loop through Conditions to Get Verifications ...
|
|
for (int i = count - 1; i >= 0; i--)
|
|
{
|
|
//
|
|
X121SetupConditions iConditions = conditions[i];
|
|
|
|
//
|
|
result = IsConditionsValidForShort(iConditions);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int CountShortValidations(
|
|
X121SetupConditions &conditions // Conditions
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// 1
|
|
// XTD ...
|
|
bool isTDPassed =
|
|
//
|
|
conditions.tdConditions.isBearish ||
|
|
conditions.tdConditions.isSwitchedToBearish
|
|
//
|
|
;
|
|
if (isTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 2
|
|
// XHK ...
|
|
bool isHKPassed =
|
|
//
|
|
(conditions.hkConditions.isHKBearish ||
|
|
conditions.hkConditions.isHKSwitchedToBearish)
|
|
//
|
|
||
|
|
//
|
|
(conditions.hkConditions.isSMHKBearish ||
|
|
conditions.hkConditions.isSMHKSwitchedToBearish)
|
|
//
|
|
;
|
|
if (isHKPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 3
|
|
// XCHE ...
|
|
bool isCHEPassed =
|
|
//
|
|
conditions.cheConditions.isBearish ||
|
|
conditions.cheConditions.isStrongBearish ||
|
|
conditions.cheConditions.isSwitchedToBearish ||
|
|
conditions.cheConditions.isStrongSwitchedToBearish
|
|
//
|
|
;
|
|
if (isCHEPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 4
|
|
// XICH ...
|
|
bool isICHPassed =
|
|
//
|
|
(conditions.ichConditions.isTenkanSenUnderKijunSen ||
|
|
conditions.ichConditions.isTenkanSenCrossedUnderKijunSen)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.ichConditions.isSenkouSpanAUnderB ||
|
|
conditions.ichConditions.isSenkouSpanAUnderLast ||
|
|
conditions.ichConditions.isSenkouSpanACrossedUnderB ||
|
|
conditions.ichConditions.isSenkouSpanACrossedUnderLast)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.ichConditions.isFutureSenkouSpanAUnderB ||
|
|
conditions.ichConditions.isFutureSenkouSpanAUnderLast ||
|
|
conditions.ichConditions.isFutureSenkouSpanACrossedUnderB ||
|
|
conditions.ichConditions.isFutureSenkouSpanACrossedUnderLast)
|
|
//
|
|
;
|
|
if (isICHPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 5
|
|
// XSTR ...
|
|
bool isSTRPassed =
|
|
//
|
|
conditions.strConditions.isTrendBearish ||
|
|
conditions.strConditions.isTrendSwitchedToBearish
|
|
//
|
|
;
|
|
if (isSTRPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 6
|
|
// XMRB ...
|
|
bool isMRBPassed =
|
|
//
|
|
conditions.mrbConditions.isFastUnderSlow ||
|
|
conditions.mrbConditions.isFastCrossedUnderSlow
|
|
//
|
|
;
|
|
if (isMRBPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 7
|
|
// XVLM ...
|
|
bool isVLMPassed =
|
|
//
|
|
conditions.vlmConditions.isVolumeBearish ||
|
|
conditions.vlmConditions.isVolumeUnderLast ||
|
|
conditions.vlmConditions.isVolumeChangedToBearish
|
|
//
|
|
;
|
|
if (isVLMPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 8
|
|
// XSSLC ...
|
|
bool isSSLCPassed =
|
|
//
|
|
conditions.sslcConditions.isBearish ||
|
|
conditions.sslcConditions.isSwitchedToBearish
|
|
//
|
|
;
|
|
if (isSSLCPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 9
|
|
// XHULL ...
|
|
bool isHULLPassed =
|
|
//
|
|
conditions.hullConditions.isBearish ||
|
|
conditions.hullConditions.isUpBearish ||
|
|
conditions.hullConditions.isDownBearish ||
|
|
conditions.hullConditions.isSwitchedToBearish
|
|
//
|
|
;
|
|
if (isHULLPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 10
|
|
// XADX ...
|
|
bool isADXTDPassed =
|
|
//
|
|
conditions.adxtdConditions.isBearish ||
|
|
conditions.adxtdConditions.isSwitchedToBearish ||
|
|
conditions.adxtdConditions.isStrongSwitchedToBearish
|
|
//
|
|
;
|
|
if (isADXTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 11
|
|
// XMC ...
|
|
bool isMCPassed =
|
|
//
|
|
((conditions.mcConditions.isBearish ||
|
|
conditions.mcConditions.isSwitchedToBearish)
|
|
//
|
|
||
|
|
//
|
|
((conditions.mcConditions.isFastUnderVerifier ||
|
|
conditions.mcConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
&&
|
|
//
|
|
(conditions.mcConditions.isSlowUnderVerifier ||
|
|
conditions.mcConditions.isSlowCrossedUnderVerifier)))
|
|
//
|
|
||
|
|
//
|
|
(conditions.mcConditions.isSARBearish ||
|
|
conditions.mcConditions.isSARSwitchedToBearish)
|
|
//
|
|
;
|
|
if (isMCPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 12
|
|
// XSLN ...
|
|
bool isXSLNPassed =
|
|
//
|
|
(conditions.slnConditions.isBearish ||
|
|
conditions.slnConditions.isSwitchedToBearish)
|
|
//
|
|
;
|
|
if (isXSLNPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 13
|
|
// XHTD ...
|
|
bool isXHTDPassed =
|
|
//
|
|
(conditions.htdConditions.isBearish ||
|
|
conditions.htdConditions.isSwitchedToBearish)
|
|
//
|
|
;
|
|
if (isXHTDPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
// 14
|
|
// XATSL ...
|
|
bool isXATSLPassed =
|
|
//
|
|
(conditions.atslConditions.isBearish ||
|
|
conditions.atslConditions.isSwitchedToBearish)
|
|
//
|
|
;
|
|
if (isXATSLPassed)
|
|
{
|
|
result++;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsConditionsValidForShort(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int verifications = 10 // Number of Verifications
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int signs = CountShortValidations(conditions);
|
|
|
|
//
|
|
result =
|
|
//
|
|
verifications <= 0
|
|
? signs > 0
|
|
: signs >= verifications
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve OSC Based Short Verifications ...
|
|
bool IsOSCShortVerified(
|
|
X121SetupConditions &conditions // Conditions
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
result =
|
|
//
|
|
// CCI ...
|
|
conditions.cci[cIndex] > -96 &&
|
|
conditions.cci[cIndex] < conditions.cci[pIndex]
|
|
//
|
|
&&
|
|
//
|
|
// RSI ...
|
|
conditions.rsi[cIndex] > 30 &&
|
|
conditions.rsi[cIndex] < conditions.rsi[pIndex]
|
|
//
|
|
&&
|
|
//
|
|
// MACD ...
|
|
conditions.macd[cIndex] < 0 &&
|
|
conditions.macdSignal[cIndex] < 0 &&
|
|
conditions.macd[cIndex] < conditions.macdSignal[cIndex]
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Custom Functions ...
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return "X121";
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XSCX121Setup : 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;
|
|
XSCXCHMAHelper *chmaHelper;
|
|
XSCXATSLHelper *atslHelper;
|
|
XSCXASCTHelper *asctHelper;
|
|
XSCXSSLCHelper *sslcHelper;
|
|
XSCXHULLHelper *hullHelper;
|
|
XSCXDMNTHelper *dmntHelper;
|
|
XSCXADXTDHelper *adxtdHelper;
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
void XSCX121Setup() {}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XSCX121Setup()
|
|
{
|
|
//
|
|
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 dmntHelper;
|
|
delete adxtdHelper;
|
|
}
|
|
|
|
//
|
|
// Getter(s) / Setter(s) ...
|
|
|
|
//
|
|
string GetSymbol()
|
|
{
|
|
return inputs.symbol;
|
|
}
|
|
|
|
//
|
|
ENUM_TIMEFRAMES GetPeriod()
|
|
{
|
|
return inputs.period;
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
bool Init(
|
|
X121SetupInputs &_inputs // Configurations
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = _inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
inputs = _inputs;
|
|
|
|
//
|
|
// Initialize Helpers ...
|
|
|
|
//
|
|
// XPV ...
|
|
pvHelper = new XSCXPVHelper();
|
|
result = pvHelper.Init(
|
|
inputs.symbol,
|
|
inputs.period,
|
|
inputs.pvInputs //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XRL ...
|
|
rlHelper = new XSCXRLHelper();
|
|
result = rlHelper.Init(
|
|
inputs.symbol,
|
|
inputs.period,
|
|
inputs.rlInputs //
|
|
);
|
|
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;
|
|
}
|
|
|
|
//
|
|
// XCHMA ...
|
|
chmaHelper = new XSCXCHMAHelper();
|
|
result = chmaHelper.Init(
|
|
inputs.symbol,
|
|
inputs.period,
|
|
inputs.chmaInputs //
|
|
);
|
|
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;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
X121SetupInputs GetInputs()
|
|
{
|
|
return inputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
X121SetupInputs &_inputs // Configurations
|
|
)
|
|
{
|
|
return Init(_inputs);
|
|
}
|
|
|
|
//
|
|
bool GetConditions(
|
|
X121SetupConditions &conditions, //
|
|
int barIndex = 0, //
|
|
int loopback = 5 //
|
|
)
|
|
{
|
|
//
|
|
bool result = true;
|
|
|
|
//
|
|
conditions.Clean();
|
|
|
|
//
|
|
conditions.symbol = GetSymbol();
|
|
conditions.period = GetPeriod();
|
|
conditions.time = TimeCurrent();
|
|
|
|
//
|
|
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 //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
X121SetupInputs inputs; // Setup Configurations ...
|
|
};
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
int FindSignalConditionsIndex(
|
|
XSignal &signal,
|
|
X121SetupConditions &conditions[] //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
// Check Signal is Valid ...
|
|
if (!signal.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Conditions Count ...
|
|
int conditionsCount = ArraySize(conditions);
|
|
if (!IsValidSize(conditionsCount))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < conditionsCount; i++)
|
|
{
|
|
//
|
|
X121SetupConditions iConditions = conditions[i];
|
|
|
|
//
|
|
if (signal.symbol == iConditions.symbol &&
|
|
signal.period == iConditions.period)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// |