4967 lines
124 KiB
Plaintext
4967 lines
124 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSC121Provider
|
|
// Description: provides all Base Provider
|
|
// requirements For X121 ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
|
|
//
|
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xmc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xdon.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xzg.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xpv.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xstr.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xche.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xosc.helper.mq5"
|
|
|
|
//
|
|
#include "../Classes/x-saherelm.xprovider.class.mq5"
|
|
#include "../Classes/x-saherelm.x121.xmcycle.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Signallers ...
|
|
enum ENUM_X121_SIGNAL_PROVIDERS
|
|
{
|
|
//
|
|
X121NONE,
|
|
X121XSP,
|
|
XTEST,
|
|
X786,
|
|
X121,
|
|
X110,
|
|
X92,
|
|
};
|
|
|
|
//
|
|
// X121 Provider Inputs ...
|
|
class X121ProviderInputs : public XSCBaseProviderInpts
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
|
|
//
|
|
// S Market ...
|
|
ENUM_TIMEFRAMES sMarketPeriod; // Short Market Period
|
|
ENUM_X_PERIOD_METHOD sMarketMethod; // Short Market Period Method
|
|
string sMarketPrefix; // Short Market Prefix
|
|
|
|
//
|
|
// MEDIUM Market ...
|
|
ENUM_TIMEFRAMES mMarketPeriod; // Medium Market Period
|
|
ENUM_X_PERIOD_METHOD mMarketMethod; // Medium Market Period Method
|
|
string mMarketPrefix; // Medium Market Prefix
|
|
|
|
//
|
|
// LONG Market ...
|
|
ENUM_TIMEFRAMES lMarketPeriod; // Long Market Period
|
|
ENUM_X_PERIOD_METHOD lMarketMethod; // Long Market Period Method
|
|
string lMarketPrefix; // Long Market Prefix
|
|
|
|
//
|
|
// HIND Market ...
|
|
ENUM_TIMEFRAMES hMarketPeriod; // Hind Market Period
|
|
ENUM_X_PERIOD_METHOD hMarketMethod; // Hind Market Period Method
|
|
string hMarketPrefix; // Hind Market Prefix
|
|
|
|
//
|
|
// Indicators ...
|
|
XCCInputs ccInputs;
|
|
XCTInputs ctInputs;
|
|
XZGInputs zgInputs;
|
|
XPVInputs pvInputs;
|
|
XMCInputs mcInputs;
|
|
XICHInputs ichInputs;
|
|
XCHEInputs cheInputs;
|
|
XSTRInputs strInputs;
|
|
XDONInputs donInputs;
|
|
XOSCInputs oscInputs;
|
|
|
|
//
|
|
X121MCycleInputs cMarketInputs; // Curent Market Inputs
|
|
X121MCycleInputs sMarketInputs; // Short Market Inputs
|
|
X121MCycleInputs mMarketInputs; // Medium Market Inputs
|
|
X121MCycleInputs lMarketInputs; // Long Market Inputs
|
|
X121MCycleInputs hMarketInputs; // Hind Market Inputs
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Initialize Input ...
|
|
bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Base Requirements ...
|
|
result =
|
|
//
|
|
IsSpecifiedValid(symbol) &&
|
|
IsSpecifiedValid(period) &&
|
|
IsSpecifiedValid(sMarketMethod, sMarketPeriod) &&
|
|
IsSpecifiedValid(mMarketMethod, mMarketPeriod) &&
|
|
IsSpecifiedValid(lMarketMethod, lMarketPeriod) &&
|
|
IsSpecifiedValid(hMarketMethod, hMarketPeriod)
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (!zgInputs.IsValid())
|
|
{
|
|
zgInputs.Default();
|
|
}
|
|
if (!pvInputs.IsValid())
|
|
{
|
|
pvInputs.Default();
|
|
}
|
|
if (!mcInputs.IsValid())
|
|
{
|
|
mcInputs.Default();
|
|
}
|
|
if (!cheInputs.IsValid())
|
|
{
|
|
cheInputs.Default();
|
|
}
|
|
if (!strInputs.IsValid())
|
|
{
|
|
strInputs.Default();
|
|
}
|
|
if (!donInputs.IsValid())
|
|
{
|
|
donInputs.Default();
|
|
}
|
|
if (!oscInputs.IsValid())
|
|
{
|
|
oscInputs.Default();
|
|
}
|
|
if (!ichInputs.IsValid())
|
|
{
|
|
ichInputs.Default();
|
|
}
|
|
|
|
// //
|
|
// if (!cMarketInputs.IsValid())
|
|
// {
|
|
// cMarketInputs.Default();
|
|
// }
|
|
// if (!sMarketInputs.IsValid())
|
|
// {
|
|
// sMarketInputs.Default();
|
|
// }
|
|
// if (!mMarketInputs.IsValid())
|
|
// {
|
|
// mMarketInputs.Default();
|
|
// }
|
|
// if (!lMarketInputs.IsValid())
|
|
// {
|
|
// lMarketInputs.Default();
|
|
// }
|
|
// if (!hMarketInputs.IsValid())
|
|
// {
|
|
// hMarketInputs.Default();
|
|
// }
|
|
|
|
//
|
|
// Initialize Market Inputs ...
|
|
|
|
//
|
|
// Current ...
|
|
cMarketInputs.pvInputs = this.pvInputs;
|
|
cMarketInputs.zgInputs = this.zgInputs;
|
|
cMarketInputs.mcInputs = this.mcInputs;
|
|
cMarketInputs.strInputs = this.strInputs;
|
|
cMarketInputs.oscInputs = this.oscInputs;
|
|
cMarketInputs.cheInputs = this.cheInputs;
|
|
cMarketInputs.ichInputs = this.ichInputs;
|
|
cMarketInputs.donInputs = this.donInputs;
|
|
result = cMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_SHORT,
|
|
this.period,
|
|
X_PERIOD_MANUALLY,
|
|
"HOST",
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
sMarketInputs.pvInputs = this.pvInputs;
|
|
sMarketInputs.zgInputs = this.zgInputs;
|
|
sMarketInputs.mcInputs = this.mcInputs;
|
|
sMarketInputs.strInputs = this.strInputs;
|
|
sMarketInputs.oscInputs = this.oscInputs;
|
|
sMarketInputs.cheInputs = this.cheInputs;
|
|
sMarketInputs.ichInputs = this.ichInputs;
|
|
sMarketInputs.donInputs = this.donInputs;
|
|
result = sMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_SHORT,
|
|
this.sMarketPeriod,
|
|
this.sMarketMethod,
|
|
this.sMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Medium ...
|
|
mMarketInputs.pvInputs = this.pvInputs;
|
|
mMarketInputs.zgInputs = this.zgInputs;
|
|
mMarketInputs.mcInputs = this.mcInputs;
|
|
mMarketInputs.strInputs = this.strInputs;
|
|
mMarketInputs.oscInputs = this.oscInputs;
|
|
mMarketInputs.cheInputs = this.cheInputs;
|
|
mMarketInputs.ichInputs = this.ichInputs;
|
|
mMarketInputs.donInputs = this.donInputs;
|
|
result = mMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_MEDIUM,
|
|
this.mMarketPeriod,
|
|
this.mMarketMethod,
|
|
this.mMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Long ...
|
|
lMarketInputs.pvInputs = this.pvInputs;
|
|
lMarketInputs.zgInputs = this.zgInputs;
|
|
lMarketInputs.mcInputs = this.mcInputs;
|
|
lMarketInputs.strInputs = this.strInputs;
|
|
lMarketInputs.oscInputs = this.oscInputs;
|
|
lMarketInputs.cheInputs = this.cheInputs;
|
|
lMarketInputs.ichInputs = this.ichInputs;
|
|
lMarketInputs.donInputs = this.donInputs;
|
|
result = lMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_LONG,
|
|
this.lMarketPeriod,
|
|
this.lMarketMethod,
|
|
this.lMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Hind ...
|
|
hMarketInputs.pvInputs = this.pvInputs;
|
|
hMarketInputs.zgInputs = this.zgInputs;
|
|
hMarketInputs.mcInputs = this.mcInputs;
|
|
hMarketInputs.strInputs = this.strInputs;
|
|
hMarketInputs.oscInputs = this.oscInputs;
|
|
hMarketInputs.cheInputs = this.cheInputs;
|
|
hMarketInputs.ichInputs = this.ichInputs;
|
|
hMarketInputs.donInputs = this.donInputs;
|
|
result = hMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_HIND,
|
|
this.hMarketPeriod,
|
|
this.hMarketMethod,
|
|
this.hMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Validate Input ...
|
|
bool IsValid() override
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
//
|
|
IsSpecifiedValid(symbol) &&
|
|
IsSpecifiedValid(period) &&
|
|
IsSpecifiedValid(sMarketMethod, sMarketPeriod) &&
|
|
IsSpecifiedValid(mMarketMethod, mMarketPeriod) &&
|
|
IsSpecifiedValid(lMarketMethod, lMarketPeriod) &&
|
|
IsSpecifiedValid(hMarketMethod, hMarketPeriod) &&
|
|
//
|
|
ccInputs.IsValid() &&
|
|
ctInputs.IsValid() &&
|
|
zgInputs.IsValid() &&
|
|
pvInputs.IsValid() &&
|
|
mcInputs.IsValid() &&
|
|
cheInputs.IsValid() &&
|
|
strInputs.IsValid() &&
|
|
donInputs.IsValid() &&
|
|
oscInputs.IsValid() &&
|
|
ichInputs.IsValid() &&
|
|
//
|
|
cMarketInputs.IsValid() &&
|
|
sMarketInputs.IsValid() &&
|
|
mMarketInputs.IsValid() &&
|
|
lMarketInputs.IsValid() &&
|
|
hMarketInputs.IsValid()
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean() override
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
sMarketPeriod = NULL;
|
|
sMarketMethod = X_PERIOD_NOTHING;
|
|
sMarketPrefix = NULL;
|
|
|
|
//
|
|
mMarketPeriod = NULL;
|
|
mMarketMethod = X_PERIOD_NOTHING;
|
|
mMarketPrefix = NULL;
|
|
|
|
//
|
|
lMarketPeriod = NULL;
|
|
lMarketMethod = X_PERIOD_NOTHING;
|
|
lMarketPrefix = NULL;
|
|
|
|
//
|
|
hMarketPeriod = NULL;
|
|
hMarketMethod = X_PERIOD_NOTHING;
|
|
hMarketPrefix = NULL;
|
|
|
|
//
|
|
ccInputs.Clean();
|
|
ctInputs.Clean();
|
|
zgInputs.Clean();
|
|
pvInputs.Clean();
|
|
mcInputs.Clean();
|
|
cheInputs.Clean();
|
|
strInputs.Clean();
|
|
donInputs.Clean();
|
|
oscInputs.Clean();
|
|
ichInputs.Clean();
|
|
//
|
|
cMarketInputs.Clean();
|
|
sMarketInputs.Clean();
|
|
mMarketInputs.Clean();
|
|
lMarketInputs.Clean();
|
|
hMarketInputs.Clean();
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default() override
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
sMarketPeriod = NULL;
|
|
sMarketMethod = X_PERIOD_AUTO;
|
|
sMarketPrefix = NULL;
|
|
|
|
//
|
|
mMarketPeriod = NULL;
|
|
mMarketMethod = X_PERIOD_AUTO;
|
|
mMarketPrefix = NULL;
|
|
|
|
//
|
|
lMarketPeriod = NULL;
|
|
lMarketMethod = X_PERIOD_AUTO;
|
|
lMarketPrefix = NULL;
|
|
|
|
//
|
|
hMarketPeriod = NULL;
|
|
hMarketMethod = X_PERIOD_AUTO;
|
|
hMarketPrefix = NULL;
|
|
|
|
//
|
|
ccInputs.Default();
|
|
ctInputs.Default();
|
|
zgInputs.Default();
|
|
pvInputs.Default();
|
|
mcInputs.Default();
|
|
cheInputs.Default();
|
|
strInputs.Default();
|
|
donInputs.Default();
|
|
oscInputs.Default();
|
|
ichInputs.Default();
|
|
cMarketInputs.Default();
|
|
sMarketInputs.Default();
|
|
mMarketInputs.Default();
|
|
lMarketInputs.Default();
|
|
hMarketInputs.Default();
|
|
}
|
|
|
|
//
|
|
// Max ...
|
|
int Max() override
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Symbol ...
|
|
bool SetSymbol(string value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsSpecifiedValid(value);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
symbol = value;
|
|
cMarketInputs.cycle.symbol = value;
|
|
sMarketInputs.cycle.symbol = value;
|
|
mMarketInputs.cycle.symbol = value;
|
|
lMarketInputs.cycle.symbol = value;
|
|
hMarketInputs.cycle.symbol = value;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Period ...
|
|
bool SetPeriod(ENUM_TIMEFRAMES value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsSpecifiedValid(value);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
period = value;
|
|
cMarketInputs.cycle.period = value;
|
|
sMarketInputs.cycle.period = value;
|
|
mMarketInputs.cycle.period = value;
|
|
lMarketInputs.cycle.period = value;
|
|
hMarketInputs.cycle.period = value;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// X121 Provider Market Conditions ...
|
|
class X121MarketConditions : public XSCBaseProviderMarketConditions
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// XZG ...
|
|
double zigzags[];
|
|
double zigzagPVs[];
|
|
|
|
//
|
|
bool isZigZagInPeak;
|
|
bool isZigZagInVale;
|
|
|
|
//
|
|
// XDON ...
|
|
double donUpperOs[];
|
|
double donLowerOs[];
|
|
double donUpperCs[];
|
|
double donLowerCs[];
|
|
double donUpperHs[];
|
|
double donLowerHs[];
|
|
double donUpperLs[];
|
|
double donLowerLs[];
|
|
|
|
//
|
|
bool isDONAttachedMaxLower;
|
|
bool isDONAttachedMinLower;
|
|
bool isDONCrossedOverMaxLower;
|
|
bool isDONCrossedUnderMaxLower;
|
|
|
|
//
|
|
bool isDONAttachedMaxUpper;
|
|
bool isDONAttachedMinUpper;
|
|
bool isDONCrossedOverMaxUpper;
|
|
bool isDONCrossedUnderMaxUpper;
|
|
|
|
//
|
|
// XPV ...
|
|
double pvPeaks[];
|
|
double pvVales[];
|
|
double pvResistances[];
|
|
double pvSupports[];
|
|
double pvFib1s[];
|
|
double pvFib2s[];
|
|
double pvFib3s[];
|
|
double pvFib4s[];
|
|
double pvFib5s[];
|
|
double pvSCHHs[];
|
|
double pvSCLLs[];
|
|
double pvMCHHs[];
|
|
double pvMCLLs[];
|
|
double pvLCHHs[];
|
|
double pvLCLLs[];
|
|
double pvHCHHs[];
|
|
double pvHCLLs[];
|
|
|
|
//
|
|
bool isPVPeakSameAs;
|
|
bool isPVNewPeak;
|
|
bool isPVNewPeakOverLast;
|
|
bool isPVNewPeakUnderLast;
|
|
bool isPVValeSameAs;
|
|
bool isPVNewVale;
|
|
bool isPVNewValeOverLast;
|
|
bool isPVNewValeUnderLast;
|
|
bool isPVFiboIncreased;
|
|
bool isPVFiboDecreased;
|
|
bool isPVFiboSectionChanged;
|
|
|
|
//
|
|
bool isPVSCBullish;
|
|
bool isPVSCHHBullish;
|
|
bool isPVSCLLBullish;
|
|
bool isPVSCSwitchedToBullish;
|
|
|
|
//
|
|
bool isPVSCBearish;
|
|
bool isPVSCHHBearish;
|
|
bool isPVSCLLBearish;
|
|
bool isPVSCSwitchedToBearish;
|
|
|
|
//
|
|
bool isPVMCBullish;
|
|
bool isPVMCHHBullish;
|
|
bool isPVMCLLBullish;
|
|
bool isPVMCSwitchedToBullish;
|
|
|
|
//
|
|
bool isPVMCBearish;
|
|
bool isPVMCHHBearish;
|
|
bool isPVMCLLBearish;
|
|
bool isPVMCSwitchedToBearish;
|
|
|
|
//
|
|
bool isPVLCBullish;
|
|
bool isPVLCHHBullish;
|
|
bool isPVLCLLBullish;
|
|
bool isPVLCSwitchedToBullish;
|
|
|
|
//
|
|
bool isPVLCBearish;
|
|
bool isPVLCHHBearish;
|
|
bool isPVLCLLBearish;
|
|
bool isPVLCSwitchedToBearish;
|
|
|
|
//
|
|
bool isPVHCBullish;
|
|
bool isPVHCHHBullish;
|
|
bool isPVHCLLBullish;
|
|
bool isPVHCSwitchedToBullish;
|
|
|
|
//
|
|
bool isPVHCBearish;
|
|
bool isPVHCHHBearish;
|
|
bool isPVHCLLBearish;
|
|
bool isPVHCSwitchedToBearish;
|
|
|
|
//
|
|
X121MCycleConditions cMarketConditions; // Current Market Conditions
|
|
X121MCycleConditions sMarketConditions; // Short Market Conditions
|
|
X121MCycleConditions mMarketConditions; // Medium Market Conditions
|
|
X121MCycleConditions lMarketConditions; // Long Market Conditions
|
|
X121MCycleConditions hMarketConditions; // Hind Market Conditions
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clear()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
Clean(bars);
|
|
Clean(zigzags);
|
|
Clean(zigzagPVs);
|
|
Clean(donUpperOs);
|
|
Clean(donLowerOs);
|
|
Clean(donUpperCs);
|
|
Clean(donLowerCs);
|
|
Clean(donUpperHs);
|
|
Clean(donLowerHs);
|
|
Clean(donUpperLs);
|
|
Clean(donLowerLs);
|
|
Clean(pvPeaks);
|
|
Clean(pvVales);
|
|
Clean(pvResistances);
|
|
Clean(pvSupports);
|
|
Clean(pvFib1s);
|
|
Clean(pvFib2s);
|
|
Clean(pvFib3s);
|
|
Clean(pvFib4s);
|
|
Clean(pvFib5s);
|
|
Clean(pvSCHHs);
|
|
Clean(pvSCLLs);
|
|
Clean(pvMCHHs);
|
|
Clean(pvMCLLs);
|
|
Clean(pvLCHHs);
|
|
Clean(pvLCLLs);
|
|
Clean(pvHCHHs);
|
|
Clean(pvHCLLs);
|
|
|
|
//
|
|
ArraySetAsSeries(bars, true);
|
|
ArraySetAsSeries(zigzags, true);
|
|
ArraySetAsSeries(zigzagPVs, true);
|
|
ArraySetAsSeries(donUpperOs, true);
|
|
ArraySetAsSeries(donLowerOs, true);
|
|
ArraySetAsSeries(donUpperCs, true);
|
|
ArraySetAsSeries(donLowerCs, true);
|
|
ArraySetAsSeries(donUpperHs, true);
|
|
ArraySetAsSeries(donLowerHs, true);
|
|
ArraySetAsSeries(donUpperLs, true);
|
|
ArraySetAsSeries(donLowerLs, true);
|
|
ArraySetAsSeries(pvPeaks, true);
|
|
ArraySetAsSeries(pvVales, true);
|
|
ArraySetAsSeries(pvResistances, true);
|
|
ArraySetAsSeries(pvSupports, true);
|
|
ArraySetAsSeries(pvFib1s, true);
|
|
ArraySetAsSeries(pvFib2s, true);
|
|
ArraySetAsSeries(pvFib3s, true);
|
|
ArraySetAsSeries(pvFib4s, true);
|
|
ArraySetAsSeries(pvFib5s, true);
|
|
ArraySetAsSeries(pvSCHHs, true);
|
|
ArraySetAsSeries(pvSCLLs, true);
|
|
ArraySetAsSeries(pvMCHHs, true);
|
|
ArraySetAsSeries(pvMCLLs, true);
|
|
ArraySetAsSeries(pvLCHHs, true);
|
|
ArraySetAsSeries(pvLCLLs, true);
|
|
ArraySetAsSeries(pvHCHHs, true);
|
|
ArraySetAsSeries(pvHCLLs, true);
|
|
|
|
//
|
|
isZigZagInPeak = false;
|
|
isZigZagInVale = false;
|
|
isDONAttachedMaxLower = false;
|
|
isDONAttachedMinLower = false;
|
|
isDONCrossedOverMaxLower = false;
|
|
isDONCrossedUnderMaxLower = false;
|
|
isDONAttachedMaxUpper = false;
|
|
isDONAttachedMinUpper = false;
|
|
isDONCrossedOverMaxUpper = false;
|
|
isDONCrossedUnderMaxUpper = false;
|
|
isPVPeakSameAs = false;
|
|
isPVNewPeak = false;
|
|
isPVNewPeakOverLast = false;
|
|
isPVNewPeakUnderLast = false;
|
|
isPVValeSameAs = false;
|
|
isPVNewVale = false;
|
|
isPVNewValeOverLast = false;
|
|
isPVNewValeUnderLast = false;
|
|
isPVFiboIncreased = false;
|
|
isPVFiboDecreased = false;
|
|
isPVFiboSectionChanged = false;
|
|
isPVSCBullish = false;
|
|
isPVSCHHBullish = false;
|
|
isPVSCLLBullish = false;
|
|
isPVSCSwitchedToBullish = false;
|
|
isPVSCBearish = false;
|
|
isPVSCHHBearish = false;
|
|
isPVSCLLBearish = false;
|
|
isPVSCSwitchedToBearish = false;
|
|
isPVMCBullish = false;
|
|
isPVMCHHBullish = false;
|
|
isPVMCLLBullish = false;
|
|
isPVMCSwitchedToBullish = false;
|
|
isPVMCBearish = false;
|
|
isPVMCHHBearish = false;
|
|
isPVMCLLBearish = false;
|
|
isPVMCSwitchedToBearish = false;
|
|
isPVLCBullish = false;
|
|
isPVLCHHBullish = false;
|
|
isPVLCLLBullish = false;
|
|
isPVLCSwitchedToBullish = false;
|
|
isPVLCBearish = false;
|
|
isPVLCHHBearish = false;
|
|
isPVLCLLBearish = false;
|
|
isPVLCSwitchedToBearish = false;
|
|
isPVHCBullish = false;
|
|
isPVHCHHBullish = false;
|
|
isPVHCLLBullish = false;
|
|
isPVHCSwitchedToBullish = false;
|
|
isPVHCBearish = false;
|
|
isPVHCHHBearish = false;
|
|
isPVHCLLBearish = false;
|
|
isPVHCSwitchedToBearish = false;
|
|
|
|
//
|
|
cMarketConditions.Clear();
|
|
sMarketConditions.Clear();
|
|
mMarketConditions.Clear();
|
|
lMarketConditions.Clear();
|
|
hMarketConditions.Clear();
|
|
}
|
|
|
|
//
|
|
void GenerateScore(
|
|
double &bullishScore, // Bullish Score
|
|
double &bearishScore, // Bearish Score
|
|
double cMarketMultiplier = 1, // Current Market Score Multiplier
|
|
double sMarketMultiplier = 1.1, // Short Market Score Multiplier
|
|
double mMarketMultiplier = 1.2, // Medium Market Score Multiplier
|
|
double lMarketMultiplier = 1.6, // Long Market Score Multiplier
|
|
double hMarketMultiplier = 1.8 // Hind Market Score Multiplier
|
|
)
|
|
{
|
|
//
|
|
// Current Market ...
|
|
double cMarketBullScore = 0;
|
|
double cMarketBearScore = 0;
|
|
cMarketConditions.GenerateScore(
|
|
cMarketBullScore,
|
|
cMarketBearScore,
|
|
cMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Short Market ...
|
|
double sMarketBullScore = 0;
|
|
double sMarketBearScore = 0;
|
|
sMarketConditions.GenerateScore(
|
|
sMarketBullScore,
|
|
sMarketBearScore,
|
|
sMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Medium Market ...
|
|
double mMarketBullScore = 0;
|
|
double mMarketBearScore = 0;
|
|
mMarketConditions.GenerateScore(
|
|
mMarketBullScore,
|
|
mMarketBearScore,
|
|
mMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Long Market ...
|
|
double lMarketBullScore = 0;
|
|
double lMarketBearScore = 0;
|
|
lMarketConditions.GenerateScore(
|
|
lMarketBullScore,
|
|
lMarketBearScore,
|
|
lMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Hind Market ...
|
|
double hMarketBullScore = 0;
|
|
double hMarketBearScore = 0;
|
|
hMarketConditions.GenerateScore(
|
|
hMarketBullScore,
|
|
hMarketBearScore,
|
|
hMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Calculate Summary Scores ...
|
|
|
|
//
|
|
bullishScore =
|
|
//
|
|
cMarketBullScore +
|
|
sMarketBullScore +
|
|
mMarketBullScore +
|
|
lMarketBullScore +
|
|
hMarketBullScore
|
|
//
|
|
;
|
|
|
|
//
|
|
bearishScore =
|
|
//
|
|
cMarketBearScore +
|
|
sMarketBearScore +
|
|
mMarketBearScore +
|
|
lMarketBearScore +
|
|
hMarketBearScore
|
|
//
|
|
;
|
|
|
|
//
|
|
// Handle Scores for Current Conditions ...
|
|
|
|
//
|
|
// XZG ...
|
|
if (isZigZagInPeak)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isZigZagInVale)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
|
|
//
|
|
// XDON ...
|
|
if (isDONAttachedMaxLower)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isDONAttachedMinLower)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isDONCrossedOverMaxLower)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isDONCrossedUnderMaxLower)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isDONAttachedMaxUpper)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isDONAttachedMinUpper)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isDONCrossedOverMaxUpper)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isDONCrossedUnderMaxUpper)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
|
|
//
|
|
// XPV ...
|
|
if (isPVPeakSameAs)
|
|
{
|
|
}
|
|
if (isPVNewPeak)
|
|
{
|
|
}
|
|
if (isPVNewPeakOverLast)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isPVNewPeakUnderLast)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVValeSameAs)
|
|
{
|
|
}
|
|
if (isPVNewVale)
|
|
{
|
|
}
|
|
if (isPVNewValeOverLast)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isPVNewValeUnderLast)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVFiboSectionChanged)
|
|
{
|
|
//
|
|
if (isPVFiboIncreased)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVFiboDecreased)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isPVSCBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVSCHHBullish)
|
|
{
|
|
bullishScore--;
|
|
}
|
|
if (isPVSCLLBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVSCSwitchedToBullish)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVSCBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVSCHHBearish)
|
|
{
|
|
bearishScore--;
|
|
}
|
|
if (isPVSCLLBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVSCSwitchedToBearish)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isPVMCBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVMCHHBullish)
|
|
{
|
|
bullishScore--;
|
|
}
|
|
if (isPVMCLLBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVMCSwitchedToBullish)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVMCBearish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVMCHHBearish)
|
|
{
|
|
bearishScore--;
|
|
}
|
|
if (isPVMCLLBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVMCSwitchedToBearish)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isPVLCBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVLCHHBullish)
|
|
{
|
|
bullishScore--;
|
|
}
|
|
if (isPVLCLLBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVLCSwitchedToBullish)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bullishScore--;
|
|
}
|
|
if (isPVLCBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVLCHHBearish)
|
|
{
|
|
bearishScore--;
|
|
}
|
|
if (isPVLCLLBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVLCSwitchedToBearish)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
if (isPVHCBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVHCHHBullish)
|
|
{
|
|
bullishScore--;
|
|
}
|
|
if (isPVHCLLBullish)
|
|
{
|
|
bullishScore++;
|
|
}
|
|
if (isPVHCSwitchedToBullish)
|
|
{
|
|
//
|
|
bullishScore++;
|
|
bearishScore--;
|
|
}
|
|
if (isPVHCBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVHCHHBearish)
|
|
{
|
|
bearishScore--;
|
|
}
|
|
if (isPVHCLLBearish)
|
|
{
|
|
bearishScore++;
|
|
}
|
|
if (isPVHCSwitchedToBearish)
|
|
{
|
|
//
|
|
bullishScore--;
|
|
bearishScore++;
|
|
}
|
|
}
|
|
|
|
//
|
|
virtual string GenerateSummary(
|
|
const bool onlySummary = false, // Only Generate Conditions Summary
|
|
double cMarketMultiplier = 1, // Current Market Score Multiplier
|
|
double sMarketMultiplier = 1.1, // Short Market Score Multiplier
|
|
double mMarketMultiplier = 1.2, // Medium Market Score Multiplier
|
|
double lMarketMultiplier = 1.6, // Long Market Score Multiplier
|
|
double hMarketMultiplier = 1.8, // Hind Market Score Multiplier
|
|
const string separator = "\n", // Separator
|
|
string provided = NULL, // Additional Info about Type, Provider and Symbol
|
|
const bool ignoreFalseConditions = true // Ignore False Conditions
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
double bullScore = 0;
|
|
double bearScore = 0;
|
|
GenerateScore(
|
|
bullScore,
|
|
bearScore,
|
|
cMarketMultiplier,
|
|
sMarketMultiplier,
|
|
mMarketMultiplier,
|
|
lMarketMultiplier,
|
|
hMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
string commonStr =
|
|
//
|
|
"Commons: " + separator +
|
|
"-----------------------------" + separator +
|
|
"Symbol: " + symbol + separator +
|
|
"Period: " + ToString(period) + separator +
|
|
"Time: " + ToString(TimeCurrent()) + separator +
|
|
"-----------" + separator +
|
|
"Cycles: " + separator +
|
|
"-----------" + separator +
|
|
sMarketConditions.GetTitle() + separator +
|
|
mMarketConditions.GetTitle() + separator +
|
|
lMarketConditions.GetTitle() + separator +
|
|
hMarketConditions.GetTitle() + separator +
|
|
"-----------" + separator +
|
|
"Scores: " + separator +
|
|
"-----------" + separator +
|
|
"Bullish: " + ToString(bullScore) + separator +
|
|
"Bearish: " + ToString(bearScore) + separator +
|
|
"-----------------------------" + separator +
|
|
//
|
|
// TODO: Add Scores Later ...
|
|
separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
// XZG ...
|
|
string zigzagStr =
|
|
//
|
|
ToString("isZigZagInPeak", isZigZagInPeak, ignoreFalseConditions) +
|
|
ToString("isZigZagInVale", isZigZagInVale, ignoreFalseConditions) +
|
|
""
|
|
//
|
|
;
|
|
zigzagStr = SetLabel("XZG: ", zigzagStr, separator);
|
|
|
|
//
|
|
// XDON ...
|
|
string donStr =
|
|
//
|
|
ToString("isDONAttachedMaxLower", isDONAttachedMaxLower, ignoreFalseConditions) +
|
|
ToString("isDONAttachedMinLower", isDONAttachedMinLower, ignoreFalseConditions) +
|
|
ToString("isDONCrossedOverMaxLower", isDONCrossedOverMaxLower, ignoreFalseConditions) +
|
|
ToString("isDONCrossedUnderMaxLower", isDONCrossedUnderMaxLower, ignoreFalseConditions) +
|
|
ToString("isDONAttachedMaxUpper", isDONAttachedMaxUpper, ignoreFalseConditions) +
|
|
ToString("isDONAttachedMinUpper", isDONAttachedMinUpper, ignoreFalseConditions) +
|
|
ToString("isDONCrossedOverMaxUpper", isDONCrossedOverMaxUpper, ignoreFalseConditions) +
|
|
ToString("isDONCrossedUnderMaxUpper", isDONCrossedUnderMaxUpper, ignoreFalseConditions) +
|
|
""
|
|
//
|
|
;
|
|
donStr = SetLabel("XDON: ", donStr, separator);
|
|
|
|
//
|
|
// XPV ...
|
|
string pvStr =
|
|
//
|
|
ToString("isPVPeakSameAs", isPVPeakSameAs, ignoreFalseConditions) +
|
|
ToString("isPVNewPeak", isPVNewPeak, ignoreFalseConditions) +
|
|
ToString("isPVNewPeakOverLast", isPVNewPeakOverLast, ignoreFalseConditions) +
|
|
ToString("isPVNewPeakUnderLast", isPVNewPeakUnderLast, ignoreFalseConditions) +
|
|
ToString("isPVValeSameAs", isPVValeSameAs, ignoreFalseConditions) +
|
|
ToString("isPVNewVale", isPVNewVale, ignoreFalseConditions) +
|
|
ToString("isPVNewValeOverLast", isPVNewValeOverLast, ignoreFalseConditions) +
|
|
ToString("isPVNewValeUnderLast", isPVNewValeUnderLast, ignoreFalseConditions) +
|
|
ToString("isPVFiboIncreased", isPVFiboIncreased, ignoreFalseConditions) +
|
|
ToString("isPVFiboDecreased", isPVFiboDecreased, ignoreFalseConditions) +
|
|
ToString("isPVFiboSectionChanged", isPVFiboSectionChanged, ignoreFalseConditions) +
|
|
ToString("isPVSCBullish", isPVSCBullish, ignoreFalseConditions) +
|
|
ToString("isPVSCHHBullish", isPVSCHHBullish, ignoreFalseConditions) +
|
|
ToString("isPVSCLLBullish", isPVSCLLBullish, ignoreFalseConditions) +
|
|
ToString("isPVSCSwitchedToBullish", isPVSCSwitchedToBullish, ignoreFalseConditions) +
|
|
ToString("isPVSCBearish", isPVSCBearish, ignoreFalseConditions) +
|
|
ToString("isPVSCHHBearish", isPVSCHHBearish, ignoreFalseConditions) +
|
|
ToString("isPVSCLLBearish", isPVSCLLBearish, ignoreFalseConditions) +
|
|
ToString("isPVSCSwitchedToBearish", isPVSCSwitchedToBearish, ignoreFalseConditions) +
|
|
ToString("isPVMCBullish", isPVMCBullish, ignoreFalseConditions) +
|
|
ToString("isPVMCHHBullish", isPVMCHHBullish, ignoreFalseConditions) +
|
|
ToString("isPVMCLLBullish", isPVMCLLBullish, ignoreFalseConditions) +
|
|
ToString("isPVMCSwitchedToBullish", isPVMCSwitchedToBullish, ignoreFalseConditions) +
|
|
ToString("isPVMCBearish", isPVMCBearish, ignoreFalseConditions) +
|
|
ToString("isPVMCHHBearish", isPVMCHHBearish, ignoreFalseConditions) +
|
|
ToString("isPVMCLLBearish", isPVMCLLBearish, ignoreFalseConditions) +
|
|
ToString("isPVMCSwitchedToBearish", isPVMCSwitchedToBearish, ignoreFalseConditions) +
|
|
ToString("isPVLCBullish", isPVLCBullish, ignoreFalseConditions) +
|
|
ToString("isPVLCHHBullish", isPVLCHHBullish, ignoreFalseConditions) +
|
|
ToString("isPVLCLLBullish", isPVLCLLBullish, ignoreFalseConditions) +
|
|
ToString("isPVLCSwitchedToBullish", isPVLCSwitchedToBullish, ignoreFalseConditions) +
|
|
ToString("isPVLCBearish", isPVLCBearish, ignoreFalseConditions) +
|
|
ToString("isPVLCHHBearish", isPVLCHHBearish, ignoreFalseConditions) +
|
|
ToString("isPVLCLLBearish", isPVLCLLBearish, ignoreFalseConditions) +
|
|
ToString("isPVLCSwitchedToBearish", isPVLCSwitchedToBearish, ignoreFalseConditions) +
|
|
ToString("isPVHCBullish", isPVHCBullish, ignoreFalseConditions) +
|
|
ToString("isPVHCHHBullish", isPVHCHHBullish, ignoreFalseConditions) +
|
|
ToString("isPVHCLLBullish", isPVHCLLBullish, ignoreFalseConditions) +
|
|
ToString("isPVHCSwitchedToBullish", isPVHCSwitchedToBullish, ignoreFalseConditions) +
|
|
ToString("isPVHCBearish", isPVHCBearish, ignoreFalseConditions) +
|
|
ToString("isPVHCHHBearish", isPVHCHHBearish, ignoreFalseConditions) +
|
|
ToString("isPVHCLLBearish", isPVHCLLBearish, ignoreFalseConditions) +
|
|
ToString("isPVHCSwitchedToBearish", isPVHCSwitchedToBearish, ignoreFalseConditions) +
|
|
""
|
|
//
|
|
;
|
|
pvStr = SetLabel("XPV: ", pvStr, separator);
|
|
|
|
//
|
|
string cMarketConditionsStr = cMarketConditions.GenerateSummary(onlySummary, cMarketMultiplier);
|
|
string sMarketConditionsStr = sMarketConditions.GenerateSummary(onlySummary, sMarketMultiplier);
|
|
string mMarketConditionsStr = mMarketConditions.GenerateSummary(onlySummary, mMarketMultiplier);
|
|
string lMarketConditionsStr = lMarketConditions.GenerateSummary(onlySummary, lMarketMultiplier);
|
|
string hMarketConditionsStr = hMarketConditions.GenerateSummary(onlySummary, hMarketMultiplier);
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetToken() + "]" + separator +
|
|
(IsSpecifiedValid(provided) ? provided + separator : "") +
|
|
"-----------------------------" + separator +
|
|
commonStr +
|
|
(!onlySummary
|
|
? zigzagStr +
|
|
donStr +
|
|
pvStr +
|
|
"======" + separator +
|
|
cMarketConditionsStr +
|
|
sMarketConditionsStr +
|
|
mMarketConditionsStr +
|
|
lMarketConditionsStr +
|
|
hMarketConditionsStr +
|
|
""
|
|
: "") +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// For Data Collector ...
|
|
string GetToken()
|
|
{
|
|
return GetSpecificToken(this);
|
|
}
|
|
bool IsModelValid()
|
|
{
|
|
return false;
|
|
}
|
|
string ToModelString()
|
|
{
|
|
return NULL;
|
|
}
|
|
bool ParseModel(string content)
|
|
{
|
|
return false;
|
|
}
|
|
int FindIndex(X121MarketConditions &items[])
|
|
{
|
|
return -1;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
|
|
//
|
|
// X121 Provider Class ...
|
|
class XSCX121Provider : public XSCBaseProvider
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XSCXCCHelper *ccHelper; // Candle Clear
|
|
XSCXCTHelper *ctHelper; // Candle Timer
|
|
XSCXZGHelper *zgHelper; // ZigZag Helper
|
|
XSCXPVHelper *pvHelper; // Peaks and Vales Helper
|
|
XSCXDONHelper *donHelper; // Donchain Helper;
|
|
|
|
//
|
|
XSCX121Market *cMarket; // Current Market
|
|
XSCX121Market *sMarket; // Short Market
|
|
XSCX121Market *mMarket; // Medium Market
|
|
XSCX121Market *lMarket; // Long Market
|
|
XSCX121Market *hMarket; // Hind Market
|
|
|
|
//
|
|
// Constructor ...
|
|
XSCX121Provider(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period // Trading PEriod
|
|
) : XSCBaseProvider(symbol, period)
|
|
{
|
|
//
|
|
ccHelper = new XSCXCCHelper();
|
|
ctHelper = new XSCXCTHelper();
|
|
|
|
//
|
|
// Instantiate Helpers Classes ...
|
|
zgHelper = new XSCXZGHelper();
|
|
pvHelper = new XSCXPVHelper();
|
|
donHelper = new XSCXDONHelper();
|
|
|
|
//
|
|
// Instantiate X121 Market Cycles Classes ...
|
|
cMarket = new XSCX121Market();
|
|
sMarket = new XSCX121Market();
|
|
mMarket = new XSCX121Market();
|
|
lMarket = new XSCX121Market();
|
|
hMarket = new XSCX121Market();
|
|
|
|
//
|
|
mNumberOfItems = 15;
|
|
mNumberOfSRVerified = 71;
|
|
mMinRequiredSupportAndResistances = 50;
|
|
}
|
|
|
|
//
|
|
// Properties Gettr(s) / Setter(s) ...
|
|
|
|
//
|
|
void SetNumberOfSRVerified(int value)
|
|
{
|
|
mNumberOfSRVerified = value;
|
|
}
|
|
|
|
//
|
|
int GetNumberOfSRVerified()
|
|
{
|
|
return mNumberOfSRVerified;
|
|
}
|
|
|
|
//
|
|
void SetNumberOfItems(int value)
|
|
{
|
|
mNumberOfItems = value;
|
|
}
|
|
|
|
//
|
|
int GetNumberOfItems()
|
|
{
|
|
return mNumberOfItems;
|
|
}
|
|
|
|
//
|
|
void SetMinRequiredSupportAndResistances(int value)
|
|
{
|
|
mMinRequiredSupportAndResistances = value;
|
|
}
|
|
|
|
//
|
|
int GetMinRequiredSupportAndResistances()
|
|
{
|
|
return mMinRequiredSupportAndResistances;
|
|
}
|
|
|
|
//
|
|
// Overrides ...
|
|
|
|
//
|
|
// DeInit all Requirements ...
|
|
void DeInit() override
|
|
{
|
|
//
|
|
delete ccHelper;
|
|
delete ctHelper;
|
|
|
|
//
|
|
delete zgHelper;
|
|
delete pvHelper;
|
|
delete donHelper;
|
|
|
|
//
|
|
delete cMarket;
|
|
delete sMarket;
|
|
delete mMarket;
|
|
delete lMarket;
|
|
delete hMarket;
|
|
}
|
|
|
|
//
|
|
// Functions ...
|
|
|
|
//
|
|
// Init all Requirements ...
|
|
bool Init(X121ProviderInputs &inputs)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate ...
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
string mSymbol = GetSymbol();
|
|
ENUM_TIMEFRAMES mPeriod = GetPeriod();
|
|
|
|
//
|
|
// Init Indicators Helpers ...
|
|
|
|
//
|
|
// CT ...
|
|
result = ctHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.ctInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// CC ...
|
|
result = ccHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.ccInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// ZigZag ...
|
|
result = zgHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.zgInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// PV ...
|
|
result = pvHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.pvInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// DON ...
|
|
result = donHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.donInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initialize X121 Market Cycles ...
|
|
|
|
//
|
|
// Current Market ...
|
|
result = cMarket
|
|
.Init(mInputs.cMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Short Market ...
|
|
result = sMarket
|
|
.Init(mInputs.sMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Medium Market ...
|
|
result = mMarket
|
|
.Init(mInputs.mMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Long Market ...
|
|
result = lMarket
|
|
.Init(mInputs.lMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Hind Market ...
|
|
result = hMarket
|
|
.Init(mInputs.hMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Default Position's Type ...
|
|
// Enable / Disable Long (Buy), Short (Sell) ...
|
|
void SetSignalTypeState(
|
|
ENUM_POSITION_TYPE type, // Which types are Signals be Targetted
|
|
bool state // Which State is going to Set
|
|
)
|
|
{
|
|
//
|
|
if (IsLong(type))
|
|
{
|
|
mIsLongEnable = state;
|
|
}
|
|
else
|
|
{
|
|
mIsShortEnable = state;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Set Signal Providers ...
|
|
void SetSignalProviderState(
|
|
ENUM_X121_SIGNAL_PROVIDERS provider, // Provider State
|
|
bool state // Which state is going to set ...
|
|
)
|
|
{
|
|
//
|
|
if (provider == X121NONE)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
switch (provider)
|
|
{
|
|
//
|
|
case X121XSP:
|
|
mIsX121XSPSignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case XTEST:
|
|
mIsXTESTSignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X786:
|
|
mIsX786SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X121:
|
|
mIsX121SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X110:
|
|
mIsX110SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X92:
|
|
mIsX92SignalProviderEnable = state;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
void SetSignalProviderStates(
|
|
ENUM_X121_SIGNAL_PROVIDERS &providers[], // Collection of Providers ...
|
|
bool state // Which state is going to set ...
|
|
)
|
|
{
|
|
//
|
|
int providersCount = ArraySize(providers);
|
|
if (providersCount <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < providersCount; i++)
|
|
{
|
|
SetSignalProviderState(providers[i], state);
|
|
}
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
result =
|
|
//
|
|
GetToken() +
|
|
"[" +
|
|
GetSymbol() +
|
|
"," +
|
|
ToString(GetPeriod()) +
|
|
"]"
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void GetMarketConditions(
|
|
X121MarketConditions &mConditions, // Market Conditions Result
|
|
int barIndex = 0 // Specified Bar Index
|
|
)
|
|
{
|
|
//
|
|
mConditions.Clear();
|
|
|
|
//
|
|
CalculateConditions(mConditions, barIndex);
|
|
}
|
|
|
|
//
|
|
// Check Market For Signal ...
|
|
bool HasSignal(
|
|
int barIndex,
|
|
XSignal &mSignal, // Hold's Signal if Exists ...
|
|
X121MarketConditions &mConditions // Hold's Market Conditions ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Enable Process ...
|
|
result = !CanIgnoreProcess();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mWaitsUntilNewBar = false;
|
|
|
|
//
|
|
// Validate Enable Type of Signalling ...
|
|
result = mIsLongEnable || mIsShortEnable;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Now we Have to Pass the Conditions to Each Signal Provider
|
|
// for Retrieving Signals Based On them ...
|
|
|
|
//
|
|
// Reading Market Conditions ...
|
|
GetMarketConditions(mConditions, barIndex);
|
|
AddScores(mConditions);
|
|
|
|
//
|
|
int signalPusher = 0;
|
|
bool hasLong = false;
|
|
bool hasShort = false;
|
|
string provider = "";
|
|
|
|
//
|
|
double providedSL = 0;
|
|
double providedTP = 0;
|
|
|
|
//
|
|
// Long ...
|
|
if (mIsLongEnable)
|
|
{
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
hasLong = HasSpecificSignal(
|
|
barIndex,
|
|
POSITION_TYPE_BUY,
|
|
provider,
|
|
signalPusher,
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
if (mIsShortEnable)
|
|
{
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
hasShort = HasSpecificSignal(
|
|
barIndex,
|
|
POSITION_TYPE_SELL,
|
|
provider,
|
|
signalPusher,
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
}
|
|
|
|
//
|
|
result = hasLong || hasShort;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Prepare Signal ...
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
// Here We Have to Prepare Signal ...
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
double tpPoint = 60;
|
|
double slPoint = 30;
|
|
double volume = 0.01;
|
|
double tpPrice = PointToPrice(
|
|
tpPoint,
|
|
symbol //
|
|
);
|
|
double slPrice = PointToPrice(
|
|
slPoint,
|
|
symbol //
|
|
);
|
|
ENUM_POSITION_TYPE type = hasLong
|
|
? POSITION_TYPE_BUY
|
|
: POSITION_TYPE_SELL;
|
|
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
|
double entry = GetEntry(
|
|
symbol,
|
|
type //
|
|
);
|
|
|
|
//
|
|
double tp = 0;
|
|
double sl = 0;
|
|
|
|
//
|
|
ENUM_X_SIGNAL_MANAGING_ACTIONS action = X_SIGNAL_USE_NOTHING;
|
|
|
|
//
|
|
// TODO: Make Configurable ...
|
|
double r2r = 2;
|
|
|
|
//
|
|
sl = 0;
|
|
tp = 0;
|
|
|
|
//
|
|
// TP based on SL and Risk to Reward ...
|
|
if (providedSL > 0)
|
|
{
|
|
//
|
|
sl = providedSL;
|
|
|
|
//
|
|
double risk = MathAbs(entry - sl);
|
|
|
|
//
|
|
double reward = risk * r2r;
|
|
|
|
//
|
|
tp = hasLong
|
|
? entry + reward
|
|
: entry - reward;
|
|
}
|
|
else
|
|
//
|
|
// SL based on TP and Risk to Reward ...
|
|
if (providedTP > 0)
|
|
{
|
|
//
|
|
tp = providedTP;
|
|
|
|
//
|
|
double reward = MathAbs(entry - tp);
|
|
|
|
//
|
|
double risk = reward / r2r;
|
|
|
|
//
|
|
sl = hasLong
|
|
? entry - risk
|
|
: entry + risk;
|
|
}
|
|
|
|
//
|
|
result = mSignal.Prepare(
|
|
symbol,
|
|
provider,
|
|
period,
|
|
type,
|
|
mode,
|
|
entry,
|
|
volume,
|
|
action,
|
|
sl,
|
|
tp
|
|
//
|
|
);
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
mWaitsUntilNewBar = true;
|
|
|
|
// //
|
|
// TODO:
|
|
// string providerTypeStr = GetSymbol() + ", " + provider + "(" + (hasLong ? "Long" : "Short") + ")";
|
|
// string mConditionsStr = mConditions.GenerateSummary(providerTypeStr, true);
|
|
// mConditionsCollector.Add(mConditionsStr);
|
|
// Print(mConditionsStr);
|
|
}
|
|
}
|
|
|
|
//
|
|
UpdateSupportsAndResistances();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check for any Guards ...
|
|
bool HasGuard(XGuard &guards[])
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Try to Find Support and Resistances if Configured ...
|
|
FindSupportAndResistances();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
void Draw()
|
|
{
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
ulong chID = FindChartID(
|
|
symbol,
|
|
period);
|
|
if (chID < 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int subWindow = 0;
|
|
|
|
//
|
|
int offset = 0;
|
|
|
|
//
|
|
cMarket.Draw(chID, subWindow, offset);
|
|
sMarket.Draw(chID, subWindow, offset);
|
|
mMarket.Draw(chID, subWindow, offset);
|
|
lMarket.Draw(chID, subWindow, offset);
|
|
hMarket.Draw(chID, subWindow, offset);
|
|
}
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
|
|
//
|
|
int CountSupportResistances()
|
|
{
|
|
return ArraySize(mSupportResistances);
|
|
}
|
|
|
|
//
|
|
bool GenerateSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
ENUM_POSITION_TYPE type, // Position Type ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (count <= 0)
|
|
{
|
|
count = 1;
|
|
}
|
|
|
|
//
|
|
if (step <= 0)
|
|
{
|
|
//
|
|
if (useAtrAsStep)
|
|
{
|
|
step = cMarket.osc.GetATR(0);
|
|
}
|
|
else
|
|
{
|
|
step = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
supRes.Clean();
|
|
|
|
//
|
|
double price = GetExit(
|
|
GetSymbol(),
|
|
type //
|
|
);
|
|
|
|
//
|
|
result = supRes.Init(
|
|
price,
|
|
mSupportResistances,
|
|
count,
|
|
step);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GenerateLongSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = GenerateSupRes(
|
|
supRes,
|
|
POSITION_TYPE_BUY,
|
|
count,
|
|
step,
|
|
useAtrAsStep //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GenerateShortSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = GenerateSupRes(
|
|
supRes,
|
|
POSITION_TYPE_BUY,
|
|
count,
|
|
step,
|
|
useAtrAsStep //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Peask and Vales Finder ...
|
|
|
|
//
|
|
double GetMinPeaks()
|
|
{
|
|
//
|
|
double cPeak = cMarket.pv.GetPeak(0);
|
|
double sPeak = sMarket.pv.GetPeak(0);
|
|
double mPeak = mMarket.pv.GetPeak(0);
|
|
double lPeak = lMarket.pv.GetPeak(0);
|
|
double hPeak = hMarket.pv.GetPeak(0);
|
|
|
|
//
|
|
double peaks[] = {
|
|
cPeak,
|
|
sPeak,
|
|
mPeak,
|
|
lPeak,
|
|
hPeak //
|
|
};
|
|
|
|
//
|
|
double minPeak = GetMin(peaks);
|
|
double maxPeak = GetMax(peaks);
|
|
|
|
//
|
|
return minPeak;
|
|
}
|
|
|
|
//
|
|
double GetMaxPeaks()
|
|
{
|
|
//
|
|
double cPeak = cMarket.pv.GetPeak(0);
|
|
double sPeak = sMarket.pv.GetPeak(0);
|
|
double mPeak = mMarket.pv.GetPeak(0);
|
|
double lPeak = lMarket.pv.GetPeak(0);
|
|
double hPeak = hMarket.pv.GetPeak(0);
|
|
|
|
//
|
|
double peaks[] = {
|
|
cPeak,
|
|
sPeak,
|
|
mPeak,
|
|
lPeak,
|
|
hPeak //
|
|
};
|
|
|
|
//
|
|
double minPeak = GetMin(peaks);
|
|
double maxPeak = GetMax(peaks);
|
|
|
|
//
|
|
return maxPeak;
|
|
}
|
|
|
|
//
|
|
double GetMinVales()
|
|
{
|
|
//
|
|
double cMVale = cMarket.pv.GetVale(0);
|
|
double sMVale = sMarket.pv.GetVale(0);
|
|
double mMVale = mMarket.pv.GetVale(0);
|
|
double lMVale = lMarket.pv.GetVale(0);
|
|
double hMVale = hMarket.pv.GetVale(0);
|
|
|
|
//
|
|
double vales[] = {
|
|
cMVale,
|
|
sMVale,
|
|
mMVale,
|
|
lMVale,
|
|
hMVale //
|
|
};
|
|
|
|
//
|
|
double minVale = GetMin(vales);
|
|
double maxVale = GetMax(vales);
|
|
|
|
//
|
|
return minVale;
|
|
}
|
|
|
|
//
|
|
double GetMaxVales()
|
|
{
|
|
//
|
|
double cMVale = cMarket.pv.GetVale(0);
|
|
double sMVale = sMarket.pv.GetVale(0);
|
|
double mMVale = mMarket.pv.GetVale(0);
|
|
double lMVale = lMarket.pv.GetVale(0);
|
|
double hMVale = hMarket.pv.GetVale(0);
|
|
|
|
//
|
|
double vales[] = {
|
|
cMVale,
|
|
sMVale,
|
|
mMVale,
|
|
lMVale,
|
|
hMVale //
|
|
};
|
|
|
|
//
|
|
double minVale = GetMin(vales);
|
|
double maxVale = GetMax(vales);
|
|
|
|
//
|
|
return maxVale;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
X121ProviderInputs mInputs;
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
|
|
//
|
|
// Check has Enough Support and Resistance ...
|
|
bool HasEnoughSupportAndResistance()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mNumberOfSRVerified <= 0 ||
|
|
mMinRequiredSupportAndResistances <= 0)
|
|
{
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
int currentSRsCount = CountSupportResistances();
|
|
result = currentSRsCount >= mMinRequiredSupportAndResistances;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Update Bar Index base Support and Resistances ....
|
|
void UpdateSupportsAndResistances(
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
if (mNumberOfSRVerified <= 0 ||
|
|
mMinRequiredSupportAndResistances <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int before = CountSupportResistances();
|
|
|
|
//
|
|
// XICH ...
|
|
|
|
//
|
|
// Current ...
|
|
|
|
//
|
|
if (cMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = cMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (cMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = cMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (cMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = cMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
if (sMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = sMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (sMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = sMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (sMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = sMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Medium ...
|
|
|
|
//
|
|
if (mMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = mMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (mMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = mMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (mMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = mMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Long ...
|
|
|
|
//
|
|
if (lMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = lMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (lMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = lMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (lMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = lMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Hind ...
|
|
|
|
//
|
|
if (hMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = hMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (hMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = hMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (hMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = hMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// XDON ...
|
|
|
|
//
|
|
if (donHelper.IsSameUpperO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperO = donHelper.GetUpperO(barIndex);
|
|
AddSRValue(selectedUpperO);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameLowerO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerO = donHelper.GetLowerO(barIndex);
|
|
AddSRValue(selectedLowerO);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameUpperC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperC = donHelper.GetUpperC(barIndex);
|
|
AddSRValue(selectedUpperC);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameLowerC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerC = donHelper.GetLowerC(barIndex);
|
|
AddSRValue(selectedLowerC);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameUpperH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperH = donHelper.GetUpperH(barIndex);
|
|
AddSRValue(selectedUpperH);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameLowerH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerH = donHelper.GetLowerH(barIndex);
|
|
AddSRValue(selectedLowerH);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameUpperL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperL = donHelper.GetUpperL(barIndex);
|
|
AddSRValue(selectedUpperL);
|
|
}
|
|
|
|
//
|
|
if (donHelper.IsSameLowerL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerL = donHelper.GetLowerL(barIndex);
|
|
AddSRValue(selectedLowerL);
|
|
}
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
if (pvHelper.IsSamePeak(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedPeak = pvHelper.GetPeak(barIndex);
|
|
AddSRValue(selectedPeak);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameVale(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedVale = pvHelper.GetVale(barIndex);
|
|
AddSRValue(selectedVale);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameFib1(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib1 = pvHelper.GetFib1(barIndex);
|
|
AddSRValue(selectedFib1);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameFib2(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib2 = pvHelper.GetFib2(barIndex);
|
|
AddSRValue(selectedFib2);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameFib3(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib3 = pvHelper.GetFib3(barIndex);
|
|
AddSRValue(selectedFib3);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameFib4(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib4 = pvHelper.GetFib4(barIndex);
|
|
AddSRValue(selectedFib4);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameFib5(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib5 = pvHelper.GetFib5(barIndex);
|
|
AddSRValue(selectedFib5);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameSCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCHH = pvHelper.GetSCHH(barIndex);
|
|
AddSRValue(selectedSCHH);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameSCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCLL = pvHelper.GetSCLL(barIndex);
|
|
AddSRValue(selectedSCLL);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameMCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCHH = pvHelper.GetMCHH(barIndex);
|
|
AddSRValue(selectedMCHH);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameMCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCLL = pvHelper.GetMCLL(barIndex);
|
|
AddSRValue(selectedMCLL);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameLCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCHH = pvHelper.GetLCHH(barIndex);
|
|
AddSRValue(selectedLCHH);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameLCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCLL = pvHelper.GetLCLL(barIndex);
|
|
AddSRValue(selectedLCLL);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameHCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCHH = pvHelper.GetHCHH(barIndex);
|
|
AddSRValue(selectedHCHH);
|
|
}
|
|
|
|
//
|
|
if (pvHelper.IsSameHCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCLL = pvHelper.GetHCLL(barIndex);
|
|
AddSRValue(selectedHCLL);
|
|
}
|
|
|
|
//
|
|
int after = CountSupportResistances();
|
|
|
|
//
|
|
if (after > before)
|
|
{
|
|
//
|
|
string message = "Found: " + ToString(after - before) + " new Pivot ...";
|
|
Print(message);
|
|
}
|
|
}
|
|
|
|
//
|
|
void FindSupportAndResistances()
|
|
{
|
|
//
|
|
bool hasEnough = HasEnoughSupportAndResistance();
|
|
if (hasEnough)
|
|
{
|
|
//
|
|
// if (IsNewBar())
|
|
// {
|
|
// UpdateSupportsAndResistances();
|
|
// }
|
|
return;
|
|
}
|
|
|
|
//
|
|
int idx = 0;
|
|
while (!HasEnoughSupportAndResistance())
|
|
{
|
|
//
|
|
UpdateSupportsAndResistances(idx);
|
|
|
|
//
|
|
if (HasEnoughSupportAndResistance())
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
idx += 50;
|
|
|
|
//
|
|
// Print("idx: " + ToString(idx) + ", Count: " + ToString(CountSupportResistances()));
|
|
Print("Pivots: " + ToString(CountSupportResistances()));
|
|
}
|
|
}
|
|
|
|
//
|
|
void AddSRValue(double value)
|
|
{
|
|
//
|
|
if (value <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddIfNotExists(
|
|
value,
|
|
mSupportResistances //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
int mNumberOfItems; // Number of Buffer Ites Read in Conditions ...
|
|
|
|
//
|
|
// Support and Resistance ...
|
|
|
|
//
|
|
int mNumberOfSRVerified; // Number of Verifications for Selecting Support and Resistances ...
|
|
|
|
//
|
|
int mMinRequiredSupportAndResistances; // Minimum Requirement Supports and Resistances ...
|
|
|
|
//
|
|
double mSupportResistances[]; // Holds Supports and Resistances ...
|
|
|
|
//
|
|
// Bullish and Bearish Scores ...
|
|
|
|
//
|
|
double mBullishScore[];
|
|
double mBearishScore[];
|
|
|
|
//
|
|
// Store Market Conditions Scores ...
|
|
void AddScores(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
ArraySetAsSeries(mBullishScore, false);
|
|
ArraySetAsSeries(mBearishScore, false);
|
|
|
|
//
|
|
Add(
|
|
bullishScore,
|
|
mBullishScore //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
bearishScore,
|
|
mBearishScore //
|
|
);
|
|
|
|
//
|
|
ArraySetAsSeries(mBullishScore, true);
|
|
ArraySetAsSeries(mBearishScore, true);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Score Averages ...
|
|
double GetBullishScoreAverage(
|
|
int start = 0,
|
|
int count = 7 //
|
|
)
|
|
{
|
|
//
|
|
return GetAverage(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Scores Max Value ...
|
|
double GetBullishScoreMax(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMax(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Scores Min Value ...
|
|
double GetBullishScoreMin(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMin(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Score Averages ...
|
|
double GetBearishScoreAverage(
|
|
int start = 0,
|
|
int count = 7 //
|
|
)
|
|
{
|
|
//
|
|
return GetAverage(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Scores Max Value ...
|
|
double GetBearishScoreMax(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMax(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Scores Min Value ...
|
|
double GetBearishScoreMin(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMin(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Signallers ...
|
|
|
|
//
|
|
bool mIsLongEnable;
|
|
bool mIsShortEnable;
|
|
|
|
//
|
|
bool mIsX121XSPSignalProviderEnable;
|
|
bool mIsX92SignalProviderEnable;
|
|
bool mIsX786SignalProviderEnable;
|
|
bool mIsX121SignalProviderEnable;
|
|
bool mIsX110SignalProviderEnable;
|
|
bool mIsXTESTSignalProviderEnable;
|
|
|
|
//
|
|
//
|
|
// Detect Signal ...
|
|
bool HasSpecificSignal(
|
|
int barIndex, // Specified Bar Index ...
|
|
ENUM_POSITION_TYPE mType, // Specific Signal Type ...
|
|
string &provider, // Signal Provider ...
|
|
int &signalPusher, // Number Of Same Time Signals ...
|
|
X121MarketConditions &mConditions, // Specified Market Conition ...
|
|
double &providedSL,
|
|
double &providedTP //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Signal Type is Enables ...
|
|
bool isLong = IsLong(mType);
|
|
result =
|
|
(isLong && mIsLongEnable) ||
|
|
(!isLong && mIsShortEnable);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Now we have to Filter based on Enabled Signal Providers ...
|
|
|
|
//
|
|
// Long ...
|
|
if (isLong && mIsLongEnable)
|
|
{
|
|
//
|
|
XSignal lSignal;
|
|
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
bool hasX121XSPSignal = false;
|
|
bool hasXTESTSignal = false;
|
|
bool hasX786Signal = false;
|
|
bool hasX121Signal = false;
|
|
bool hasX110Signal = false;
|
|
bool hasX92Signal = false;
|
|
|
|
//
|
|
// XPS ...
|
|
if (mIsX121XSPSignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121XSPSignal = X121XSPHasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX121XSPSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121XSP);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// XTEST ...
|
|
if (mIsXTESTSignalProviderEnable)
|
|
{
|
|
//
|
|
hasXTESTSignal = XTESTHasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasXTESTSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(XTEST);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X786 ...
|
|
if (mIsX786SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX786Signal = X786HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX786Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X786);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X121 ...
|
|
if (mIsX121SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121Signal = X121HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX121Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X110 ...
|
|
if (mIsX110SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX110Signal = X110HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX110Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X110);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X92 ...
|
|
if (mIsX92SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX92Signal = X92HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX92Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X92);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasX121XSPSignal
|
|
//
|
|
||
|
|
//
|
|
hasXTESTSignal
|
|
//
|
|
||
|
|
//
|
|
hasX786Signal
|
|
//
|
|
||
|
|
//
|
|
hasX121Signal
|
|
//
|
|
||
|
|
//
|
|
hasX110Signal
|
|
//
|
|
||
|
|
//
|
|
hasX92Signal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
if (!isLong && mIsShortEnable)
|
|
{
|
|
//
|
|
XSignal sSignal;
|
|
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
bool hasX121XSPSignal = false;
|
|
bool hasXTESTSignal = false;
|
|
bool hasX786Signal = false;
|
|
bool hasX121Signal = false;
|
|
bool hasX110Signal = false;
|
|
bool hasX92Signal = false;
|
|
|
|
//
|
|
// X121XSP ...
|
|
if (mIsX121XSPSignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121XSPSignal = X121XSPHasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX121XSPSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121XSP);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// XTEST ...
|
|
if (mIsXTESTSignalProviderEnable)
|
|
{
|
|
//
|
|
hasXTESTSignal = XTESTHasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasXTESTSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(XTEST);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X786 ...
|
|
if (mIsX786SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX786Signal = X786HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX786Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X786);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X121 ...
|
|
if (mIsX121SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121Signal = X121HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX121Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X110 ...
|
|
if (mIsX110SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX110Signal = X110HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX110Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X110);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X92 ...
|
|
if (mIsX92SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX92Signal = X92HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP //
|
|
);
|
|
|
|
//
|
|
if (hasX92Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X92);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasX121XSPSignal
|
|
//
|
|
||
|
|
//
|
|
hasXTESTSignal
|
|
//
|
|
||
|
|
//
|
|
hasX786Signal
|
|
//
|
|
||
|
|
//
|
|
hasX121Signal
|
|
//
|
|
||
|
|
//
|
|
hasX110Signal
|
|
//
|
|
||
|
|
//
|
|
hasX92Signal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void CalculateConditions(
|
|
X121MarketConditions &mConditions, // Market Conditions Result
|
|
int barIndex = 0 // Specified Bar Index
|
|
)
|
|
{
|
|
//
|
|
mConditions.Clear();
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
if (barIndex >= CountBars())
|
|
{
|
|
barIndex = CountBars() + 2;
|
|
}
|
|
|
|
//
|
|
int curr = barIndex + 1;
|
|
int prev = curr + 1;
|
|
|
|
//
|
|
mConditions.symbol = GetSymbol();
|
|
mConditions.period = GetPeriod();
|
|
mConditions.time = iTime(
|
|
mConditions.symbol,
|
|
mConditions.period,
|
|
barIndex //
|
|
);
|
|
|
|
//
|
|
GetBars(
|
|
mConditions.bars,
|
|
mConditions.symbol,
|
|
mConditions.period,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
// XZG ...
|
|
|
|
//
|
|
zgHelper.CopyMain(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.zigzags //
|
|
);
|
|
|
|
//
|
|
zgHelper.CopyPeaksAndVales(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.zigzagPVs //
|
|
);
|
|
|
|
//
|
|
// Looking for Vale ...
|
|
bool isZigZagInPeak = mConditions.zigzags[curr] < mConditions.zigzagPVs[curr];
|
|
mConditions.isZigZagInPeak = isZigZagInPeak;
|
|
|
|
//
|
|
// Looking for Peak ...
|
|
bool isZigZagInVale = mConditions.zigzags[curr] > mConditions.zigzagPVs[curr];
|
|
mConditions.isZigZagInVale = isZigZagInVale;
|
|
|
|
//
|
|
// XDON ...
|
|
|
|
//
|
|
donHelper.CopyUpperO(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donUpperOs //
|
|
);
|
|
donHelper.CopyLowerO(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donLowerOs //
|
|
);
|
|
donHelper.CopyUpperC(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donUpperCs //
|
|
);
|
|
donHelper.CopyLowerC(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donLowerCs //
|
|
);
|
|
donHelper.CopyUpperH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donUpperHs //
|
|
);
|
|
donHelper.CopyLowerH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donLowerHs //
|
|
);
|
|
donHelper.CopyUpperL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donUpperLs //
|
|
);
|
|
donHelper.CopyLowerL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.donLowerLs //
|
|
);
|
|
|
|
//
|
|
// Upper ...
|
|
|
|
//
|
|
double donUpperO = mConditions.donUpperOs[curr];
|
|
double donUpperOPrev = mConditions.donUpperOs[prev];
|
|
|
|
//
|
|
double donUpperC = mConditions.donUpperCs[curr];
|
|
double donUpperCPrev = mConditions.donUpperCs[prev];
|
|
|
|
//
|
|
double donUpperH = mConditions.donUpperHs[curr];
|
|
double donUpperHPrev = mConditions.donUpperHs[prev];
|
|
|
|
//
|
|
double donUpperL = mConditions.donUpperLs[curr];
|
|
double donUpperLPrev = mConditions.donUpperLs[prev];
|
|
|
|
//
|
|
double donUppers[] = {
|
|
donUpperO,
|
|
donUpperC,
|
|
donUpperH,
|
|
donUpperL //
|
|
};
|
|
double maxDonUpper = GetMax(donUppers);
|
|
double minDonUpper = GetMin(donUppers);
|
|
|
|
//
|
|
double donUpperPrevs[] = {
|
|
donUpperOPrev,
|
|
donUpperCPrev,
|
|
donUpperHPrev,
|
|
donUpperLPrev //
|
|
};
|
|
double maxDonUpperPrev = GetMax(donUpperPrevs);
|
|
double minDonUpperPrev = GetMin(donUpperPrevs);
|
|
|
|
//
|
|
// Lower ...
|
|
|
|
//
|
|
double donLowerO = mConditions.donLowerOs[curr];
|
|
double donLowerOPrev = mConditions.donLowerOs[prev];
|
|
|
|
//
|
|
double donLowerC = mConditions.donLowerCs[curr];
|
|
double donLowerCPrev = mConditions.donLowerCs[prev];
|
|
|
|
//
|
|
double donLowerH = mConditions.donLowerHs[curr];
|
|
double donLowerHPrev = mConditions.donLowerHs[prev];
|
|
|
|
//
|
|
double donLowerL = mConditions.donLowerLs[curr];
|
|
double donLowerLPrev = mConditions.donLowerLs[prev];
|
|
|
|
//
|
|
double donLowers[] = {
|
|
donLowerO,
|
|
donLowerC,
|
|
donLowerH,
|
|
donLowerL //
|
|
};
|
|
double maxDonLower = GetMax(donLowers);
|
|
double minDonLower = GetMin(donLowers);
|
|
|
|
//
|
|
double donLowerPrevs[] = {
|
|
donLowerOPrev,
|
|
donLowerCPrev,
|
|
donLowerHPrev,
|
|
donLowerLPrev //
|
|
};
|
|
double maxDonLowerPrev = GetMax(donLowerPrevs);
|
|
double minDonLowerPrev = GetMin(donLowerPrevs);
|
|
|
|
//
|
|
bool isDONAttachedMaxLower = mConditions.bars[curr].low == maxDonLower;
|
|
bool isDONAttachedMinLower = mConditions.bars[curr].low == minDonLower;
|
|
bool isDONCrossedOverMaxLower =
|
|
//
|
|
((mConditions.bars[curr].low > maxDonLower) ||
|
|
(mConditions.bars[curr].close > maxDonLower))
|
|
//
|
|
&&
|
|
//
|
|
((mConditions.bars[prev].high <= maxDonLower) ||
|
|
(mConditions.bars[prev].open <= maxDonLower))
|
|
//
|
|
;
|
|
bool isDONCrossedUnderMaxLower =
|
|
//
|
|
((mConditions.bars[curr].low < maxDonLower) ||
|
|
(mConditions.bars[curr].close < maxDonLower))
|
|
//
|
|
&&
|
|
//
|
|
((mConditions.bars[prev].high >= maxDonLower) ||
|
|
(mConditions.bars[prev].open >= maxDonLower))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isDONAttachedMaxUpper = mConditions.bars[curr].high == maxDonUpper;
|
|
bool isDONAttachedMinUpper = mConditions.bars[curr].high == minDonUpper;
|
|
bool isDONCrossedOverMaxUpper =
|
|
//
|
|
((mConditions.bars[curr].low > maxDonUpper) ||
|
|
(mConditions.bars[curr].close > maxDonUpper))
|
|
//
|
|
&&
|
|
//
|
|
((mConditions.bars[prev].high <= maxDonUpper) ||
|
|
(mConditions.bars[prev].open <= maxDonUpper))
|
|
//
|
|
;
|
|
bool isDONCrossedUnderMaxUpper =
|
|
//
|
|
((mConditions.bars[curr].low < maxDonUpper) ||
|
|
(mConditions.bars[curr].close < maxDonUpper))
|
|
//
|
|
&&
|
|
//
|
|
((mConditions.bars[prev].high >= maxDonUpper) ||
|
|
(mConditions.bars[prev].open >= maxDonUpper))
|
|
//
|
|
;
|
|
|
|
//
|
|
mConditions.isDONAttachedMaxLower = isDONAttachedMaxLower;
|
|
mConditions.isDONAttachedMinLower = isDONAttachedMinLower;
|
|
mConditions.isDONCrossedOverMaxLower = isDONCrossedOverMaxLower;
|
|
mConditions.isDONCrossedUnderMaxLower = isDONCrossedUnderMaxLower;
|
|
|
|
//
|
|
mConditions.isDONAttachedMaxUpper = isDONAttachedMaxUpper;
|
|
mConditions.isDONAttachedMinUpper = isDONAttachedMinUpper;
|
|
mConditions.isDONCrossedOverMaxUpper = isDONCrossedOverMaxUpper;
|
|
mConditions.isDONCrossedUnderMaxUpper = isDONCrossedUnderMaxUpper;
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
pvHelper.CopyPeak(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvPeaks //
|
|
);
|
|
pvHelper.CopyVale(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvVales //
|
|
);
|
|
pvHelper.CopyResistance(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvResistances //
|
|
);
|
|
pvHelper.CopySupport(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvSupports //
|
|
);
|
|
pvHelper.CopyFib1(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvFib1s //
|
|
);
|
|
pvHelper.CopyFib2(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvFib2s //
|
|
);
|
|
pvHelper.CopyFib3(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvFib3s //
|
|
);
|
|
pvHelper.CopyFib4(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvFib4s //
|
|
);
|
|
pvHelper.CopyFib5(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvFib5s //
|
|
);
|
|
pvHelper.CopySCHH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvSCHHs //
|
|
);
|
|
pvHelper.CopySCLL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvSCLLs //
|
|
);
|
|
pvHelper.CopyMCHH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvMCHHs //
|
|
);
|
|
pvHelper.CopyMCLL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvMCLLs //
|
|
);
|
|
pvHelper.CopyLCHH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvLCHHs //
|
|
);
|
|
pvHelper.CopyLCLL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvLCLLs //
|
|
);
|
|
pvHelper.CopyHCHH(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvHCHHs //
|
|
);
|
|
pvHelper.CopyHCLL(
|
|
barIndex,
|
|
mNumberOfItems,
|
|
mConditions.pvHCLLs //
|
|
);
|
|
|
|
//
|
|
double pvPeak = mConditions.pvPeaks[curr];
|
|
double pvPeakPrev = mConditions.pvPeaks[prev];
|
|
|
|
//
|
|
double pvVale = mConditions.pvVales[curr];
|
|
double pvValePrev = mConditions.pvVales[prev];
|
|
|
|
//
|
|
double pvFib1 = mConditions.pvFib1s[curr];
|
|
double pvFib2 = mConditions.pvFib2s[curr];
|
|
double pvFib3 = mConditions.pvFib3s[curr];
|
|
double pvFib4 = mConditions.pvFib4s[curr];
|
|
double pvFib5 = mConditions.pvFib5s[curr];
|
|
|
|
//
|
|
double pvFib1Prev = mConditions.pvFib1s[prev];
|
|
double pvFib2Prev = mConditions.pvFib2s[prev];
|
|
double pvFib3Prev = mConditions.pvFib3s[prev];
|
|
double pvFib4Prev = mConditions.pvFib4s[prev];
|
|
double pvFib5Prev = mConditions.pvFib5s[prev];
|
|
|
|
//
|
|
bool isPVPeakSameAs = IsSame(mConditions.pvPeaks);
|
|
bool isPVNewPeak = NotEmpty(pvPeak) && pvPeak != pvPeakPrev;
|
|
bool isPVNewPeakOverLast = isPVNewPeak && pvPeak > pvPeakPrev;
|
|
bool isPVNewPeakUnderLast = isPVNewPeak && pvPeak < pvPeakPrev;
|
|
bool isPVValeSameAs = IsSame(mConditions.pvVales);
|
|
bool isPVNewVale = NotEmpty(pvVale) && pvVale != pvValePrev;
|
|
bool isPVNewValeOverLast = isPVNewVale && pvVale > pvValePrev;
|
|
bool isPVNewValeUnderLast = isPVNewVale && pvVale < pvValePrev;
|
|
bool isPVFiboIncreased =
|
|
//
|
|
pvFib1 > pvFib1Prev &&
|
|
pvFib2 > pvFib2Prev &&
|
|
pvFib3 > pvFib3Prev &&
|
|
pvFib4 > pvFib4Prev &&
|
|
pvFib5 > pvFib5Prev
|
|
//
|
|
;
|
|
bool isPVFiboDecreased =
|
|
//
|
|
pvFib1 < pvFib1Prev &&
|
|
pvFib2 < pvFib2Prev &&
|
|
pvFib3 < pvFib3Prev &&
|
|
pvFib4 < pvFib4Prev &&
|
|
pvFib5 < pvFib5Prev
|
|
//
|
|
;
|
|
|
|
bool isPVFiboSectionChanged =
|
|
//
|
|
(isPVNewPeakUnderLast && isPVFiboDecreased)
|
|
//
|
|
||
|
|
//
|
|
(isPVNewValeOverLast && isPVFiboIncreased)
|
|
//
|
|
;
|
|
|
|
//
|
|
mConditions.isPVPeakSameAs = isPVPeakSameAs;
|
|
mConditions.isPVNewPeak = isPVNewPeak;
|
|
mConditions.isPVNewPeakOverLast = isPVNewPeakOverLast;
|
|
mConditions.isPVNewPeakUnderLast = isPVNewPeakUnderLast;
|
|
mConditions.isPVValeSameAs = isPVValeSameAs;
|
|
mConditions.isPVNewVale = isPVNewVale;
|
|
mConditions.isPVNewValeOverLast = isPVNewValeOverLast;
|
|
mConditions.isPVNewValeUnderLast = isPVNewValeUnderLast;
|
|
mConditions.isPVFiboIncreased = isPVFiboIncreased;
|
|
mConditions.isPVFiboDecreased = isPVFiboDecreased;
|
|
mConditions.isPVFiboSectionChanged = isPVFiboSectionChanged;
|
|
|
|
//
|
|
// XPV Cycles ...
|
|
|
|
//
|
|
double pvSCHH = mConditions.pvSCHHs[curr];
|
|
double pvSCLL = mConditions.pvSCLLs[curr];
|
|
double pvMCHH = mConditions.pvMCHHs[curr];
|
|
double pvMCLL = mConditions.pvMCLLs[curr];
|
|
double pvLCHH = mConditions.pvLCHHs[curr];
|
|
double pvLCLL = mConditions.pvLCLLs[curr];
|
|
double pvHCHH = mConditions.pvHCHHs[curr];
|
|
double pvHCLL = mConditions.pvHCLLs[curr];
|
|
|
|
//
|
|
double pvSCHHPrev = mConditions.pvSCHHs[prev];
|
|
double pvSCLLPrev = mConditions.pvSCLLs[prev];
|
|
double pvMCHHPrev = mConditions.pvMCHHs[prev];
|
|
double pvMCLLPrev = mConditions.pvMCLLs[prev];
|
|
double pvLCHHPrev = mConditions.pvLCHHs[prev];
|
|
double pvLCLLPrev = mConditions.pvLCLLs[prev];
|
|
double pvHCHHPrev = mConditions.pvHCHHs[prev];
|
|
double pvHCLLPrev = mConditions.pvHCLLs[prev];
|
|
|
|
//
|
|
double pvSCHHPrevPrev = mConditions.pvSCHHs[prev + 1];
|
|
double pvSCLLPrevPrev = mConditions.pvSCLLs[prev + 1];
|
|
double pvMCHHPrevPrev = mConditions.pvMCHHs[prev + 1];
|
|
double pvMCLLPrevPrev = mConditions.pvMCLLs[prev + 1];
|
|
double pvLCHHPrevPrev = mConditions.pvLCHHs[prev + 1];
|
|
double pvLCLLPrevPrev = mConditions.pvLCLLs[prev + 1];
|
|
double pvHCHHPrevPrev = mConditions.pvHCHHs[prev + 1];
|
|
double pvHCLLPrevPrev = mConditions.pvHCLLs[prev + 1];
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
bool isPVSCHHBullish = pvSCHH > pvSCHHPrev;
|
|
bool isPVSCHHBullishPrev = pvSCHHPrev > pvSCHHPrevPrev;
|
|
bool isPVSCLLBullish = pvSCLL > pvSCLLPrev;
|
|
bool isPVSCLLBullishPrev = pvSCLLPrev > pvSCLLPrevPrev;
|
|
bool isPVSCBullish =
|
|
//
|
|
isPVSCHHBullish &&
|
|
isPVSCLLBullish
|
|
//
|
|
;
|
|
bool isPVSCBullishPrev =
|
|
//
|
|
isPVSCHHBullishPrev &&
|
|
isPVSCLLBullishPrev
|
|
//
|
|
;
|
|
bool isPVSCSwitchedToBullish =
|
|
//
|
|
isPVSCBullish &&
|
|
!isPVSCBullishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPVSCHHBearish = pvSCHH < pvSCHHPrev;
|
|
bool isPVSCHHBearishPrev = pvSCHHPrev < pvSCHHPrevPrev;
|
|
bool isPVSCLLBearish = pvSCLL < pvSCLLPrev;
|
|
bool isPVSCLLBearishPrev = pvSCLLPrev < pvSCLLPrevPrev;
|
|
bool isPVSCBearish =
|
|
//
|
|
isPVSCHHBearish &&
|
|
isPVSCLLBearish
|
|
//
|
|
;
|
|
bool isPVSCBearishPrev =
|
|
//
|
|
isPVSCHHBearishPrev &&
|
|
isPVSCLLBearishPrev
|
|
//
|
|
;
|
|
bool isPVSCSwitchedToBearish =
|
|
//
|
|
isPVSCBearish &&
|
|
!isPVSCBearishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
// Medium ...
|
|
|
|
//
|
|
bool isPVMCHHBullish = pvMCHH > pvMCHHPrev;
|
|
bool isPVMCHHBullishPrev = pvMCHHPrev > pvMCHHPrevPrev;
|
|
bool isPVMCLLBullish = pvMCLL > pvMCLLPrev;
|
|
bool isPVMCLLBullishPrev = pvMCLLPrev > pvMCLLPrevPrev;
|
|
bool isPVMCBullish =
|
|
//
|
|
isPVMCHHBullish &&
|
|
isPVMCLLBullish
|
|
//
|
|
;
|
|
bool isPVMCBullishPrev =
|
|
//
|
|
isPVMCHHBullishPrev &&
|
|
isPVMCLLBullishPrev
|
|
//
|
|
;
|
|
bool isPVMCSwitchedToBullish =
|
|
//
|
|
isPVMCBullish &&
|
|
!isPVMCBullishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPVMCHHBearish = pvMCHH < pvMCHHPrev;
|
|
bool isPVMCHHBearishPrev = pvMCHHPrev < pvMCHHPrevPrev;
|
|
bool isPVMCLLBearish = pvMCLL < pvMCLLPrev;
|
|
bool isPVMCLLBearishPrev = pvMCLLPrev < pvMCLLPrevPrev;
|
|
bool isPVMCBearish =
|
|
//
|
|
isPVMCHHBearish &&
|
|
isPVMCLLBearish
|
|
//
|
|
;
|
|
bool isPVMCBearishPrev =
|
|
//
|
|
isPVMCHHBearishPrev &&
|
|
isPVMCLLBearishPrev
|
|
//
|
|
;
|
|
bool isPVMCSwitchedToBearish =
|
|
//
|
|
isPVMCBearish &&
|
|
!isPVMCBearishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
// Long ...
|
|
|
|
//
|
|
bool isPVLCHHBullish = pvLCHH > pvLCHHPrev;
|
|
bool isPVLCHHBullishPrev = pvLCHHPrev > pvLCHHPrevPrev;
|
|
bool isPVLCLLBullish = pvLCLL > pvLCLLPrev;
|
|
bool isPVLCLLBullishPrev = pvLCLLPrev > pvLCLLPrevPrev;
|
|
bool isPVLCBullish =
|
|
//
|
|
isPVLCHHBullish &&
|
|
isPVLCLLBullish
|
|
//
|
|
;
|
|
bool isPVLCBullishPrev =
|
|
//
|
|
isPVLCHHBullishPrev &&
|
|
isPVLCLLBullishPrev
|
|
//
|
|
;
|
|
bool isPVLCSwitchedToBullish =
|
|
//
|
|
isPVLCBullish &&
|
|
!isPVLCBullishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPVLCHHBearish = pvLCHH < pvLCHHPrev;
|
|
bool isPVLCHHBearishPrev = pvLCHHPrev < pvLCHHPrevPrev;
|
|
bool isPVLCLLBearish = pvLCLL < pvLCLLPrev;
|
|
bool isPVLCLLBearishPrev = pvLCLLPrev < pvLCLLPrevPrev;
|
|
bool isPVLCBearish =
|
|
//
|
|
isPVLCHHBearish &&
|
|
isPVLCLLBearish
|
|
//
|
|
;
|
|
bool isPVLCBearishPrev =
|
|
//
|
|
isPVLCHHBearishPrev &&
|
|
isPVLCLLBearishPrev
|
|
//
|
|
;
|
|
bool isPVLCSwitchedToBearish =
|
|
//
|
|
isPVLCBearish &&
|
|
!isPVLCBearishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
// Hind ...
|
|
|
|
//
|
|
bool isPVHCHHBullish = pvHCHH > pvHCHHPrev;
|
|
bool isPVHCHHBullishPrev = pvHCHHPrev > pvHCHHPrevPrev;
|
|
bool isPVHCLLBullish = pvHCLL > pvHCLLPrev;
|
|
bool isPVHCLLBullishPrev = pvHCLLPrev > pvHCLLPrevPrev;
|
|
bool isPVHCBullish =
|
|
//
|
|
isPVHCHHBullish &&
|
|
isPVHCLLBullish
|
|
//
|
|
;
|
|
bool isPVHCBullishPrev =
|
|
//
|
|
isPVHCHHBullishPrev &&
|
|
isPVHCLLBullishPrev
|
|
//
|
|
;
|
|
bool isPVHCSwitchedToBullish =
|
|
//
|
|
isPVHCBullish &&
|
|
!isPVHCBullishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPVHCHHBearish = pvHCHH < pvHCHHPrev;
|
|
bool isPVHCHHBearishPrev = pvHCHHPrev < pvHCHHPrevPrev;
|
|
bool isPVHCLLBearish = pvHCLL < pvHCLLPrev;
|
|
bool isPVHCLLBearishPrev = pvHCLLPrev < pvHCLLPrevPrev;
|
|
bool isPVHCBearish =
|
|
//
|
|
isPVHCHHBearish &&
|
|
isPVHCLLBearish
|
|
//
|
|
;
|
|
bool isPVHCBearishPrev =
|
|
//
|
|
isPVHCHHBearishPrev &&
|
|
isPVHCLLBearishPrev
|
|
//
|
|
;
|
|
bool isPVHCSwitchedToBearish =
|
|
//
|
|
isPVHCBearish &&
|
|
!isPVHCBearishPrev
|
|
//
|
|
;
|
|
|
|
//
|
|
mConditions.isPVSCHHBullish = isPVSCHHBullish;
|
|
mConditions.isPVSCLLBullish = isPVSCLLBullish;
|
|
mConditions.isPVSCBullish = isPVSCBullish;
|
|
mConditions.isPVSCSwitchedToBullish = isPVSCSwitchedToBullish;
|
|
mConditions.isPVSCHHBearish = isPVSCHHBearish;
|
|
mConditions.isPVSCLLBearish = isPVSCLLBearish;
|
|
mConditions.isPVSCBearish = isPVSCBearish;
|
|
mConditions.isPVSCSwitchedToBearish = isPVSCSwitchedToBearish;
|
|
mConditions.isPVMCHHBullish = isPVMCHHBullish;
|
|
mConditions.isPVMCLLBullish = isPVMCLLBullish;
|
|
mConditions.isPVMCBullish = isPVMCBullish;
|
|
mConditions.isPVMCSwitchedToBullish = isPVMCSwitchedToBullish;
|
|
mConditions.isPVMCHHBearish = isPVMCHHBearish;
|
|
mConditions.isPVMCLLBearish = isPVMCLLBearish;
|
|
mConditions.isPVMCBearish = isPVMCBearish;
|
|
mConditions.isPVMCSwitchedToBearish = isPVMCSwitchedToBearish;
|
|
mConditions.isPVLCHHBullish = isPVLCHHBullish;
|
|
mConditions.isPVLCLLBullish = isPVLCLLBullish;
|
|
mConditions.isPVLCBullish = isPVLCBullish;
|
|
mConditions.isPVLCSwitchedToBullish = isPVLCSwitchedToBullish;
|
|
mConditions.isPVLCHHBearish = isPVLCHHBearish;
|
|
mConditions.isPVLCLLBearish = isPVLCLLBearish;
|
|
mConditions.isPVLCBearish = isPVLCBearish;
|
|
mConditions.isPVLCSwitchedToBearish = isPVLCSwitchedToBearish;
|
|
mConditions.isPVHCHHBullish = isPVHCHHBullish;
|
|
mConditions.isPVHCLLBullish = isPVHCLLBullish;
|
|
mConditions.isPVHCBullish = isPVHCBullish;
|
|
mConditions.isPVHCSwitchedToBullish = isPVHCSwitchedToBullish;
|
|
mConditions.isPVHCHHBearish = isPVHCHHBearish;
|
|
mConditions.isPVHCLLBearish = isPVHCLLBearish;
|
|
mConditions.isPVHCBearish = isPVHCBearish;
|
|
mConditions.isPVHCSwitchedToBearish = isPVHCSwitchedToBearish;
|
|
|
|
//
|
|
// X121 Cycles Conditions ...
|
|
|
|
//
|
|
cMarket.GetMarketConditions(
|
|
mConditions.cMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
sMarket.GetMarketConditions(
|
|
mConditions.sMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
mMarket.GetMarketConditions(
|
|
mConditions.mMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
lMarket.GetMarketConditions(
|
|
mConditions.lMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
hMarket.GetMarketConditions(
|
|
mConditions.hMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Signalling based On Signallers ...
|
|
|
|
//
|
|
// X121XSP ...
|
|
|
|
//
|
|
bool X121XSPHasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool XTESTHasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE and XSTR ...
|
|
bool X786HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO: Remove this ...
|
|
return result;
|
|
|
|
//
|
|
// Check For Long ...
|
|
bool isSTRLong =
|
|
//
|
|
(mConditions.hMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.sMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isCHELong =
|
|
//
|
|
(mConditions.hMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.sMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
isSTRLong
|
|
//
|
|
&&
|
|
//
|
|
isCHELong
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XMC ...
|
|
bool X121HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
sl = 0;
|
|
tp = 0;
|
|
|
|
//
|
|
// Current Market ...
|
|
bool isCMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.cMarketConditions.isSlowOverVerifier &&
|
|
mConditions.cMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isFastOverVerifier &&
|
|
mConditions.cMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Medium Market ...
|
|
bool isMMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.mMarketConditions.isSlowOverVerifier &&
|
|
mConditions.mMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isFastOverVerifier &&
|
|
mConditions.mMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Long Market ...
|
|
bool isLMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.lMarketConditions.isSlowOverVerifier &&
|
|
mConditions.lMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isFastOverVerifier &&
|
|
mConditions.lMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Hind Market ...
|
|
bool isHMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.hMarketConditions.isSlowOverVerifier &&
|
|
mConditions.hMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.hMarketConditions.isFastOverVerifier &&
|
|
mConditions.hMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
isCMCLong
|
|
//
|
|
||
|
|
//
|
|
isMMCLong
|
|
//
|
|
||
|
|
//
|
|
isLMCLong
|
|
//
|
|
||
|
|
//
|
|
isHMCLong
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
sl = GetMinPeaks();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE ...
|
|
bool X110HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use Scores ...
|
|
bool X92HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// return false;
|
|
|
|
//
|
|
double bullishScore = mBullishScore[0];
|
|
double bullishMin100 = GetBullishScoreMin(0, 100);
|
|
double bullishMax100 = GetBullishScoreMax(0, 100);
|
|
double bullish7AVG = GetBullishScoreAverage(0, 7);
|
|
double bullish21AVG = GetBullishScoreAverage(0, 21);
|
|
|
|
//
|
|
double bearishScore = mBearishScore[0];
|
|
double bearishMin100 = GetBearishScoreMin(0, 100);
|
|
double bearishMax100 = GetBearishScoreMax(0, 100);
|
|
double bearish7AVG = GetBearishScoreAverage(0, 7);
|
|
double bearish21AVG = GetBearishScoreAverage(0, 21);
|
|
|
|
//
|
|
bool isBullishOverAVGs =
|
|
//
|
|
bullishScore > bearishScore &&
|
|
bullishScore > bullish7AVG &&
|
|
bullishScore > bullish21AVG
|
|
//
|
|
;
|
|
|
|
//
|
|
if (isBullishOverAVGs)
|
|
{
|
|
sl = GetMinVales();
|
|
}
|
|
|
|
// //
|
|
// bool isBearishEqualOverMax100 =
|
|
// //
|
|
// bearishScore > bearish7AVG &&
|
|
// bearishScore > bearish21AVG &&
|
|
// bearishScore >= bearishMax100
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// if (isBearishEqualOverMax100)
|
|
// {
|
|
// sl = 0; // GetMaxVales() - PointToPrice(100, GetSymbol());
|
|
// }
|
|
|
|
//
|
|
result =
|
|
//
|
|
isBullishOverAVGs
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool X121XSPHasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool XTESTHasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE and XSTR ...
|
|
bool X786HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO: Remove this ...
|
|
return result;
|
|
|
|
//
|
|
// Check For Short ...
|
|
bool isSTRShort =
|
|
//
|
|
(mConditions.hMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.sMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isCHEShort =
|
|
//
|
|
(mConditions.hMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.sMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
isSTRShort
|
|
//
|
|
&&
|
|
//
|
|
isCHEShort
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XMC ...
|
|
bool X121HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO: Remove this ...
|
|
return result;
|
|
|
|
//
|
|
bool isCMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.cMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.cMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.cMarketConditions.isFastUnderVerifier &&
|
|
mConditions.cMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isMMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.mMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.mMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isFastUnderVerifier &&
|
|
mConditions.mMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isLMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.lMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.lMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isFastUnderVerifier &&
|
|
mConditions.lMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.hMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.hMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.hMarketConditions.isFastUnderVerifier &&
|
|
mConditions.hMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
isCMCShort
|
|
//
|
|
||
|
|
//
|
|
isMMCShort
|
|
//
|
|
||
|
|
//
|
|
isLMCShort
|
|
//
|
|
||
|
|
//
|
|
isHMCShort
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
sl = GetMaxPeaks();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE ...
|
|
bool X110HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use Scores ...
|
|
bool X92HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp // Provided TP ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
double bullishScore = mBullishScore[0];
|
|
double bullishMin100 = GetBullishScoreMin(0, 71);
|
|
double bullishMax100 = GetBullishScoreMax(0, 71);
|
|
double bullish7AVG = GetBullishScoreAverage(0, 7);
|
|
double bullish21AVG = GetBullishScoreAverage(0, 21);
|
|
|
|
//
|
|
double bearishScore = mBearishScore[0];
|
|
double bearishMin100 = GetBearishScoreMin(0, 71);
|
|
double bearishMax100 = GetBearishScoreMax(0, 71);
|
|
double bearish7AVG = GetBearishScoreAverage(0, 7);
|
|
double bearish21AVG = GetBearishScoreAverage(0, 21);
|
|
|
|
//
|
|
bool isBearishOverAVGs =
|
|
//
|
|
bearishScore > bullishScore &&
|
|
bearishScore > bearish7AVG &&
|
|
bearishScore > bearish21AVG
|
|
//
|
|
;
|
|
|
|
//
|
|
if (isBearishOverAVGs)
|
|
{
|
|
sl = GetMaxPeaks();
|
|
}
|
|
|
|
// //
|
|
// bool isBullishEqualOverMax100 =
|
|
// //
|
|
// bullishScore > bullish7AVG &&
|
|
// bullishScore > bullish21AVG &&
|
|
// bullishScore >= bullishMax100
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// if (isBullishEqualOverMax100)
|
|
// {
|
|
// sl = GetMaxPeaks();
|
|
// }
|
|
|
|
//
|
|
result =
|
|
//
|
|
isBearishOverAVGs
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Model Provider Descriptor ...
|
|
struct X121ProviderDescriptor
|
|
{
|
|
//
|
|
string symbol; // Trading Symbol
|
|
ENUM_TIMEFRAMES period; // Trading Timeframe
|
|
bool allowLong; // Allow Long Signals
|
|
bool allowShort; // Allow Short Signals
|
|
ENUM_X121_SIGNAL_PROVIDERS signallers[]; // Allowed Signal Providers
|
|
|
|
//
|
|
X121ProviderInputs inputs;
|
|
XSCX121Provider *provider;
|
|
|
|
//
|
|
XSignal signal;
|
|
X121MarketConditions conditions;
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = this.Init(
|
|
this.symbol,
|
|
this.period,
|
|
this.signallers,
|
|
this.allowLong,
|
|
this.allowShort //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool Init(
|
|
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
|
|
bool mAllowLong = true, // Allow Long Signals
|
|
bool mAllowShort = true // Allow Short Signals
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = this.Init(
|
|
this.symbol,
|
|
this.period,
|
|
mSignallers,
|
|
mAllowLong,
|
|
mAllowShort //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool Init(
|
|
string mSymbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES mPeriod, // Trading Timeframe
|
|
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
|
|
bool mAllowLong = true, // Allow Long Signals
|
|
bool mAllowShort = true // Allow Short Signals
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
inputs.IsValid() &&
|
|
IsValid(mSymbol) &&
|
|
IsValid(mPeriod) &&
|
|
(allowLong || allowShort) &&
|
|
ArraySize(mSignallers) > 0
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
this.symbol = mSymbol;
|
|
this.period = mPeriod;
|
|
this.allowLong = mAllowLong;
|
|
this.allowShort = mAllowShort;
|
|
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS tmp[];
|
|
Copy(
|
|
mSignallers,
|
|
tmp //
|
|
);
|
|
Copy(
|
|
tmp,
|
|
this.signallers //
|
|
);
|
|
|
|
//
|
|
// Instantiate Provider ...
|
|
provider = new XSCX121Provider(
|
|
this.symbol,
|
|
this.period //
|
|
);
|
|
|
|
//
|
|
// Set Long/Short State ...
|
|
|
|
//
|
|
provider
|
|
.SetSignalTypeState(
|
|
POSITION_TYPE_BUY,
|
|
this.allowLong //
|
|
);
|
|
|
|
//
|
|
provider
|
|
.SetSignalTypeState(
|
|
POSITION_TYPE_SELL,
|
|
this.allowShort //
|
|
);
|
|
|
|
//
|
|
// Enable Required Signallers ...
|
|
provider
|
|
.SetSignalProviderStates(
|
|
this.signallers,
|
|
true //
|
|
);
|
|
|
|
//
|
|
// Now Must to Initialize Provider ...
|
|
result = provider.Init(
|
|
this.inputs //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
signal.Clean();
|
|
conditions.Clear();
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid(bool validateInputs = true)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(symbol) &&
|
|
IsValid(period) &&
|
|
(validateInputs
|
|
? inputs.IsValid()
|
|
: true) &&
|
|
(allowLong || allowShort) &&
|
|
ArraySize(signallers) > 0
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Signal ...
|
|
bool HasSignal(int barIndex = 0)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Clear Signal and Conditions ...
|
|
Clean();
|
|
|
|
//
|
|
result = provider.HasSignal(
|
|
barIndex,
|
|
signal,
|
|
conditions //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
void GetAllX121SignalProviders(ENUM_X121_SIGNAL_PROVIDERS &result[])
|
|
{
|
|
//
|
|
Clean(result);
|
|
|
|
//
|
|
Add(X121NONE, result);
|
|
Add(X121XSP, result);
|
|
Add(XTEST, result);
|
|
Add(X786, result);
|
|
Add(X121, result);
|
|
Add(X110, result);
|
|
Add(X92, result);
|
|
}
|
|
|
|
//
|
|
string ToString(ENUM_X121_SIGNAL_PROVIDERS value)
|
|
{
|
|
return EnumToString(value);
|
|
}
|
|
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS ToX121SignalProvider(string content)
|
|
{
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS result = X121NONE;
|
|
|
|
//
|
|
if (!IsValid(content))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (content == ToString(X121NONE))
|
|
{
|
|
result = X121NONE;
|
|
}
|
|
else if (content == ToString(X121XSP))
|
|
{
|
|
result = X121XSP;
|
|
}
|
|
else if (content == ToString(XTEST))
|
|
{
|
|
result = XTEST;
|
|
}
|
|
else if (content == ToString(X786))
|
|
{
|
|
result = X786;
|
|
}
|
|
else if (content == ToString(X121))
|
|
{
|
|
result = X121;
|
|
}
|
|
else if (content == ToString(X110))
|
|
{
|
|
result = X110;
|
|
}
|
|
else if (content == ToString(X92))
|
|
{
|
|
result = X92;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// |