2929 lines
76 KiB
Plaintext
2929 lines
76 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 "../Classes/x-saherelm.xczone.class.mq5"
|
|
|
|
//
|
|
#include "../Helpers/x-saherelm.xtd.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xhk.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.xasct.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xsslc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xhull.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xmatd.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xadxtd.helper.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
enum ENUM_X121_SIGNAL_PROVIDER
|
|
{
|
|
//
|
|
PROVIDER_UNKNOWN = 0,
|
|
PROVIDER_XMATD = 1,
|
|
PROVIDER_XSARD = 2,
|
|
PROVIDER_XADXTD = 3,
|
|
PROVIDER_XSTR = 4,
|
|
PROVIDER_XCHE = 5,
|
|
PROVIDER_XTD = 6,
|
|
PROVIDER_XSI = 7,
|
|
PROVIDER_XCI = 8,
|
|
PROVIDER_XMCD = 9,
|
|
PROVIDER_XICH = 10,
|
|
PROVIDER_XHK = 11,
|
|
PROVIDER_XSMHK = 12,
|
|
PROVIDER_XMRB = 13,
|
|
PROVIDER_XSSLC = 14,
|
|
PROVIDER_XHULL = 15,
|
|
PROVIDER_XASCT = 16,
|
|
PROVIDER_XVLM = 17,
|
|
};
|
|
|
|
//
|
|
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_XMATD))))
|
|
{
|
|
result = PROVIDER_XMATD;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XSARD))))
|
|
{
|
|
result = PROVIDER_XSARD;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XADXTD))))
|
|
{
|
|
result = PROVIDER_XADXTD;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XSTR))))
|
|
{
|
|
result = PROVIDER_XSTR;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XCHE))))
|
|
{
|
|
result = PROVIDER_XCHE;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XTD))))
|
|
{
|
|
result = PROVIDER_XTD;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XSI))))
|
|
{
|
|
result = PROVIDER_XSI;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XCI))))
|
|
{
|
|
result = PROVIDER_XCI;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XMCD))))
|
|
{
|
|
result = PROVIDER_XMCD;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XICH))))
|
|
{
|
|
result = PROVIDER_XICH;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XHK))))
|
|
{
|
|
result = PROVIDER_XHK;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XSMHK))))
|
|
{
|
|
result = PROVIDER_XSMHK;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XMRB))))
|
|
{
|
|
result = PROVIDER_XMRB;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XSSLC))))
|
|
{
|
|
result = PROVIDER_XSSLC;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XHULL))))
|
|
{
|
|
result = PROVIDER_XHULL;
|
|
}
|
|
else if (Contains(value, (EnumToString(PROVIDER_XASCT))))
|
|
{
|
|
result = PROVIDER_XASCT;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
struct X121SetupInputs
|
|
{
|
|
//
|
|
// Commons ...
|
|
string symbol; // Symbol
|
|
ENUM_TIMEFRAMES period; // Time Frame
|
|
|
|
//
|
|
// Helpers Inputs ...
|
|
XTDInputs tdInputs; // XTD Inputs
|
|
XHKInputs hkInputs; // XHK 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
|
|
XMATDInputs matdInputs; // XMATD 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
|
|
XTDInputs &_tdInputs, // XTD Inputs
|
|
XHKInputs &_hkInputs, // XHK 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
|
|
XMATDInputs &_matdInputs, // XMATD 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.tdInputs = _tdInputs;
|
|
this.hkInputs = _hkInputs;
|
|
this.cheInputs = _cheInputs;
|
|
this.ichInputs = _ichInputs;
|
|
this.strInputs = _strInputs;
|
|
this.mrbInputs = _mrbInputs;
|
|
this.oscInputs = _oscInputs;
|
|
this.vlmInputs = _vlmInputs;
|
|
this.matdInputs = _matdInputs;
|
|
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;
|
|
|
|
//
|
|
tdInputs.Clean();
|
|
hkInputs.Clean();
|
|
cheInputs.Clean();
|
|
ichInputs.Clean();
|
|
strInputs.Clean();
|
|
mrbInputs.Clean();
|
|
oscInputs.Clean();
|
|
vlmInputs.Clean();
|
|
matdInputs.Clean();
|
|
asctInputs.Clean();
|
|
sslcInputs.Clean();
|
|
hullInputs.Clean();
|
|
adxtdInputs.Clean();
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
tdInputs.Default();
|
|
hkInputs.Default();
|
|
cheInputs.Default();
|
|
ichInputs.Default();
|
|
strInputs.Default();
|
|
mrbInputs.Default();
|
|
oscInputs.Default();
|
|
vlmInputs.Default();
|
|
matdInputs.Default();
|
|
asctInputs.Default();
|
|
sslcInputs.Default();
|
|
hullInputs.Default();
|
|
adxtdInputs.Default();
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(symbol) &&
|
|
IsValid(period)
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = tdInputs.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 = matdInputs.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;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Conditions ...
|
|
struct X121SetupConditions
|
|
{
|
|
//
|
|
// Common ...
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
// Conditions ...
|
|
XTDConditions tdConditions;
|
|
XHKConditions hkConditions;
|
|
XCHEConditions cheConditions;
|
|
XICHConditions ichConditions;
|
|
XSTRConditions strConditions;
|
|
XMRBConditions mrbConditions;
|
|
XVLMConditions vlmConditions;
|
|
XMATDConditions matdConditions;
|
|
XASCTConditions asctConditions;
|
|
XSSLCConditions sslcConditions;
|
|
XHULLConditions hullConditions;
|
|
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);
|
|
|
|
//
|
|
tdConditions.Clean();
|
|
hkConditions.Clean();
|
|
cheConditions.Clean();
|
|
ichConditions.Clean();
|
|
strConditions.Clean();
|
|
mrbConditions.Clean();
|
|
vlmConditions.Clean();
|
|
matdConditions.Clean();
|
|
asctConditions.Clean();
|
|
sslcConditions.Clean();
|
|
hullConditions.Clean();
|
|
adxtdConditions.Clean();
|
|
}
|
|
|
|
//
|
|
void GenerateScore(
|
|
double &bullishScore,
|
|
double &bearishScore //
|
|
)
|
|
{
|
|
//
|
|
bullishScore = 0;
|
|
bearishScore = 0;
|
|
|
|
//
|
|
double tempBullishScore = 0;
|
|
double tempBearishScore = 0;
|
|
|
|
//
|
|
matdConditions.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;
|
|
}
|
|
|
|
//
|
|
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 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 matdSummary = matdConditions.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 adxtdSummary = adxtdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
|
|
|
|
//
|
|
string conditionsStr =
|
|
//
|
|
tdSummary + separator +
|
|
hkSummary + separator +
|
|
ichSummary + separator +
|
|
mrbSummary + separator +
|
|
vlmSummary + separator +
|
|
strSummary + separator +
|
|
cheSummary + separator +
|
|
asctSummary + separator +
|
|
sslcSummary + separator +
|
|
hullSummary + separator +
|
|
matdSummary + separator +
|
|
adxtdSummary + separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetTag() + "]" + separator +
|
|
(onlyConditions
|
|
? ""
|
|
: commonStr) +
|
|
(!includeScores
|
|
? ""
|
|
: scoresStr) +
|
|
" " + separator +
|
|
(onlyCommons
|
|
? ""
|
|
: conditionsStr) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return "X121Setup";
|
|
}
|
|
};
|
|
|
|
//
|
|
// Condition Parser ...
|
|
struct X121SignalGenerator
|
|
{
|
|
//
|
|
string version;
|
|
double hotLevels[];
|
|
|
|
//
|
|
// Constructor ...
|
|
void X121SignalGenerator()
|
|
{
|
|
//
|
|
Add(
|
|
0.25,
|
|
hotLevels //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
0.20,
|
|
hotLevels //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
0.15,
|
|
hotLevels //
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
// Check Market Conditions for Long Signals ...
|
|
bool HasLongConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int &pusher, // Pushers
|
|
string &provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
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 //
|
|
);
|
|
|
|
//
|
|
// XMATD ...
|
|
bool long1 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.matdConditions.isSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isSARBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long1)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMATD);
|
|
}
|
|
|
|
//
|
|
// XSARD ...
|
|
bool long2 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.matdConditions.isSARSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long2)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSARD);
|
|
}
|
|
|
|
//
|
|
// XADXTD ...
|
|
bool long3 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.adxtdConditions.isStrongSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long3)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XADXTD);
|
|
}
|
|
|
|
//
|
|
// XSTR ...
|
|
bool long4 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.strConditions.isTrendSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long4)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSTR);
|
|
}
|
|
|
|
//
|
|
// XCHE ...
|
|
bool long5 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.cheConditions.isStrongSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long5)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCHE);
|
|
}
|
|
|
|
//
|
|
// XTD ...
|
|
bool long6 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.tdConditions.isSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long6)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XTD);
|
|
}
|
|
|
|
//
|
|
// XSI ...
|
|
bool long7 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.rsi[cIndex] > 30 &&
|
|
conditions.rsi[pIndex] <= 30 &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long7)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSI);
|
|
}
|
|
|
|
//
|
|
// XCI ...
|
|
bool long8 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.cci[cIndex] > -100 &&
|
|
conditions.cci[pIndex] <= -100 &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long8)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCI);
|
|
}
|
|
|
|
//
|
|
// XMCD ...
|
|
bool long9 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.macd[cIndex] > 0 &&
|
|
conditions.macd[cIndex] > conditions.macdSignal[cIndex] &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long9)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMCD);
|
|
}
|
|
|
|
//
|
|
// XICH ...
|
|
bool long10 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.ichConditions.HasLongConditions() &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long10)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XICH);
|
|
}
|
|
|
|
//
|
|
// XHK ...
|
|
bool long11 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hkConditions.isHKSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long11)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XHK);
|
|
}
|
|
|
|
//
|
|
// XSMHK ...
|
|
bool long12 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hkConditions.isSMHKSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long12)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSMHK);
|
|
}
|
|
|
|
//
|
|
// XMRB ...
|
|
bool long13 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.mrbConditions.isFastCrossedOverSlow &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long13)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMRB);
|
|
}
|
|
|
|
//
|
|
// XSSLC ...
|
|
bool long14 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.sslcConditions.isSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long14)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSSLC);
|
|
}
|
|
|
|
//
|
|
// XHULL ...
|
|
bool long15 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hullConditions.isSwitchedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long15)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XHULL);
|
|
}
|
|
|
|
//
|
|
// XASCT ...
|
|
bool long16 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.asctConditions.isLongSignal &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.sslcConditions.isBullish &&
|
|
conditions.vlmConditions.isVolumeBullish
|
|
//
|
|
;
|
|
if (long16)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XASCT);
|
|
}
|
|
|
|
//
|
|
// XVLM ...
|
|
bool long17 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.vlmConditions.isVolumeChangedToBullish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBullish &&
|
|
conditions.matdConditions.isBullish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBullish &&
|
|
conditions.strConditions.isTrendBullish &&
|
|
conditions.cheConditions.isStrongBullish &&
|
|
conditions.hkConditions.isHKBullish &&
|
|
conditions.hkConditions.isSMHKBullish &&
|
|
conditions.mrbConditions.isFastOverSlow &&
|
|
conditions.hullConditions.isBullish &&
|
|
conditions.sslcConditions.isBullish
|
|
//
|
|
;
|
|
if (long17)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XVLM);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
pusher >= 1 &&
|
|
// !isOSCShortVerified &&
|
|
// bullishScore > bearishScore * 2 &&
|
|
(
|
|
//
|
|
long1
|
|
//
|
|
||
|
|
//
|
|
long2
|
|
//
|
|
||
|
|
//
|
|
long3
|
|
//
|
|
||
|
|
//
|
|
long4
|
|
//
|
|
||
|
|
//
|
|
long5
|
|
//
|
|
||
|
|
//
|
|
long6
|
|
//
|
|
||
|
|
//
|
|
long7
|
|
//
|
|
||
|
|
//
|
|
long8
|
|
//
|
|
||
|
|
//
|
|
long9
|
|
//
|
|
||
|
|
//
|
|
long10
|
|
//
|
|
||
|
|
//
|
|
long11
|
|
//
|
|
||
|
|
//
|
|
long12
|
|
//
|
|
||
|
|
//
|
|
long13
|
|
//
|
|
||
|
|
//
|
|
long14
|
|
//
|
|
||
|
|
//
|
|
long15
|
|
//
|
|
||
|
|
//
|
|
long16
|
|
//
|
|
||
|
|
//
|
|
long17
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Market Conditions for Short Signals ...
|
|
bool HasShortConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int &pusher, // Pushers
|
|
string &provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
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 //
|
|
);
|
|
|
|
//
|
|
// XMATD ...
|
|
bool short1 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.matdConditions.isSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isSARBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short1)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMATD);
|
|
}
|
|
|
|
//
|
|
// XSARD ...
|
|
bool short2 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.matdConditions.isSARSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short2)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSARD);
|
|
}
|
|
|
|
//
|
|
// XADXTD ...
|
|
bool short3 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.adxtdConditions.isStrongSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short3)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XADXTD);
|
|
}
|
|
|
|
//
|
|
// XSTR ...
|
|
bool short4 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.strConditions.isTrendSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short4)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSTR);
|
|
}
|
|
|
|
//
|
|
// XCHE ...
|
|
bool short5 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.cheConditions.isStrongSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short5)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCHE);
|
|
}
|
|
|
|
//
|
|
// XTD ...
|
|
bool short6 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.tdConditions.isSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short6)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XTD);
|
|
}
|
|
|
|
//
|
|
// XSI ...
|
|
bool short7 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.rsi[cIndex] < 70 &&
|
|
conditions.rsi[pIndex] >= 70 &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short7)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSI);
|
|
}
|
|
|
|
//
|
|
// XCI ...
|
|
bool short8 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.cci[cIndex] < 100 &&
|
|
conditions.cci[pIndex] >= 100 &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short8)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XCI);
|
|
}
|
|
|
|
//
|
|
// XMCD ...
|
|
bool short9 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.macd[cIndex] < 0 &&
|
|
conditions.macd[cIndex] < conditions.macdSignal[cIndex] &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short9)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMCD);
|
|
}
|
|
|
|
//
|
|
// XICH ...
|
|
bool short10 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.ichConditions.HasShortConditions() &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short10)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XICH);
|
|
}
|
|
|
|
//
|
|
// XHK ...
|
|
bool short11 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hkConditions.isHKSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short11)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XHK);
|
|
}
|
|
|
|
//
|
|
// XSMHK ...
|
|
bool short12 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hkConditions.isSMHKSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short12)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSMHK);
|
|
}
|
|
|
|
//
|
|
// XMRB ...
|
|
bool short13 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.mrbConditions.isFastCrossedUnderSlow &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short13)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XMRB);
|
|
}
|
|
|
|
//
|
|
// XSSLC ...
|
|
bool short14 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.sslcConditions.isSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short14)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XSSLC);
|
|
}
|
|
|
|
//
|
|
// XHULL ...
|
|
bool short15 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.hullConditions.isSwitchedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short15)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XHULL);
|
|
}
|
|
|
|
//
|
|
// XASCT ...
|
|
bool short16 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.asctConditions.isShortSignal &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.sslcConditions.isBearish &&
|
|
conditions.vlmConditions.isVolumeBearish
|
|
//
|
|
;
|
|
if (short16)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XASCT);
|
|
}
|
|
|
|
//
|
|
// XVLM ...
|
|
bool short17 =
|
|
//
|
|
// Starting Conditions ...
|
|
conditions.vlmConditions.isVolumeChangedToBearish &&
|
|
//
|
|
// Verifications ...
|
|
conditions.tdConditions.isBearish &&
|
|
conditions.matdConditions.isBearish &&
|
|
conditions.adxtdConditions.isStrong &&
|
|
conditions.adxtdConditions.isBearish &&
|
|
conditions.strConditions.isTrendBearish &&
|
|
conditions.cheConditions.isStrongBearish &&
|
|
conditions.hkConditions.isHKBearish &&
|
|
conditions.hkConditions.isSMHKBearish &&
|
|
conditions.mrbConditions.isFastUnderSlow &&
|
|
conditions.hullConditions.isBearish &&
|
|
conditions.sslcConditions.isBearish
|
|
//
|
|
;
|
|
if (short17)
|
|
{
|
|
//
|
|
pusher++;
|
|
provider = ToString(PROVIDER_XVLM);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
pusher >= 1 &&
|
|
// !isOSCLongVerified &&
|
|
// bearishScore > bullishScore * 2 &&
|
|
(
|
|
//
|
|
short1
|
|
//
|
|
||
|
|
//
|
|
short2
|
|
//
|
|
||
|
|
//
|
|
short3
|
|
//
|
|
||
|
|
//
|
|
short4
|
|
//
|
|
||
|
|
//
|
|
short5
|
|
//
|
|
||
|
|
//
|
|
short6
|
|
//
|
|
||
|
|
//
|
|
short7
|
|
//
|
|
||
|
|
//
|
|
short8
|
|
//
|
|
||
|
|
//
|
|
short9
|
|
//
|
|
||
|
|
//
|
|
short10
|
|
//
|
|
||
|
|
//
|
|
short11
|
|
//
|
|
||
|
|
//
|
|
short12
|
|
//
|
|
||
|
|
//
|
|
short13
|
|
//
|
|
||
|
|
//
|
|
short14
|
|
//
|
|
||
|
|
//
|
|
short15
|
|
//
|
|
||
|
|
//
|
|
short16
|
|
//
|
|
||
|
|
//
|
|
short17
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Filter Long Conditions ...
|
|
bool FilterLongConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int pusher, // Pushers
|
|
string provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO Filter ...
|
|
result = true; // provider == ToString(PROVIDER_XVLM);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Filter Short Conditions ...
|
|
bool FilterShortConditions(
|
|
X121SetupConditions &conditions, // Conditions
|
|
int pusher, // Pushers
|
|
string provider // Provider
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO Filter ...
|
|
result = true; // provider == ToString(PROVIDER_XVLM);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Conditions for Generating Possible Signals ...
|
|
bool HasSignal(
|
|
X121SetupConditions &conditions, // Conditions
|
|
XSignal &signal, // Signal if Exists
|
|
int &pusher, // Pushers
|
|
string &provider, // Signal Provider Name
|
|
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 //
|
|
);
|
|
|
|
//
|
|
if (hasLong)
|
|
{
|
|
//
|
|
hasLong = FilterLongConditions(
|
|
conditions,
|
|
pusher,
|
|
provider //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_allowShort && !hasLong)
|
|
{
|
|
//
|
|
hasShort =
|
|
HasShortConditions(
|
|
conditions,
|
|
pusher,
|
|
provider //
|
|
);
|
|
|
|
//
|
|
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;
|
|
}
|
|
|
|
//
|
|
// Calculate Ticks Zone ...
|
|
XSCZones *zones = new XSCZones(
|
|
signal.symbol,
|
|
signal.period //
|
|
);
|
|
|
|
//
|
|
XSCZonesInput zonesInput;
|
|
zonesInput.length = 71;
|
|
zonesInput.numberOfZones = 10;
|
|
|
|
//
|
|
zonesInput.AddLevelColor(
|
|
hotLevels[0],
|
|
clrRed //
|
|
);
|
|
zonesInput.AddLevelColor(
|
|
hotLevels[1],
|
|
clrOrange //
|
|
);
|
|
zonesInput.AddLevelColor(
|
|
hotLevels[2],
|
|
clrLightCoral //
|
|
);
|
|
|
|
//
|
|
bool canUseZones = zones.Init(zonesInput);
|
|
if (canUseZones)
|
|
{
|
|
signal.zones = zones;
|
|
}
|
|
|
|
//
|
|
// Generate Support Signals ...
|
|
if (_useSupport)
|
|
{
|
|
//
|
|
GenerateSupportSignals(
|
|
signal //
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void GenerateSupportSignals(
|
|
XSignal &signal // Source Signal for Support Generating ...
|
|
)
|
|
{
|
|
//
|
|
// Validate Signal ...
|
|
if (!signal.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Retrieve Signal Direction ...
|
|
bool isLong = IsLong(signal.type);
|
|
|
|
//
|
|
bool canUseZones = signal.zones != NULL;
|
|
|
|
//
|
|
// Check Signal Has TP and SL ...
|
|
if (signal.tp > 0 && signal.sl > 0)
|
|
{
|
|
//
|
|
// Here we Can Provide Orders based on Signal TP and SL ...
|
|
|
|
//
|
|
// Calculate TP/Entry Distance ...
|
|
double tpDistance =
|
|
isLong
|
|
? signal.tp - signal.entry
|
|
: signal.entry - signal.tp;
|
|
|
|
//
|
|
// Calculate Recovery Zone Step ...
|
|
double slDistance =
|
|
isLong
|
|
? signal.entry - signal.sl
|
|
: signal.sl - signal.entry;
|
|
}
|
|
|
|
//
|
|
// Add Zone Based Signals ...
|
|
if (canUseZones)
|
|
{
|
|
//
|
|
// signal.zones.DrawZones();
|
|
|
|
//
|
|
// Try to Find a Hot Level based on Signal Direction
|
|
// as Resistance ...
|
|
|
|
//
|
|
XSignal rSignal; // Recovery Signal ...
|
|
|
|
//
|
|
double rSL = 0; // Recovery Stop Loss ...
|
|
double rTP = 0; // Recovery Take Profit ...
|
|
double rEntry = 0; // Recovery Entry Point ...
|
|
double rVolume = signal.volume * 2; // Recovery Volume ...
|
|
ENUM_POSITION_TYPE rType; // Recovery Signal Type ...
|
|
ENUM_X_ORDER_MODES rMode; // Recovery Signal Mode ...
|
|
bool isSignalPrepared = false; // Check Signal Preparation Succeed ...
|
|
|
|
//
|
|
double onePointValue = PointToPrice(1, signal.symbol);
|
|
|
|
//
|
|
for (int i = 0; i < signal.zones.CountZones(); i++)
|
|
{
|
|
//
|
|
// Retrieve Indexed Zone ...
|
|
XSCZone *iZone = signal.zones.GetZone(i);
|
|
|
|
//
|
|
// Check Zone is Hot Zone or not ...
|
|
bool isHotZone = false;
|
|
for (int j = 0; j < ArraySize(hotLevels); j++)
|
|
{
|
|
//
|
|
isHotZone = (iZone.percent / 100 >= hotLevels[j]);
|
|
if (isHotZone)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Prevent Moving Forward if there isn't Hot Zone ...
|
|
if (!isHotZone)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
if (iZone.high > signal.entry && iZone.low > signal.entry)
|
|
{
|
|
//
|
|
// Here we can Use Resistance Zone as SL Recovery for
|
|
// Short Positions ...
|
|
if (!isLong &&
|
|
(signal.sl <= 0
|
|
? true
|
|
: iZone.high < signal.sl && iZone.low < signal.sl))
|
|
{
|
|
//
|
|
// Opposit Support on Resistance Upper ...
|
|
|
|
//
|
|
rTP = signal.sl <= 0
|
|
? iZone.high - (onePointValue * 15)
|
|
: signal.sl;
|
|
rSL = signal.entry;
|
|
rType = POSITION_TYPE_BUY;
|
|
rEntry = iZone.high + (onePointValue * 2);
|
|
rMode = X_ORDER_MODE_STOP;
|
|
|
|
//
|
|
isSignalPrepared = rSignal.Prepare(
|
|
signal.symbol,
|
|
signal.provider,
|
|
signal.period,
|
|
rType,
|
|
rMode,
|
|
rEntry,
|
|
rVolume,
|
|
rSL,
|
|
rTP //
|
|
);
|
|
if (isSignalPrepared)
|
|
{
|
|
//
|
|
AddRef(
|
|
rSignal,
|
|
signal.supports //
|
|
);
|
|
|
|
//
|
|
rSignal.Clean();
|
|
|
|
//
|
|
rSL = 0;
|
|
rTP = 0;
|
|
rEntry = 0;
|
|
isSignalPrepared = false;
|
|
}
|
|
|
|
//
|
|
// Support Directional on Resistance Lower ...
|
|
|
|
//
|
|
rTP = signal.entry;
|
|
rSL = signal.sl <= 0
|
|
? signal.entry - (onePointValue * 15)
|
|
: signal.sl;
|
|
rEntry = iZone.low - (onePointValue * 2);
|
|
rVolume = signal.volume * 3;
|
|
rType = POSITION_TYPE_SELL;
|
|
rMode = X_ORDER_MODE_LIMIT;
|
|
|
|
//
|
|
isSignalPrepared = rSignal.Prepare(
|
|
signal.symbol,
|
|
signal.provider,
|
|
signal.period,
|
|
rType,
|
|
rMode,
|
|
rEntry,
|
|
rVolume,
|
|
rSL,
|
|
rTP //
|
|
);
|
|
if (isSignalPrepared)
|
|
{
|
|
//
|
|
AddRef(
|
|
rSignal,
|
|
signal.supports //
|
|
);
|
|
|
|
//
|
|
rSignal.Clean();
|
|
|
|
//
|
|
rSL = 0;
|
|
rTP = 0;
|
|
rEntry = 0;
|
|
isSignalPrepared = false;
|
|
rVolume = signal.volume * 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iZone.high < signal.entry && iZone.low < signal.entry)
|
|
{
|
|
//
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return "X121";
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XSCX121Setup : public XSCBaseAlert
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
XSCXTDHelper *tdHelper;
|
|
XSCXHKHelper *hkHelper;
|
|
XSCXCHEHelper *cheHelper;
|
|
XSCXICHHelper *ichHelper;
|
|
XSCXSTRHelper *strHelper;
|
|
XSCXMRBHelper *mrbHelper;
|
|
XSCXOSCHelper *oscHelper;
|
|
XSCXVLMHelper *vlmHelper;
|
|
XSCXMATDHelper *matdHelper;
|
|
XSCXASCTHelper *asctHelper;
|
|
XSCXSSLCHelper *sslcHelper;
|
|
XSCXHULLHelper *hullHelper;
|
|
XSCXADXTDHelper *adxtdHelper;
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
void XSCX121Setup() {}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XSCX121Setup()
|
|
{
|
|
//
|
|
delete tdHelper;
|
|
delete hkHelper;
|
|
delete cheHelper;
|
|
delete ichHelper;
|
|
delete strHelper;
|
|
delete mrbHelper;
|
|
delete oscHelper;
|
|
delete vlmHelper;
|
|
delete matdHelper;
|
|
delete asctHelper;
|
|
delete sslcHelper;
|
|
delete hullHelper;
|
|
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 ...
|
|
|
|
//
|
|
// XTD ...
|
|
tdHelper = new XSCXTDHelper();
|
|
result = tdHelper.Init(
|
|
inputs.symbol,
|
|
inputs.period,
|
|
inputs.tdInputs //
|
|
);
|
|
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;
|
|
}
|
|
|
|
//
|
|
// XMATD ...
|
|
matdHelper = new XSCXMATDHelper(
|
|
inputs.symbol,
|
|
inputs.period //
|
|
);
|
|
result = matdHelper.Init(
|
|
inputs.matdInputs //
|
|
);
|
|
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(
|
|
inputs.symbol,
|
|
inputs.period //
|
|
);
|
|
result = adxtdHelper.Init(
|
|
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 = 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 = matdHelper.GetConditions(
|
|
conditions.matdConditions,
|
|
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 ...
|
|
};
|