Files
xMQL5/MQLTestWorkspace/BKPS/14030322/Classes/x-saherelm.x121.xmcycle.class.mq5
T

5857 lines
153 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSC121MCycle
// Description: provides all requirements for
// Handling Specified Market Cycle Analysis...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
//
#include "../Libraries/x-saherelm.draw.lib.mq5"
//
#include "../Helpers/x-saherelm.xtd.helper.mq5"
#include "../Helpers/x-saherelm.xhk.helper.mq5"
#include "../Helpers/x-saherelm.xmc.helper.mq5"
#include "../Helpers/x-saherelm.xpv.helper.mq5"
#include "../Helpers/x-saherelm.xzg.helper.mq5"
#include "../Helpers/x-saherelm.xmrb.helper.mq5"
#include "../Helpers/x-saherelm.xdon.helper.mq5"
#include "../Helpers/x-saherelm.xche.helper.mq5"
#include "../Helpers/x-saherelm.xosc.helper.mq5"
#include "../Helpers/x-saherelm.xstr.helper.mq5"
#include "../Helpers/x-saherelm.xich.helper.mq5"
#include "../Helpers/x-saherelm.xasct.helper.mq5"
#include "../Helpers/x-saherelm.xhull.helper.mq5"
#include "../Helpers/x-saherelm.xsslc.helper.mq5"
//
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
#include "../Classes/x-saherelm.xalert.class.mq5"
//
// Definitions ...
//
// Signallers ...
enum ENUM_XSIGNAL_PROVIDERS
{
//
PROVIDER_NONE,
XSP,
XTEST,
X786,
X121,
X110,
X92,
X128,
};
//
void GetAllXSignalProviders(ENUM_XSIGNAL_PROVIDERS &result[])
{
//
Clean(result);
//
Add(XSP, result);
Add(XTEST, result);
Add(X786, result);
Add(X121, result);
Add(X110, result);
Add(X92, result);
Add(X128, result);
}
//
string ToString(ENUM_XSIGNAL_PROVIDERS value)
{
return EnumToString(value);
}
//
ENUM_XSIGNAL_PROVIDERS ToXSignalProvider(string content)
{
//
ENUM_XSIGNAL_PROVIDERS result = PROVIDER_NONE;
//
if (!IsValid(content))
{
return result;
}
//
if (content == ToString(PROVIDER_NONE))
{
result = PROVIDER_NONE;
}
else if (content == ToString(XSP))
{
result = XSP;
}
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;
}
else if (content == ToString(X128))
{
result = X128;
}
//
return result;
}
//
// X121 Specified Market Cycle Structure ...
class X121MCycleInputs : public XSCBase
{
//
// Public ...
public:
//
// Props ...
//
XMarketCycle cycle; // Cycle Descriptor ...
//
// Draw Props ...
//
XDrawSpecifications cBarMidDrawSpecs; // Current Bar MidLine Draw Specifications
XOHCLDrawSpecification cBarDrawSpecs; // Current Bar Draw Specifications
//
XDrawSpecifications pBarMidDrawSpecs; // Previous Bar MidLine Draw Specifications
XOHCLDrawSpecification pBarDrawSpecs; // Previous Bar Draw Specifications
//
bool drawLabels; // Draw Labels
bool drawCBar; // Draw Current Bar
bool drawPBar; // Draw Previous Bar
bool drawCBarMid; // Draw Current Bar Mid Line
bool drawPBarMid; // Draw Previous Bar Mid Line
//
XHKInputs hkInputs; // HK Inputs ...
XMCInputs mcInputs; // MC Inputs ...
XPVInputs pvInputs; // PV Inputs ...
XZGInputs zgInputs; // ZG Inputs ...
XTDInputs tdInputs; // TD Inputs ...
XMRBInputs mrbInputs; // MRB Inputs ...
XSTRInputs strInputs; // STR Inputs ...
XOSCInputs oscInputs; // OSC Inputs ...
XCHEInputs cheInputs; // CHE Inputs ...
XICHInputs ichInputs; // ICH Inputs ...
XDONInputs donInputs; // DON Inputs ...
XASCTInputs asctInputs; // ASCT Inputs ...
XHULLInputs hullInputs; // HULL Inputs ...
XSSLCInputs sslcInputs; // SSLC Inputs ...
//
// Constructor ...
//
// Tools ...
//
// Initialize Market Cycle ...
bool Init(
string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mHostPeriod, // Host Period
ENUM_X_MARKET_CYCLES mCycle, // Init Cycle
ENUM_TIMEFRAMES mPeriod, // Cycle Period
ENUM_X_PERIOD_METHOD mPeriodMethod, // Cycle Period Method
string mPrefix = "", // Prefix
bool useDefaults = true // Use Inputs Default Settings ...
)
{
//
bool result = false;
//
cycle.period = mPeriod;
cycle.method = mPeriodMethod;
//
// Initial Cycle Model ...
result = cycle.Init(
mSymbol,
mHostPeriod,
mCycle,
mPrefix
//
);
if (!result)
{
return result;
}
//
if (useDefaults)
{
//
hkInputs.Default();
mcInputs.Default();
pvInputs.Default();
zgInputs.Default();
mrbInputs.Default();
strInputs.Default();
oscInputs.Default();
cheInputs.Default();
ichInputs.Default();
donInputs.Default();
hullInputs.Default();
sslcInputs.Default();
}
//
result = IsValid();
if (!result)
{
return result;
}
//
return result;
}
//
// Initialize Market Cycle ...
bool Init(
string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mHostPeriod, // Host Period
ENUM_X_MARKET_CYCLES mCycle, // Init Cycle
XHKInputs &mHkInputs, // HK Inputs
XMCInputs &mMcInputs, // MC Inputs
XPVInputs &mPvInputs, // PV Inputs ...
XZGInputs &mZgInputs, // ZG Inputs ...
XTDInputs &mTdInputs, // TD Inputs ...
XMRBInputs &mMrbInputs, // MRB Inputs ...
XSTRInputs &mStrInputs, // STR Inputs
XOSCInputs &mOscInputs, // OSC Inputs
XCHEInputs &mCheInputs, // CHE Inputs
XICHInputs &mIchInputs, // ICH Inputs ...
XDONInputs &mDonInputs, // DON Inputs ...
XASCTInputs &mAsctInputs, // ASCT Inputs
XHULLInputs &mHullInputs, // HULL Inputs ...
XSSLCInputs &mSslcInputs, // SSLC Inputs ...
int mHostBarIndex = 0, // Specified Host Period Bar Index
string mPrefix = "" // Prefix
)
{
//
bool result = false;
//
// Initial Cycle Model ...
result = cycle.Init(
mSymbol,
mHostPeriod,
mCycle,
mPrefix
//
);
if (!result)
{
return result;
}
//
hkInputs = mHkInputs;
mcInputs = mMcInputs;
pvInputs = mPvInputs;
zgInputs = mZgInputs;
tdInputs = mTdInputs;
mrbInputs = mMrbInputs;
strInputs = mStrInputs;
oscInputs = mOscInputs;
cheInputs = mCheInputs;
ichInputs = mIchInputs;
donInputs = mDonInputs;
asctInputs = mAsctInputs;
hullInputs = mHullInputs;
sslcInputs = mSslcInputs;
//
result = IsValid();
if (!result)
{
return result;
}
//
return result;
}
//
// Cleanup ...
virtual void Clean()
{
//
cycle.Clean();
//
hkInputs.Clean();
mcInputs.Clean();
pvInputs.Clean();
zgInputs.Clean();
tdInputs.Clean();
mrbInputs.Clean();
strInputs.Clean();
oscInputs.Clean();
cheInputs.Clean();
ichInputs.Clean();
donInputs.Clean();
asctInputs.Clean();
hullInputs.Clean();
sslcInputs.Clean();
//
cBarDrawSpecs.Clean();
pBarDrawSpecs.Clean();
cBarMidDrawSpecs.Clean();
pBarMidDrawSpecs.Clean();
//
drawLabels = false;
drawCBar = false;
drawPBar = false;
drawCBarMid = false;
drawPBarMid = false;
}
//
// Default ...
virtual void Default()
{
//
hkInputs.Default();
mcInputs.Default();
pvInputs.Default();
zgInputs.Default();
tdInputs.Default();
mrbInputs.Default();
strInputs.Default();
oscInputs.Default();
cheInputs.Default();
ichInputs.Default();
donInputs.Default();
asctInputs.Default();
hullInputs.Default();
sslcInputs.Default();
//
drawLabels = false;
drawCBar = false;
drawPBar = false;
drawCBarMid = false;
drawPBarMid = false;
}
//
// Validation ...
virtual bool IsValid()
{
//
bool result = false;
//
result = cycle.IsValid();
if (!result)
{
return result;
}
//
result = hkInputs.IsValid();
if (!result)
{
return result;
}
//
result = mcInputs.IsValid();
if (!result)
{
return result;
}
//
result = pvInputs.IsValid();
if (!result)
{
return result;
}
//
result = zgInputs.IsValid();
if (!result)
{
return result;
}
//
result = tdInputs.IsValid();
if (!result)
{
return result;
}
//
result = mrbInputs.IsValid();
if (!result)
{
return result;
}
//
result = strInputs.IsValid();
if (!result)
{
return result;
}
//
result = oscInputs.IsValid();
if (!result)
{
return result;
}
//
result = cheInputs.IsValid();
if (!result)
{
return result;
}
//
result = ichInputs.IsValid();
if (!result)
{
return result;
}
//
result = donInputs.IsValid();
if (!result)
{
return result;
}
//
result = hullInputs.IsValid();
if (!result)
{
return result;
}
//
result = asctInputs.IsValid();
if (!result)
{
return result;
}
//
result = sslcInputs.IsValid();
if (!result)
{
return result;
}
//
return result;
}
//
// Max ...
virtual int Max()
{
//
int result = 0;
//
result = MathMax(mcInputs.Max(), strInputs.Max());
//
result = MathMax(result, hkInputs.Max());
result = MathMax(result, mcInputs.Max());
result = MathMax(result, pvInputs.Max());
result = MathMax(result, zgInputs.Max());
result = MathMax(result, tdInputs.Max());
result = MathMax(result, mrbInputs.Max());
result = MathMax(result, strInputs.Max());
result = MathMax(result, oscInputs.Max());
result = MathMax(result, cheInputs.Max());
result = MathMax(result, ichInputs.Max());
result = MathMax(result, donInputs.Max());
result = MathMax(result, asctInputs.Max());
result = MathMax(result, hullInputs.Max());
result = MathMax(result, sslcInputs.Max());
//
return result;
}
};
//
// Specific Market Sense Based on Specified Bar Index on Host Period ...
class X121MCycleConditions : public XSCBase
{
//
// Public ...
public:
//
// Props ...
datetime time; // Time
string symbol; // Symbol
ENUM_TIMEFRAMES period; // Period
//
string prefix; // Cycle Prefix
ENUM_X_MARKET_CYCLES cycle; // Init Cycle
ENUM_TIMEFRAMES hostPeriod; // Hosting Time Frame
//
XOHCL bars[]; // Number of Bars
//
// Candlestic Conditions ...
bool isLastBullish;
bool isLastBearish;
bool isCurrentBullish;
bool isCurrentBearish;
bool isCurrentMidLineOverLastHigh;
bool isCurrentMidLineUnderLastLow;
bool isCurrentMidLineOverLastUp;
bool isCurrentMidLineUnderLastDown;
bool isCurrentMidLineOverLastMidLine;
bool isCurrentMidLineUnderLastMidLine;
//
// Buffers ...
//
XOHCL hkBars[];
XOHCL smHKBars[];
//
// XASCT ...
double asctLongs[];
double asctShorts[];
//
// XICH ...
double ichTenkanSens[];
double ichKijunSens[];
double ichChikouSpans[];
double ichSenkouSpanAs[];
double ichSenkouSpanBs[];
double ichFutureSenkouSpanAs[];
double ichFutureSenkouSpanBs[];
//
// XMC ...
double mcFasts[];
double mcSlows[];
double mcVerifiers[];
//
// XSTR ...
double strTrends[];
double strStates[];
//
// XZG ...
double zigzags[];
double zigzagPVs[];
//
// XHULL ...
double hullUps[];
double hullDowns[];
//
// XSSLC ...
double sslcUps[];
double sslcDowns[];
//
// XMRB ...
//
double mrbFasts[];
double mrb1Fasts[];
double mrb2Fasts[];
double mrb3Fasts[];
double mrb4Fasts[];
double mrb5Fasts[];
double mrb6Fasts[];
//
double mrbSlows[];
double mrb1Slows[];
double mrb2Slows[];
double mrb3Slows[];
double mrb4Slows[];
double mrb5Slows[];
double mrb6Slows[];
//
// XCHE ...
double cheLongExit1s[];
double cheLongExit2s[];
double cheShortExit1s[];
double cheShortExit2s[];
//
// XDON ...
double donUpperOs[];
double donLowerOs[];
double donUpperCs[];
double donLowerCs[];
double donUpperHs[];
double donLowerHs[];
double donUpperLs[];
double donLowerLs[];
//
// 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[];
//
// XOSC ...
double oscAtrs[];
double oscRviMains[];
double oscRviSignals[];
double oscBullPs[];
double oscBearPs[];
double oscVolumes[];
double oscRsis[];
double oscCcis[];
double oscMomentums[];
double oscSars[];
double oscMacdMains[];
double oscMacdSignals[];
double oscStochMains[];
double oscStochSignals[];
double oscStddevs[];
//
// XTD ...
double tdBullishs[];
double tdBearishs[];
double tdSignals[];
//
// General Conditions ...
//
// XZG ...
bool isZigZagInPeak;
bool isZigZagInVale;
//
// XASCT ...
bool isASCTLong;
bool isASCTShort;
//
// XHULL ...
bool isHullBullish;
bool isHullBearish;
bool isHullUpBullish;
bool isHullUpBearish;
bool isHullDownBullish;
bool isHullDownBearish;
bool isHullSwitchedToBullish;
bool isHullSwitchedToBearish;
//
// XSSLC ...
bool isSSLCBullish;
bool isSSLCBearish;
bool isSSLCSwitchedToBullish;
bool isSSLCSwitchedToBearish;
//
// XPV ...
//
bool isNewPeak;
bool isNewPeakOverLast;
bool isNewPeakUnderLast;
//
bool isNewVale;
bool isNewValeOverLast;
bool isNewValeUnderLast;
//
bool isFiboIncreased;
bool isFiboDecreased;
bool isFiboSectionChanged;
//
// SC ...
//
bool isSCBullish;
bool isSCHHBullish;
bool isSCLLBullish;
bool isSCSwitchedToBullish;
bool isSCHHSwitchedToBullish;
bool isSCLLSwitchedToBullish;
//
bool isSCBearish;
bool isSCHHBearish;
bool isSCLLBearish;
bool isSCSwitchedToBearish;
bool isSCHHSwitchedToBearish;
bool isSCLLSwitchedToBeraish;
//
// MC ...
//
bool isMCBullish;
bool isMCHHBullish;
bool isMCLLBullish;
bool isMCSwitchedToBullish;
bool isMCHHSwitchedToBullish;
bool isMCLLSwitchedToBullish;
//
bool isMCBearish;
bool isMCHHBearish;
bool isMCLLBearish;
bool isMCSwitchedToBearish;
bool isMCHHSwitchedToBearish;
bool isMCLLSwitchedToBeraish;
//
// LC ...
//
bool isLCBullish;
bool isLCHHBullish;
bool isLCLLBullish;
bool isLCSwitchedToBullish;
bool isLCHHSwitchedToBullish;
bool isLCLLSwitchedToBullish;
//
bool isLCBearish;
bool isLCHHBearish;
bool isLCLLBearish;
bool isLCSwitchedToBearish;
bool isLCHHSwitchedToBearish;
bool isLCLLSwitchedToBeraish;
//
// HC ...
//
bool isHCBullish;
bool isHCHHBullish;
bool isHCLLBullish;
bool isHCSwitchedToBullish;
bool isHCHHSwitchedToBullish;
bool isHCLLSwitchedToBullish;
//
bool isHCBearish;
bool isHCHHBearish;
bool isHCLLBearish;
bool isHCSwitchedToBearish;
bool isHCHHSwitchedToBearish;
bool isHCLLSwitchedToBeraish;
//
// XHK ...
//
bool isHKBullish;
bool isHKBearish;
bool isClosedOverHK;
bool isClosedUnderHK;
bool isHKSwitchedToBullish;
bool isHKSwitchedToBearish;
//
bool isSMHKBullish;
bool isSMHKBearish;
bool isClosedOverSMHK;
bool isClosedUnderSMHK;
bool isSMHKSwitchedToBullish;
bool isSMHKSwitchedToBearish;
//
// XSTR ...
bool isTrendBullish;
bool isTrendBearish;
bool isTrendSwitchedToBullish;
bool isTrendSwitchedToBearish;
//
// XTD ...
bool isTDBullish;
bool isTDBearish;
bool isTDSwitchedToBullish;
bool isTDSwitchedToBearish;
//
// XCHE ...
bool isCHEBullish;
bool isCHEBearish;
bool isCHESwitchedToBullish;
bool isCHESwitchedToBearish;
//
// XMC ...
bool isMCFastOverSlow;
bool isMCFastUnderSlow;
bool isMCFastOverVerifier;
bool isMCFastUnderVerifier;
bool isMCSlowOverVerifier;
bool isMCSlowUnderVerifier;
bool isMCFastCrossedOverSlow;
bool isMCFastCrossedUnderSlow;
bool isMCFastCrossedOverVerifier;
bool isMCFastCrossedUnderVerifier;
bool isMCSlowCrossedOverVerifier;
bool isMCSlowCrossedUnderVerifier;
//
// XMRB ...
bool isMRBFastOverSlow;
bool isMRBFastUnderSlow;
bool isMRBFastCrossedOverSlow;
bool isMRBFastCrossedUnderSlow;
bool isMRBFastOverVerifier;
bool isMRBFastUnderVerifier;
bool isMRBFastCrossedtOverVerifier;
bool isMRBFastCrossedUnderVerifier;
bool isMRBSlowOverVerifier;
bool isMRBSlowUnderVerifier;
bool isMRBSlowCrossedtOverVerifier;
bool isMRBSlowCrossedUnderVerifier;
//
// XDON ...
//
bool isDONAttachedMaxLower;
bool isDONAttachedMinLower;
bool isDONCrossedOverMaxLower;
bool isDONCrossedUnderMaxLower;
bool isDONCrossedOverMinLower;
bool isDONCrossedUnderMinLower;
//
bool isDONAttachedMaxUpper;
bool isDONAttachedMinUpper;
bool isDONCrossedOverMaxUpper;
bool isDONCrossedUnderMaxUpper;
bool isDONCrossedOverMinUpper;
bool isDONCrossedUnderMinUpper;
//
// XICH ...
//
bool isClosedOverKijunSen;
bool isClosedUnderKijunSen;
bool isTenkanSenOverKijunSen;
bool isTenkanSenUnderKijunSen;
bool isTenkanSenCrossedOverKijunSen;
bool isTenkanSenCrossedUnderKijunSen;
//
bool isSenkouSpanAOverB;
bool isSenkouSpanAUnderB;
bool isSenkouSpanAOverLast;
bool isSenkouSpanAUnderLast;
bool isFutureSenkouSpanAOverB;
bool isFutureSenkouSpanAUnderB;
bool isFutureSenkouSpanAOverLast;
bool isFutureSenkouSpanAUnderLast;
//
bool isSenkouSpanACrossedOverB;
bool isSenkouSpanACrossedUnderB;
bool isSenkouSpanACrossedOverLast;
bool isSenkouSpanACrossedUnderLast;
bool isFutureSenkouSpanACrossedOverB;
bool isFutureSenkouSpanACrossedUnderB;
bool isFutureSenkouSpanACrossedOverLast;
bool isFutureSenkouSpanACrossedUnderLast;
//
// XOSC ...
//
// SAR ...
// ATR ...
// RVI ...
// RSI ...
// CCI ...
// MACD ...
// STOCH ...
// BULLP ...
// BEARP ...
// STDDEV ...
// VOLUME ...
// MOMENTUM ...
//
// Tools ...
//
void Clear()
{
//
// Commons ...
time = 0;
cycle = NULL;
prefix = NULL;
symbol = NULL;
period = NULL;
hostPeriod = NULL;
//
Clean(bars);
//
// Candlestic ...
isLastBullish = false;
isLastBearish = false;
isCurrentBullish = false;
isCurrentBearish = false;
isCurrentMidLineOverLastHigh = false;
isCurrentMidLineUnderLastLow = false;
isCurrentMidLineOverLastUp = false;
isCurrentMidLineUnderLastDown = false;
isCurrentMidLineOverLastMidLine = false;
isCurrentMidLineUnderLastMidLine = false;
//
// Buffers ...
Clean(bars);
Clean(asctLongs);
Clean(asctShorts);
Clean(hkBars);
Clean(smHKBars);
Clean(ichTenkanSens);
Clean(ichKijunSens);
Clean(ichChikouSpans);
Clean(ichSenkouSpanAs);
Clean(ichSenkouSpanBs);
Clean(ichFutureSenkouSpanAs);
Clean(ichFutureSenkouSpanBs);
Clean(mcFasts);
Clean(mcSlows);
Clean(mcVerifiers);
Clean(strTrends);
Clean(strStates);
Clean(cheLongExit1s);
Clean(cheLongExit2s);
Clean(cheShortExit1s);
Clean(cheShortExit2s);
Clean(oscAtrs);
Clean(oscRviMains);
Clean(oscRviSignals);
Clean(oscBullPs);
Clean(oscBearPs);
Clean(oscVolumes);
Clean(oscRsis);
Clean(oscCcis);
Clean(oscMomentums);
Clean(oscSars);
Clean(oscMacdMains);
Clean(oscMacdSignals);
Clean(oscStochMains);
Clean(oscStochSignals);
Clean(oscStddevs);
Clean(zigzags);
Clean(zigzagPVs);
Clean(mrbFasts);
Clean(mrb1Fasts);
Clean(mrb2Fasts);
Clean(mrb3Fasts);
Clean(mrb4Fasts);
Clean(mrb5Fasts);
Clean(mrb6Fasts);
Clean(mrbSlows);
Clean(mrb1Slows);
Clean(mrb2Slows);
Clean(mrb3Slows);
Clean(mrb4Slows);
Clean(mrb5Slows);
Clean(mrb6Slows);
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);
Clean(tdBullishs);
Clean(tdBearishs);
Clean(tdSignals);
Clean(hullUps);
Clean(hullDowns);
Clean(sslcUps);
Clean(sslcDowns);
//
// Buffers ...
ArraySetAsSeries(bars, true);
ArraySetAsSeries(hkBars, true);
ArraySetAsSeries(asctLongs, true);
ArraySetAsSeries(asctShorts, true);
ArraySetAsSeries(smHKBars, true);
ArraySetAsSeries(ichTenkanSens, true);
ArraySetAsSeries(ichKijunSens, true);
ArraySetAsSeries(ichChikouSpans, true);
ArraySetAsSeries(ichSenkouSpanAs, true);
ArraySetAsSeries(ichSenkouSpanBs, true);
ArraySetAsSeries(ichFutureSenkouSpanAs, true);
ArraySetAsSeries(ichFutureSenkouSpanBs, true);
ArraySetAsSeries(mcFasts, true);
ArraySetAsSeries(mcSlows, true);
ArraySetAsSeries(mcVerifiers, true);
ArraySetAsSeries(strTrends, true);
ArraySetAsSeries(strStates, true);
ArraySetAsSeries(cheLongExit1s, true);
ArraySetAsSeries(cheLongExit2s, true);
ArraySetAsSeries(cheShortExit1s, true);
ArraySetAsSeries(cheShortExit2s, true);
ArraySetAsSeries(oscAtrs, true);
ArraySetAsSeries(oscRviMains, true);
ArraySetAsSeries(oscRviSignals, true);
ArraySetAsSeries(oscBullPs, true);
ArraySetAsSeries(oscBearPs, true);
ArraySetAsSeries(oscVolumes, true);
ArraySetAsSeries(oscRsis, true);
ArraySetAsSeries(oscCcis, true);
ArraySetAsSeries(oscMomentums, true);
ArraySetAsSeries(oscSars, true);
ArraySetAsSeries(oscMacdMains, true);
ArraySetAsSeries(oscMacdSignals, true);
ArraySetAsSeries(oscStochMains, true);
ArraySetAsSeries(oscStochSignals, true);
ArraySetAsSeries(oscStddevs, true);
ArraySetAsSeries(zigzags, true);
ArraySetAsSeries(zigzagPVs, true);
ArraySetAsSeries(mrbFasts, true);
ArraySetAsSeries(mrb1Fasts, true);
ArraySetAsSeries(mrb2Fasts, true);
ArraySetAsSeries(mrb3Fasts, true);
ArraySetAsSeries(mrb4Fasts, true);
ArraySetAsSeries(mrb5Fasts, true);
ArraySetAsSeries(mrb6Fasts, true);
ArraySetAsSeries(mrbSlows, true);
ArraySetAsSeries(mrb1Slows, true);
ArraySetAsSeries(mrb2Slows, true);
ArraySetAsSeries(mrb3Slows, true);
ArraySetAsSeries(mrb4Slows, true);
ArraySetAsSeries(mrb5Slows, true);
ArraySetAsSeries(mrb6Slows, 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);
ArraySetAsSeries(tdBullishs, true);
ArraySetAsSeries(tdBearishs, true);
ArraySetAsSeries(tdSignals, true);
ArraySetAsSeries(hullUps, true);
ArraySetAsSeries(hullDowns, true);
ArraySetAsSeries(sslcUps, true);
ArraySetAsSeries(sslcDowns, true);
//
// XZG ...
isZigZagInPeak = false;
isZigZagInVale = false;
//
// XASCT ...
isASCTLong = false;
isASCTShort = false;
//
// XHULL ...
isHullBullish = false;
isHullBearish = false;
isHullUpBullish = false;
isHullUpBearish = false;
isHullDownBullish = false;
isHullDownBearish = false;
isHullSwitchedToBullish = false;
isHullSwitchedToBearish = false;
//
// XSSLC ...
isSSLCBullish = false;
isSSLCBearish = false;
isSSLCSwitchedToBullish = false;
isSSLCSwitchedToBearish = false;
//
// XPV ...
//
isNewPeak = false;
isNewPeakOverLast = false;
isNewPeakUnderLast = false;
//
isNewVale = false;
isNewValeOverLast = false;
isNewValeUnderLast = false;
//
isFiboIncreased = false;
isFiboDecreased = false;
isFiboSectionChanged = false;
//
// SC ...
//
isSCBullish = false;
isSCHHBullish = false;
isSCLLBullish = false;
isSCSwitchedToBullish = false;
isSCHHSwitchedToBullish = false;
isSCLLSwitchedToBullish = false;
//
isSCBearish = false;
isSCHHBearish = false;
isSCLLBearish = false;
isSCSwitchedToBearish = false;
isSCHHSwitchedToBearish = false;
isSCLLSwitchedToBeraish = false;
//
// MC ...
//
isMCBullish = false;
isMCHHBullish = false;
isMCLLBullish = false;
isMCSwitchedToBullish = false;
isMCHHSwitchedToBullish = false;
isMCLLSwitchedToBullish = false;
//
isMCBearish = false;
isMCHHBearish = false;
isMCLLBearish = false;
isMCSwitchedToBearish = false;
isMCHHSwitchedToBearish = false;
isMCLLSwitchedToBeraish = false;
//
// LC ...
//
isLCBullish = false;
isLCHHBullish = false;
isLCLLBullish = false;
isLCSwitchedToBullish = false;
isLCHHSwitchedToBullish = false;
isLCLLSwitchedToBullish = false;
//
isLCBearish = false;
isLCHHBearish = false;
isLCLLBearish = false;
isLCSwitchedToBearish = false;
isLCHHSwitchedToBearish = false;
isLCLLSwitchedToBeraish = false;
//
// HC ...
//
isHCBullish = false;
isHCHHBullish = false;
isHCLLBullish = false;
isHCSwitchedToBullish = false;
isHCHHSwitchedToBullish = false;
isHCLLSwitchedToBullish = false;
//
isHCBearish = false;
isHCHHBearish = false;
isHCLLBearish = false;
isHCSwitchedToBearish = false;
isHCHHSwitchedToBearish = false;
isHCLLSwitchedToBeraish = false;
//
// XHK ...
isHKBullish = false;
isHKBearish = false;
isClosedOverHK = false;
isClosedUnderHK = false;
isHKSwitchedToBullish = false;
isHKSwitchedToBearish = false;
//
isSMHKBullish = false;
isSMHKBearish = false;
isClosedOverSMHK = false;
isClosedUnderSMHK = false;
isSMHKSwitchedToBullish = false;
isSMHKSwitchedToBearish = false;
//
// XSTR ...
isTrendBullish = false;
isTrendBearish = false;
isTrendSwitchedToBullish = false;
isTrendSwitchedToBearish = false;
//
// XTD ...
isTDBullish = false;
isTDBearish = false;
isTDSwitchedToBullish = false;
isTDSwitchedToBearish = false;
//
// XCHE ...
isCHEBullish = false;
isCHEBearish = false;
isCHESwitchedToBullish = false;
isCHESwitchedToBearish = false;
//
// XMC ...
isMCFastOverSlow = false;
isMCFastUnderSlow = false;
isMCFastOverVerifier = false;
isMCFastUnderVerifier = false;
isMCSlowOverVerifier = false;
isMCSlowUnderVerifier = false;
isMCFastCrossedOverSlow = false;
isMCFastCrossedUnderSlow = false;
isMCFastCrossedOverVerifier = false;
isMCFastCrossedUnderVerifier = false;
isMCSlowCrossedOverVerifier = false;
isMCSlowCrossedUnderVerifier = false;
//
// XMRB ...
isMRBFastOverSlow = false;
isMRBFastUnderSlow = false;
isMRBFastCrossedOverSlow = false;
isMRBFastCrossedUnderSlow = false;
isMRBFastOverVerifier = false;
isMRBFastUnderVerifier = false;
isMRBFastCrossedtOverVerifier = false;
isMRBFastCrossedUnderVerifier = false;
isMRBSlowOverVerifier = false;
isMRBSlowUnderVerifier = false;
isMRBSlowCrossedtOverVerifier = false;
isMRBSlowCrossedUnderVerifier = false;
//
// XDON ...
//
isDONAttachedMaxLower = false;
isDONAttachedMinLower = false;
isDONCrossedOverMaxLower = false;
isDONCrossedUnderMaxLower = false;
isDONCrossedOverMinLower = false;
isDONCrossedUnderMinLower = false;
//
isDONAttachedMaxUpper = false;
isDONAttachedMinUpper = false;
isDONCrossedOverMaxUpper = false;
isDONCrossedUnderMaxUpper = false;
isDONCrossedOverMinUpper = false;
isDONCrossedUnderMinUpper = false;
//
// XICH ...
//
isClosedOverKijunSen = false;
isClosedUnderKijunSen = false;
isTenkanSenOverKijunSen = false;
isTenkanSenUnderKijunSen = false;
isTenkanSenCrossedOverKijunSen = false;
isTenkanSenCrossedUnderKijunSen = false;
//
isSenkouSpanAOverB = false;
isSenkouSpanAUnderB = false;
isSenkouSpanAOverLast = false;
isSenkouSpanAUnderLast = false;
isFutureSenkouSpanAOverB = false;
isFutureSenkouSpanAUnderB = false;
isFutureSenkouSpanAOverLast = false;
isFutureSenkouSpanAUnderLast = false;
//
isSenkouSpanACrossedOverB = false;
isSenkouSpanACrossedUnderB = false;
isSenkouSpanACrossedOverLast = false;
isSenkouSpanACrossedUnderLast = false;
isFutureSenkouSpanACrossedOverB = false;
isFutureSenkouSpanACrossedUnderB = false;
isFutureSenkouSpanACrossedOverLast = false;
isFutureSenkouSpanACrossedUnderLast = false;
}
//
// Generate Score ...
void GenerateScore(
double &bullishScore, // Holds Bullish Score ...
double &bearishScore, // Holds Bearish Score ...
double multiplier = 1 // Score Multiplier ...
)
{
//
double bullScore = 0;
double bearScore = 0;
//
if (multiplier <= 0)
{
multiplier = 1;
}
//
// XASCT ...
if (isASCTLong)
{
//
bullScore++;
bullScore++;
bearScore--;
}
if (isASCTShort)
{
//
bullScore--;
bearScore++;
bearScore++;
}
//
// Candlestic ...
if (isLastBullish)
{
bullScore++;
}
if (isLastBearish)
{
bearScore++;
}
if (isCurrentBullish)
{
bullScore++;
}
if (isCurrentBearish)
{
bearScore++;
}
if (isCurrentMidLineOverLastHigh)
{
bullScore++;
}
if (isCurrentMidLineUnderLastLow)
{
bearScore++;
}
if (isCurrentMidLineOverLastUp)
{
bullScore++;
}
if (isCurrentMidLineUnderLastDown)
{
bearScore++;
}
if (isCurrentMidLineOverLastMidLine)
{
bullScore++;
}
if (isCurrentMidLineUnderLastMidLine)
{
bearScore++;
}
//
// XZG ...
if (isZigZagInPeak)
{
bullScore++;
}
if (isZigZagInVale)
{
bearScore++;
}
//
// XHULL ...
if (isHullBullish)
{
bullScore++;
}
if (isHullBearish)
{
bearScore++;
}
if (isHullUpBullish)
{
bullScore++;
}
if (isHullUpBearish)
{
bearScore++;
}
if (isHullDownBullish)
{
bullScore++;
}
if (isHullDownBearish)
{
bearScore++;
}
if (isHullSwitchedToBullish)
{
bullScore++;
}
if (isHullSwitchedToBearish)
{
bearScore++;
}
//
// XSSLC ...
if (isSSLCBullish)
{
bullScore++;
}
if (isSSLCBearish)
{
bearScore++;
}
if (isSSLCSwitchedToBullish)
{
bullScore++;
}
if (isSSLCSwitchedToBearish)
{
bearScore++;
}
//
// XPV ...
//
if (isNewPeak)
{
bearScore++;
}
if (isNewPeakOverLast)
{
}
if (isNewPeakUnderLast)
{
}
//
if (isNewVale)
{
bullScore++;
}
if (isNewValeOverLast)
{
}
if (isNewValeUnderLast)
{
}
//
if (isFiboIncreased)
{
bullScore++;
}
if (isFiboDecreased)
{
bearScore++;
}
if (isFiboSectionChanged)
{
}
//
// SC ...
//
if (isSCBullish)
{
bullScore++;
}
if (isSCHHBullish)
{
bullScore++;
}
if (isSCLLBullish)
{
bullScore++;
}
if (isSCSwitchedToBullish)
{
bullScore++;
}
if (isSCHHSwitchedToBullish)
{
bullScore++;
}
if (isSCLLSwitchedToBullish)
{
bullScore++;
}
//
if (isSCBearish)
{
bearScore++;
}
if (isSCHHBearish)
{
bearScore++;
}
if (isSCLLBearish)
{
bearScore++;
}
if (isSCSwitchedToBearish)
{
bearScore++;
}
if (isSCHHSwitchedToBearish)
{
bearScore++;
}
if (isSCLLSwitchedToBeraish)
{
bearScore++;
}
//
// MC ...
//
if (isMCBullish)
{
bullScore++;
}
if (isMCHHBullish)
{
bullScore++;
}
if (isMCLLBullish)
{
bullScore++;
}
if (isMCSwitchedToBullish)
{
bullScore++;
}
if (isMCHHSwitchedToBullish)
{
bullScore++;
}
if (isMCLLSwitchedToBullish)
{
bullScore++;
}
//
if (isMCBearish)
{
bearScore++;
}
if (isMCHHBearish)
{
bearScore++;
}
if (isMCLLBearish)
{
bearScore++;
}
if (isMCSwitchedToBearish)
{
bearScore++;
}
if (isMCHHSwitchedToBearish)
{
bearScore++;
}
if (isMCLLSwitchedToBeraish)
{
bearScore++;
}
//
// LC ...
//
if (isLCBullish)
{
bullScore++;
}
if (isLCHHBullish)
{
bullScore++;
}
if (isLCLLBullish)
{
bullScore++;
}
if (isLCSwitchedToBullish)
{
bullScore++;
}
if (isLCHHSwitchedToBullish)
{
bullScore++;
}
if (isLCLLSwitchedToBullish)
{
bullScore++;
}
//
if (isLCBearish)
{
bearScore++;
}
if (isLCHHBearish)
{
bearScore++;
}
if (isLCLLBearish)
{
bearScore++;
}
if (isLCSwitchedToBearish)
{
bearScore++;
}
if (isLCHHSwitchedToBearish)
{
bearScore++;
}
if (isLCLLSwitchedToBeraish)
{
bearScore++;
}
//
// HC ...
//
if (isHCBullish)
{
bullScore++;
}
if (isHCHHBullish)
{
bullScore++;
}
if (isHCLLBullish)
{
bullScore++;
}
if (isHCSwitchedToBullish)
{
bullScore++;
}
if (isHCHHSwitchedToBullish)
{
bullScore++;
}
if (isHCLLSwitchedToBullish)
{
bullScore++;
}
//
if (isHCBearish)
{
bearScore++;
}
if (isHCHHBearish)
{
bearScore++;
}
if (isHCLLBearish)
{
bearScore++;
}
if (isHCSwitchedToBearish)
{
bearScore++;
}
if (isHCHHSwitchedToBearish)
{
bearScore++;
}
if (isHCLLSwitchedToBeraish)
{
bearScore++;
}
//
// XHK ...
//
if (isHKBullish)
{
bullScore++;
}
if (isHKBearish)
{
bearScore++;
}
if (isClosedOverHK)
{
bullScore++;
}
if (isClosedUnderHK)
{
bearScore++;
}
if (isHKSwitchedToBullish)
{
bullScore++;
}
if (isHKSwitchedToBearish)
{
bearScore++;
}
//
if (isSMHKBullish)
{
bullScore++;
}
if (isSMHKBearish)
{
bearScore++;
}
if (isClosedOverSMHK)
{
bullScore++;
}
if (isClosedUnderSMHK)
{
bearScore++;
}
if (isSMHKSwitchedToBullish)
{
bullScore++;
}
if (isSMHKSwitchedToBearish)
{
bearScore++;
}
//
// XSTR ...
if (isTrendBullish)
{
bullScore++;
}
if (isTrendBearish)
{
bearScore++;
}
if (isTrendSwitchedToBullish)
{
bullScore++;
}
if (isTrendSwitchedToBearish)
{
bearScore++;
}
//
// XTD ...
if (isTDBullish)
{
bullScore++;
}
if (isTDBearish)
{
bearScore++;
}
if (isTDSwitchedToBullish)
{
bullScore++;
}
if (isTDSwitchedToBearish)
{
bearScore++;
}
//
// XCHE ...
if (isCHEBullish)
{
bullScore++;
}
if (isCHEBearish)
{
bearScore++;
}
if (isCHESwitchedToBullish)
{
bullScore++;
}
if (isCHESwitchedToBearish)
{
bearScore++;
}
//
// XMC ...
if (isMCFastOverSlow)
{
bullScore++;
}
if (isMCFastUnderSlow)
{
bearScore++;
}
if (isMCFastOverVerifier)
{
bullScore++;
}
if (isMCFastUnderVerifier)
{
bearScore++;
}
if (isMCSlowOverVerifier)
{
bullScore++;
}
if (isMCSlowUnderVerifier)
{
bearScore++;
}
if (isMCFastCrossedOverSlow)
{
bullScore++;
}
if (isMCFastCrossedUnderSlow)
{
bearScore++;
}
if (isMCFastCrossedOverVerifier)
{
bullScore++;
}
if (isMCFastCrossedUnderVerifier)
{
bearScore++;
}
if (isMCSlowCrossedOverVerifier)
{
bullScore++;
}
if (isMCSlowCrossedUnderVerifier)
{
bearScore++;
}
//
// XMRB ...
if (isMRBFastOverSlow)
{
bullScore++;
}
if (isMRBFastUnderSlow)
{
bearScore++;
}
if (isMRBFastCrossedOverSlow)
{
bullScore++;
}
if (isMRBFastCrossedUnderSlow)
{
bearScore++;
}
if (isMRBFastOverVerifier)
{
bullScore++;
}
if (isMRBFastUnderVerifier)
{
bearScore++;
}
if (isMRBFastCrossedtOverVerifier)
{
bullScore++;
}
if (isMRBFastCrossedUnderVerifier)
{
bearScore++;
}
if (isMRBSlowOverVerifier)
{
bullScore++;
}
if (isMRBSlowUnderVerifier)
{
bearScore++;
}
if (isMRBSlowCrossedtOverVerifier)
{
bullScore++;
}
if (isMRBSlowCrossedUnderVerifier)
{
bearScore++;
}
//
// XDON ...
//
if (isDONAttachedMaxLower)
{
bullScore++;
}
if (isDONAttachedMinLower)
{
bullScore++;
}
if (isDONCrossedOverMaxLower)
{
bullScore++;
}
if (isDONCrossedUnderMaxLower)
{
bullScore++;
}
if (isDONCrossedOverMinLower)
{
bullScore++;
}
if (isDONCrossedUnderMinLower)
{
bullScore++;
}
//
if (isDONAttachedMaxUpper)
{
bearScore++;
}
if (isDONAttachedMinUpper)
{
bearScore++;
}
if (isDONCrossedOverMaxUpper)
{
bearScore++;
}
if (isDONCrossedUnderMaxUpper)
{
bearScore++;
}
if (isDONCrossedOverMinUpper)
{
bearScore++;
}
if (isDONCrossedUnderMinUpper)
{
bearScore++;
}
//
// XICH ...
//
if (isClosedOverKijunSen)
{
bullScore++;
}
if (isClosedUnderKijunSen)
{
bearScore++;
}
if (isTenkanSenOverKijunSen)
{
bullScore++;
}
if (isTenkanSenUnderKijunSen)
{
bearScore++;
}
if (isTenkanSenCrossedOverKijunSen)
{
bullScore++;
}
if (isTenkanSenCrossedUnderKijunSen)
{
bearScore++;
}
//
if (isSenkouSpanAOverB)
{
bullScore++;
}
if (isSenkouSpanAUnderB)
{
bearScore++;
}
if (isSenkouSpanAOverLast)
{
bullScore++;
}
if (isSenkouSpanAUnderLast)
{
bearScore++;
}
if (isFutureSenkouSpanAOverB)
{
bullScore++;
}
if (isFutureSenkouSpanAUnderB)
{
bearScore++;
}
if (isFutureSenkouSpanAOverLast)
{
bullScore++;
}
if (isFutureSenkouSpanAUnderLast)
{
bearScore++;
}
//
if (isSenkouSpanACrossedOverB)
{
bullScore++;
}
if (isSenkouSpanACrossedUnderB)
{
bearScore++;
}
if (isSenkouSpanACrossedOverLast)
{
bullScore++;
}
if (isSenkouSpanACrossedUnderLast)
{
bearScore++;
}
if (isFutureSenkouSpanACrossedOverB)
{
bullScore++;
}
if (isFutureSenkouSpanACrossedUnderB)
{
bearScore++;
}
if (isFutureSenkouSpanACrossedOverLast)
{
bullScore++;
}
if (isFutureSenkouSpanACrossedUnderLast)
{
bearScore++;
}
//
bullishScore = bullScore * multiplier;
bearishScore = bearScore * multiplier;
}
//
// Generate Summary ...
string GenerateSummary(
const bool onlySummary = false, // Only Generate Conditions Summary
double multiplier = 1, // Score Multiplier
const string separator = "\n", // Separator
const bool ignoreFalseConditions = true // Ignore False Conditions
)
{
//
string result = NULL;
//
result = GenerateSummaryBody(
onlySummary,
multiplier,
separator,
ignoreFalseConditions
//
);
//
// Generating Full Result by Combining parts ...
result =
//
GetTitle() + separator +
"-----------------------------" + separator +
result +
""
//
;
//
return result;
}
//
string GenerateSummaryBody(
const bool onlySummary = false, // Only Generate Conditions Summary
double multiplier = 1, // Score Multiplier
const string separator = "\n", // Separator
const bool ignoreFalseConditions = true // Ignore False Conditions
)
{
//
string result = NULL;
//
double bullScore = 0;
double bearScore = 0;
GenerateScore(
bullScore,
bearScore,
multiplier //
);
//
// Common ...
string commonStr =
//
(onlySummary ? "" : "Commons: " + separator) +
(onlySummary ? "" : "-----------------------------" + separator) +
"Time: " + ToString(TimeCurrent()) + separator +
"-----------" + separator +
"Scores: " + separator +
"-----------" + separator +
"Bullish: " + ToString(bullScore) + separator +
"Bearish: " + ToString(bearScore) + separator +
"-----------------------------" + separator +
//
// TODO: Add Scores Later ...
separator +
""
//
;
//
// Candlestick ...
string candlestickStr =
//
ToString("isLastBullish", isLastBullish, ignoreFalseConditions, separator) +
ToString("isLastBearish", isLastBearish, ignoreFalseConditions, separator) +
ToString("isCurrentBullish", isCurrentBullish, ignoreFalseConditions, separator) +
ToString("isCurrentBearish", isCurrentBearish, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineOverLastHigh", isCurrentMidLineOverLastHigh, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineUnderLastLow", isCurrentMidLineUnderLastLow, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineOverLastUp", isCurrentMidLineOverLastUp, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineUnderLastDown", isCurrentMidLineUnderLastDown, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineOverLastMidLine", isCurrentMidLineOverLastMidLine, ignoreFalseConditions, separator) +
ToString("isCurrentMidLineUnderLastMidLine", isCurrentMidLineUnderLastMidLine, ignoreFalseConditions, separator) +
""
//
;
candlestickStr = SetLabel("XOHCL: ", candlestickStr, separator);
//
// XASCT ...
string asctStr =
//
ToString("isASCTLong", isASCTLong, ignoreFalseConditions, separator) +
ToString("isASCTShort", isASCTShort, ignoreFalseConditions, separator) +
""
//
;
asctStr = SetLabel("XASCT: ", asctStr, separator);
//
// XZG ...
string zgStr =
//
ToString("isZigZagInPeak", isZigZagInPeak, ignoreFalseConditions, separator) +
ToString("isZigZagInVale", isZigZagInVale, ignoreFalseConditions, separator) +
""
//
;
zgStr = SetLabel("XZG: ", zgStr, separator);
//
// XSTR ...
string strStr =
//
ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) +
ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) +
ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
strStr = SetLabel("XSTR: ", strStr, separator);
//
// XCHE ...
string cheStr =
//
ToString("isCHEBullish", isCHEBullish, ignoreFalseConditions, separator) +
ToString("isCHEBearish", isCHEBearish, ignoreFalseConditions, separator) +
ToString("isCHESwitchedToBullish", isCHESwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isCHESwitchedToBearish", isCHESwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
cheStr = SetLabel("XCHE: ", cheStr, separator);
//
// XTD ...
string tdStr =
//
ToString("isTDBullish", isTDBullish, ignoreFalseConditions, separator) +
ToString("isTDBearish", isTDBearish, ignoreFalseConditions, separator) +
ToString("isTDSwitchedToBullish", isTDSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isTDSwitchedToBearish", isTDSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
tdStr = SetLabel("XTD: ", tdStr, separator);
//
// XSSLC ...
string sslcStr =
//
ToString("isSSLCBullish", isSSLCBullish, ignoreFalseConditions, separator) +
ToString("isSSLCBearish", isSSLCBearish, ignoreFalseConditions, separator) +
ToString("isSSLCSwitchedToBullish", isSSLCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSSLCSwitchedToBearish", isSSLCSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
sslcStr = SetLabel("XSSLC: ", sslcStr, separator);
//
// XHULL ...
string hullStr =
//
ToString("isHullBullish", isHullBullish, ignoreFalseConditions, separator) +
ToString("isHullBearish", isHullBearish, ignoreFalseConditions, separator) +
ToString("isHullUpBullish", isHullUpBullish, ignoreFalseConditions, separator) +
ToString("isHullUpBearish", isHullUpBearish, ignoreFalseConditions, separator) +
ToString("isHullDownBullish", isHullDownBullish, ignoreFalseConditions, separator) +
ToString("isHullDownBearish", isHullDownBearish, ignoreFalseConditions, separator) +
ToString("isHullSwitchedToBullish", isHullSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHullSwitchedToBearish", isHullSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
hullStr = SetLabel("XHULL: ", hullStr, separator);
//
// XHK ...
string hkStr =
//
ToString("isHKBullish", isHKBullish, ignoreFalseConditions, separator) +
ToString("isHKBearish", isHKBearish, ignoreFalseConditions, separator) +
ToString("isClosedOverHK", isClosedOverHK, ignoreFalseConditions, separator) +
ToString("isClosedUnderHK", isClosedUnderHK, ignoreFalseConditions, separator) +
ToString("isHKSwitchedToBullish", isHKSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHKSwitchedToBearish", isHKSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isSMHKBullish", isSMHKBullish, ignoreFalseConditions, separator) +
ToString("isSMHKBearish", isSMHKBearish, ignoreFalseConditions, separator) +
ToString("isClosedOverSMHK", isClosedOverSMHK, ignoreFalseConditions, separator) +
ToString("isClosedUnderSMHK", isClosedUnderSMHK, ignoreFalseConditions, separator) +
ToString("isSMHKSwitchedToBullish", isSMHKSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSMHKSwitchedToBearish", isSMHKSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
hkStr = SetLabel("XHK: ", hkStr, separator);
//
// XDON ...
string donStr =
//
ToString("isDONAttachedMaxLower", isDONAttachedMaxLower, ignoreFalseConditions, separator) +
ToString("isDONAttachedMinLower", isDONAttachedMinLower, ignoreFalseConditions, separator) +
ToString("isDONCrossedOverMaxLower", isDONCrossedOverMaxLower, ignoreFalseConditions, separator) +
ToString("isDONCrossedUnderMaxLower", isDONCrossedUnderMaxLower, ignoreFalseConditions, separator) +
ToString("isDONCrossedOverMinLower", isDONCrossedOverMinLower, ignoreFalseConditions, separator) +
ToString("isDONCrossedUnderMinLower", isDONCrossedUnderMinLower, ignoreFalseConditions, separator) +
ToString("isDONAttachedMaxUpper", isDONAttachedMaxUpper, ignoreFalseConditions, separator) +
ToString("isDONAttachedMinUpper", isDONAttachedMinUpper, ignoreFalseConditions, separator) +
ToString("isDONCrossedOverMaxUpper", isDONCrossedOverMaxUpper, ignoreFalseConditions, separator) +
ToString("isDONCrossedUnderMaxUpper", isDONCrossedUnderMaxUpper, ignoreFalseConditions, separator) +
ToString("isDONCrossedOverMinUpper", isDONCrossedOverMinUpper, ignoreFalseConditions, separator) +
ToString("isDONCrossedUnderMinUpper", isDONCrossedUnderMinUpper, ignoreFalseConditions, separator) +
""
//
;
donStr = SetLabel("XDON: ", donStr, separator);
//
// XMC ...
string mcStr =
//
ToString("isMCFastOverSlow", isMCFastOverSlow, ignoreFalseConditions, separator) +
ToString("isMCFastUnderSlow", isMCFastUnderSlow, ignoreFalseConditions, separator) +
ToString("isMCFastOverVerifier", isMCFastOverVerifier, ignoreFalseConditions, separator) +
ToString("isMCFastUnderVerifier", isMCFastUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMCSlowOverVerifier", isMCSlowOverVerifier, ignoreFalseConditions, separator) +
ToString("isMCSlowUnderVerifier", isMCSlowUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMCFastCrossedOverSlow", isMCFastCrossedOverSlow, ignoreFalseConditions, separator) +
ToString("isMCFastCrossedUnderSlow", isMCFastCrossedUnderSlow, ignoreFalseConditions, separator) +
ToString("isMCFastCrossedOverVerifier", isMCFastCrossedOverVerifier, ignoreFalseConditions, separator) +
ToString("isMCFastCrossedUnderVerifier", isMCFastCrossedUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMCSlowCrossedOverVerifier", isMCSlowCrossedOverVerifier, ignoreFalseConditions, separator) +
ToString("isMCSlowCrossedUnderVerifier", isMCSlowCrossedUnderVerifier, ignoreFalseConditions, separator) +
""
//
;
mcStr = SetLabel("XMC: ", mcStr, separator);
//
// XMRB ...
string mrbStr =
//
ToString("isMRBFastOverSlow", isMRBFastOverSlow, ignoreFalseConditions, separator) +
ToString("isMRBFastUnderSlow", isMRBFastUnderSlow, ignoreFalseConditions, separator) +
ToString("isMRBFastCrossedOverSlow", isMRBFastCrossedOverSlow, ignoreFalseConditions, separator) +
ToString("isMRBFastCrossedUnderSlow", isMRBFastCrossedUnderSlow, ignoreFalseConditions, separator) +
ToString("isMRBFastOverVerifier", isMRBFastOverVerifier, ignoreFalseConditions, separator) +
ToString("isMRBFastUnderVerifier", isMRBFastUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMRBFastCrossedtOverVerifier", isMRBFastCrossedtOverVerifier, ignoreFalseConditions, separator) +
ToString("isMRBFastCrossedUnderVerifier", isMRBFastCrossedUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMRBSlowOverVerifier", isMRBSlowOverVerifier, ignoreFalseConditions, separator) +
ToString("isMRBSlowUnderVerifier", isMRBSlowUnderVerifier, ignoreFalseConditions, separator) +
ToString("isMRBSlowCrossedtOverVerifier", isMRBSlowCrossedtOverVerifier, ignoreFalseConditions, separator) +
ToString("isMRBSlowCrossedUnderVerifier", isMRBSlowCrossedUnderVerifier, ignoreFalseConditions, separator) +
""
//
;
mrbStr = SetLabel("XMRB: ", mrbStr, separator);
//
// XICH ...
string ichStr =
//
ToString("isClosedOverKijunSen", isClosedOverKijunSen, ignoreFalseConditions, separator) +
ToString("isClosedUnderKijunSen", isClosedUnderKijunSen, ignoreFalseConditions, separator) +
ToString("isTenkanSenOverKijunSen", isTenkanSenOverKijunSen, ignoreFalseConditions, separator) +
ToString("isTenkanSenUnderKijunSen", isTenkanSenUnderKijunSen, ignoreFalseConditions, separator) +
ToString("isTenkanSenCrossedOverKijunSen", isTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) +
ToString("isTenkanSenCrossedUnderKijunSen", isTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) +
ToString("isSenkouSpanAOverB", isSenkouSpanAOverB, ignoreFalseConditions, separator) +
ToString("isSenkouSpanAUnderB", isSenkouSpanAUnderB, ignoreFalseConditions, separator) +
ToString("isSenkouSpanAOverLast", isSenkouSpanAOverLast, ignoreFalseConditions, separator) +
ToString("isSenkouSpanAUnderLast", isSenkouSpanAUnderLast, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanAOverB", isFutureSenkouSpanAOverB, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanAUnderB", isFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanAOverLast", isFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanAUnderLast", isFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) +
ToString("isSenkouSpanACrossedOverB", isSenkouSpanACrossedOverB, ignoreFalseConditions, separator) +
ToString("isSenkouSpanACrossedUnderB", isSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) +
ToString("isSenkouSpanACrossedOverLast", isSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) +
ToString("isSenkouSpanACrossedUnderLast", isSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanACrossedOverB", isFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanACrossedUnderB", isFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanACrossedOverLast", isFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) +
ToString("isFutureSenkouSpanACrossedUnderLast", isFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) +
""
//
;
ichStr = SetLabel("XICH: ", ichStr, separator);
//
// XPV ...
string pvStr =
//
ToString("isNewPeak", isNewPeak, ignoreFalseConditions, separator) +
ToString("isNewPeakOverLast", isNewPeakOverLast, ignoreFalseConditions, separator) +
ToString("isNewPeakUnderLast", isNewPeakUnderLast, ignoreFalseConditions, separator) +
ToString("isNewVale", isNewVale, ignoreFalseConditions, separator) +
ToString("isNewValeOverLast", isNewValeOverLast, ignoreFalseConditions, separator) +
ToString("isNewValeUnderLast", isNewValeUnderLast, ignoreFalseConditions, separator) +
ToString("isFiboIncreased", isFiboIncreased, ignoreFalseConditions, separator) +
ToString("isFiboDecreased", isFiboDecreased, ignoreFalseConditions, separator) +
ToString("isFiboSectionChanged", isFiboSectionChanged, ignoreFalseConditions, separator) +
ToString("isSCBullish", isSCBullish, ignoreFalseConditions, separator) +
ToString("isSCHHBullish", isSCHHBullish, ignoreFalseConditions, separator) +
ToString("isSCLLBullish", isSCLLBullish, ignoreFalseConditions, separator) +
ToString("isSCSwitchedToBullish", isSCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSCHHSwitchedToBullish", isSCHHSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSCLLSwitchedToBullish", isSCLLSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSCBearish", isSCBearish, ignoreFalseConditions, separator) +
ToString("isSCHHBearish", isSCHHBearish, ignoreFalseConditions, separator) +
ToString("isSCLLBearish", isSCLLBearish, ignoreFalseConditions, separator) +
ToString("isSCSwitchedToBearish", isSCSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isSCHHSwitchedToBearish", isSCHHSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isSCLLSwitchedToBeraish", isSCLLSwitchedToBeraish, ignoreFalseConditions, separator) +
ToString("isMCBullish", isMCBullish, ignoreFalseConditions, separator) +
ToString("isMCHHBullish", isMCHHBullish, ignoreFalseConditions, separator) +
ToString("isMCLLBullish", isMCLLBullish, ignoreFalseConditions, separator) +
ToString("isMCSwitchedToBullish", isMCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMCHHSwitchedToBullish", isMCHHSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMCLLSwitchedToBullish", isMCLLSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMCBearish", isMCBearish, ignoreFalseConditions, separator) +
ToString("isMCHHBearish", isMCHHBearish, ignoreFalseConditions, separator) +
ToString("isMCLLBearish", isMCLLBearish, ignoreFalseConditions, separator) +
ToString("isMCSwitchedToBearish", isMCSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isMCHHSwitchedToBearish", isMCHHSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isMCLLSwitchedToBeraish", isMCLLSwitchedToBeraish, ignoreFalseConditions, separator) +
ToString("isLCBullish", isLCBullish, ignoreFalseConditions, separator) +
ToString("isLCHHBullish", isLCHHBullish, ignoreFalseConditions, separator) +
ToString("isLCLLBullish", isLCLLBullish, ignoreFalseConditions, separator) +
ToString("isLCSwitchedToBullish", isLCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isLCHHSwitchedToBullish", isLCHHSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isLCLLSwitchedToBullish", isLCLLSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isLCBearish", isLCBearish, ignoreFalseConditions, separator) +
ToString("isLCHHBearish", isLCHHBearish, ignoreFalseConditions, separator) +
ToString("isLCLLBearish", isLCLLBearish, ignoreFalseConditions, separator) +
ToString("isLCSwitchedToBearish", isLCSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isLCHHSwitchedToBearish", isLCHHSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isLCLLSwitchedToBeraish", isLCLLSwitchedToBeraish, ignoreFalseConditions, separator) +
ToString("isHCBullish", isHCBullish, ignoreFalseConditions, separator) +
ToString("isHCHHBullish", isHCHHBullish, ignoreFalseConditions, separator) +
ToString("isHCLLBullish", isHCLLBullish, ignoreFalseConditions, separator) +
ToString("isHCSwitchedToBullish", isHCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHCHHSwitchedToBullish", isHCHHSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHCLLSwitchedToBullish", isHCLLSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHCBearish", isHCBearish, ignoreFalseConditions, separator) +
ToString("isHCHHBearish", isHCHHBearish, ignoreFalseConditions, separator) +
ToString("isHCLLBearish", isHCLLBearish, ignoreFalseConditions, separator) +
ToString("isHCSwitchedToBearish", isHCSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isHCHHSwitchedToBearish", isHCHHSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isHCLLSwitchedToBeraish", isHCLLSwitchedToBeraish, ignoreFalseConditions, separator) +
""
//
;
pvStr = SetLabel("XPV: ", pvStr, separator);
//
result =
onlySummary
? commonStr
: (commonStr +
candlestickStr +
asctStr +
zgStr +
strStr +
cheStr +
tdStr +
sslcStr +
hullStr +
hkStr +
donStr +
mcStr +
mrbStr +
ichStr +
pvStr +
"" //
);
//
return result;
}
//
string GetTitle()
{
//
string result = NULL;
//
result =
//
"[" + ToString(cycle) + "]: " + ToString(period)
//
;
//
return result;
}
};
//
// Signaller Class Base Implementation ...
class XSignallerDescriptor : public XSCBase
{
//
// Public ...
public:
//
// Props ...
//
ENUM_XSIGNAL_PROVIDERS name; // Signaller Name
//
bool allowLong; // Allow Long Positions
bool allowShort; // Allow Short Positions
//
double r2r; // Risk To Reward Ratio
//
double staticVolumeLong; // Static Volume for Long
double staticVolumeShort; // Static Volume For Short
//
int maxAllowedLong; // Max Allowed Same Time Long Open Positions
int maxAllowedShort; // Max Allowed Same Time Short Open Positions
//
int delayBetweenTwoSameTypeSignals; // Delay between Two Same Type Signals
int maxAllowedOpenPositionAge; // Close Position if Still Alive bigger than this value
//
double minRequiredProfitPerTrade; // Minimum Required Profit Per Trade for Hedging
double minRequiredProfitPerTradeVolumeFactor; // Calculate Required Profit Based on Volume Factor for Hedging
//
bool openNextPositionOnProfit; // Open Next Signaller Position only When Previous Signals in Profit
bool ignoreProfitForOppositeSignals; // Ignore In Profit Policy when Opposite Signal Comming
//
//
// Constructor ...
void XSignallerDescriptor()
{
}
//
// Tools ...
//
// Cleanup ...
void Clean()
{
//
name = PROVIDER_NONE;
//
allowLong = false;
allowShort = false;
//
r2r = 0;
//
staticVolumeLong = 0;
staticVolumeShort = 0;
//
maxAllowedLong = 0;
maxAllowedShort = 0;
maxAllowedOpenPositionAge = 0;
delayBetweenTwoSameTypeSignals = 0;
//
minRequiredProfitPerTrade = 0;
minRequiredProfitPerTradeVolumeFactor = 0;
//
openNextPositionOnProfit = false;
ignoreProfitForOppositeSignals = false;
}
//
// Enable Default Configurations ...
virtual void Default()
{
//
allowLong = true;
allowShort = true;
//
r2r = 1;
//
maxAllowedLong = 3;
maxAllowedShort = 3;
//
staticVolumeLong = 0.01;
staticVolumeShort = 0.01;
//
maxAllowedOpenPositionAge = 576; // Two Days on 5 Min
delayBetweenTwoSameTypeSignals = 12; // 1 Hour on 5 Min
//
// Set 10 $ Per each Trade on 0.01 Volume
// is Enough for Hedging ...
minRequiredProfitPerTrade = 5;
minRequiredProfitPerTradeVolumeFactor = 0.01;
//
openNextPositionOnProfit = true;
ignoreProfitForOppositeSignals = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
name != PROVIDER_NONE &&
r2r > 0 &&
(allowLong
? staticVolumeLong > 0
: true) &&
(allowShort
? staticVolumeShort > 0
: true)
//
;
//
return result;
}
//
// Retrieve Signaller Name as String ...
string GetName()
{
return ToString(name);
}
//
// Check Hedge is Enable or Not ...
bool AllowHedge()
{
//
bool result = false;
//
result =
//
minRequiredProfitPerTrade > 0 &&
minRequiredProfitPerTradeVolumeFactor > 0
//
;
//
return result;
}
//
// Generate Signal ...
bool GenerateSignal(
XSignal &signal, // Result
string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mPeriod, // Trading TimeFrame
ENUM_POSITION_TYPE mType, // Long (Buy) or Short (Sell)
ENUM_X_ORDER_MODES mMode, // Execution Mode
double mEntry, // Entry Price
double mSL = 0, // Stop Loss
double mTP = 0 // Take Profit
)
{
//
bool result = false;
//
signal.Clean();
//
// Validate Model ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isLong = IsLong(mType);
//
// Validate Signal Type ...
result = isLong
? allowLong && staticVolumeLong > 0
: allowShort && staticVolumeShort > 0;
if (!result)
{
return result;
}
//
double mVolume = isLong
? staticVolumeLong
: staticVolumeShort;
//
result = signal.Prepare(
mSymbol,
GetName(),
mPeriod,
mType,
mMode,
mEntry,
mVolume,
mSL,
mTP //
);
//
return result;
}
//
// Generate Market Signal ...
bool GenerateMarketSignal(
XSignal &signal, // Result
string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mPeriod, // Trading TimeFrame
ENUM_POSITION_TYPE mType, // Long (Buy) or Short (Sell)
double mEntry, // Entry Price
double mSL = 0, // Stop Loss
double mTP = 0 // Take Profit
)
{
//
bool result = false;
//
signal.Clean();
//
// Validate Model ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isLong = IsLong(mType);
//
// Validate Signal Type ...
result = isLong
? allowLong && staticVolumeLong > 0
: allowShort && staticVolumeShort > 0;
if (!result)
{
return result;
}
//
double mVolume = isLong
? staticVolumeLong
: staticVolumeShort;
//
result = signal.Prepare(
mSymbol,
GetName(),
mPeriod,
mType,
X_ORDER_MODE_MARKET,
mEntry,
mVolume,
mSL,
mTP //
);
//
return result;
}
//
// Check Has Conditions opr Not ...
bool HasConditions(
X121MCycleConditions &conditions, // Market Conditions
bool &hasLong, // Hold Long Conditions Result
bool &hasShort, // Hold Short Conditions Result
double &sl, // Hold SL ...
double &tp // Hold TP ...
)
{
//
bool result = false;
//
hasLong = HasLongConditions(conditions, sl, tp);
hasShort = HasShortConditions(conditions, sl, tp);
//
result = hasLong || hasShort;
//
return result;
}
//
// Check Has Long Conditions opr Not ...
virtual bool HasLongConditions(
X121MCycleConditions &conditions, // Market Conditions
double &sl, // Hold SL ...
double &tp // Hold TP ...
)
{
return false;
}
//
// Check Has Short Conditions opr Not ...
virtual bool HasShortConditions(
X121MCycleConditions &conditions, // Market Conditions
double &sl, // Hold SL ...
double &tp // Hold TP ...
)
{
return false;
}
//
// Check For Guards ...
virtual int HasGuard(XGuard &guards[])
{
return 0;
}
//
// Protected ...
protected:
};
//
// Market Class ...
class XSCX121Market : XSCBaseAlert
{
//
// Public ...
public:
//
// Props ...
XSCXHKHelper hk;
XSCXMCHelper mc;
XSCXPVHelper pv;
XSCXZGHelper zg;
XSCXTDHelper td;
XSCXMRBHelper mrb;
XSCXSTRHelper str;
XSCXCHEHelper che;
XSCXOSCHelper osc;
XSCXICHHelper ich;
XSCXDONHelper don;
XSCXASCTHelper asct;
XSCXHULLHelper hull;
XSCXSSLCHelper sslc;
//
// Properties ...
//
// Retrieve Trading Symbol ...
string GetSymbol()
{
return mInputs.cycle.symbol;
}
//
// Retrieve Cycle Time Frame ...
ENUM_TIMEFRAMES GetPeriod()
{
return mInputs.cycle.period;
}
//
// Retrieve Market Host Time Frame ...
ENUM_TIMEFRAMES GetHostPeriod()
{
return mInputs.cycle.hostPeriod;
}
//
// Count Total Available Bars in Market ...
int CountBars()
{
//
Update(0);
return mInputs.cycle.CountBars();
}
//
// Check Market is in new Bar ...
int IsNewBar()
{
//
Update(0);
return mInputs.cycle.IsNewBar();
}
//
// Retrieve Current Cycles Specific Bar ...
XOHCL GetBar(int barIndex)
{
//
Update(0);
return mInputs.cycle.GetBar(barIndex);
}
//
// Retrieve Current Bar Index based on Host Period bar Index ...
int GetBarIndex(int barIndex)
{
//
Update(barIndex);
return mInputs.cycle.GetBarIndex(barIndex);
}
//
// Retrieve Bar Time ...
datetime GetBarTime(int barIndex)
{
//
Update(0);
return mInputs.cycle.GetBarTime(barIndex);
}
//
// Retrieve Current Market Config ...
bool GetInputs(X121MCycleInputs &inputs)
{
//
bool result = false;
//
inputs = mInputs;
//
result = inputs.IsValid();
//
return result;
}
//
// Set Market Inputs and Re Initial ...
bool SetInputs(
X121MCycleInputs &inputs // Config
)
{
//
return Init(inputs);
}
//
// Tools ...
//
void GetMarketConditions(
X121MCycleConditions &conditions, // Market Conditions Result
int barIndex = 0, // Specified Bar Index
int mNumberOfItems = 15 // Number of Reading Items
)
{
//
conditions.Clear();
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex >= CountBars())
{
barIndex = CountBars() + 2;
}
//
if (mNumberOfItems <= 0)
{
mNumberOfItems = 2;
}
//
// Set Commons ...
conditions.time = GetBarTime(barIndex);
conditions.cycle = mInputs.cycle.cycle;
conditions.prefix = mInputs.cycle.prefix;
conditions.symbol = mInputs.cycle.symbol;
conditions.period = mInputs.cycle.period;
conditions.hostPeriod = mInputs.cycle.hostPeriod;
//
Clean(conditions.bars);
GetBars(
conditions.bars,
conditions.symbol,
conditions.period,
barIndex,
mNumberOfItems
//
);
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
int start = zIndex;
int count = mNumberOfItems;
//
// Filling Buffers ...
//
// XASCT ...
//
asct.CopyLong(
start,
count,
conditions.asctLongs //
);
//
asct.CopyShort(
start,
count,
conditions.asctShorts //
);
//
// XHULL ...
//
hull.CopyUp(
start,
count,
conditions.hullUps //
);
//
hull.CopyDown(
start,
count,
conditions.hullDowns //
);
//
// XSSLC ...
//
sslc.CopyUp(
start,
count,
conditions.sslcUps //
);
//
sslc.CopyDown(
start,
count,
conditions.sslcDowns //
);
//
// XHK ...
//
hk.CopyAsOHCL(
start,
count,
conditions.hkBars //
);
//
hk.CopySMAsOHCL(
start,
count,
conditions.smHKBars //
);
//
// XICH ...
//
ich.CopyTenkanSen(
start,
count,
conditions.ichTenkanSens //
);
//
ich.CopyKijunSen(
start,
count,
conditions.ichKijunSens //
);
//
ich.CopyChikouSpan(
start,
count,
conditions.ichChikouSpans //
);
//
ich.CopySenkouSpanA(
start,
count,
conditions.ichSenkouSpanAs //
);
//
ich.CopySenkouSpanB(
start,
count,
conditions.ichSenkouSpanBs //
);
//
ich.CopyFutureSenkouSpanA(
start,
count,
conditions.ichFutureSenkouSpanAs //
);
//
ich.CopyFutureSenkouSpanB(
start,
count,
conditions.ichFutureSenkouSpanBs //
);
//
// XMC ...
//
mc.CopyFast(
start,
count,
conditions.mcFasts //
);
//
mc.CopySlow(
start,
count,
conditions.mcSlows //
);
//
mc.CopyVerifier(
start,
count,
conditions.mcVerifiers //
);
//
// XSTR ...
//
str.CopyTrend(
start,
count,
conditions.strTrends //
);
//
str.CopyState(
start,
count,
conditions.strStates //
);
//
// XZG ...
//
zg.CopyMain(
start,
count,
conditions.zigzags //
);
//
zg.CopyPeaksAndVales(
start,
count,
conditions.zigzagPVs //
);
//
// XMRB ...
//
mrb.CopyFast(
start,
count,
conditions.mrbFasts //
);
//
mrb.CopySlow(
start,
count,
conditions.mrbSlows //
);
//
// Ribbon 1 ...
//
mrb.CopyR1Fast(
start,
count,
conditions.mrb1Fasts //
);
//
mrb.CopyR1Slow(
start,
count,
conditions.mrb1Slows //
);
//
// Ribbon 2 ...
//
mrb.CopyR2Fast(
start,
count,
conditions.mrb2Fasts //
);
//
mrb.CopyR2Slow(
start,
count,
conditions.mrb2Slows //
);
//
// Ribbon 3 ...
//
mrb.CopyR3Fast(
start,
count,
conditions.mrb3Fasts //
);
//
mrb.CopyR3Slow(
start,
count,
conditions.mrb3Slows //
);
//
// Ribbon 4 ...
//
mrb.CopyR4Fast(
start,
count,
conditions.mrb4Fasts //
);
//
mrb.CopyR4Slow(
start,
count,
conditions.mrb4Slows //
);
//
// Ribbon 5 ...
//
mrb.CopyR5Fast(
start,
count,
conditions.mrb5Fasts //
);
//
mrb.CopyR5Slow(
start,
count,
conditions.mrb5Slows //
);
//
// Ribbon 6 ...
//
mrb.CopyR6Fast(
start,
count,
conditions.mrb6Fasts //
);
//
mrb.CopyR6Slow(
start,
count,
conditions.mrb6Slows //
);
//
// XCHE ...
//
che.CopyLongExit1(
start,
count,
conditions.cheLongExit1s //
);
//
che.CopyLongExit2(
start,
count,
conditions.cheLongExit2s //
);
//
che.CopyShortExit1(
start,
count,
conditions.cheShortExit1s //
);
//
che.CopyShortExit2(
start,
count,
conditions.cheShortExit2s //
);
//
// XTD ...
//
td.CopyBullish(
start,
count,
conditions.tdBullishs //
);
//
td.CopyBearish(
start,
count,
conditions.tdBearishs //
);
//
td.CopySignal(
start,
count,
conditions.tdSignals //
);
//
// XDON ...
//
don.CopyUpperO(
start,
count,
conditions.donUpperOs //
);
//
don.CopyLowerO(
start,
count,
conditions.donLowerOs //
);
//
don.CopyUpperC(
start,
count,
conditions.donUpperCs //
);
//
don.CopyLowerC(
start,
count,
conditions.donLowerCs //
);
//
don.CopyUpperH(
start,
count,
conditions.donUpperHs //
);
//
don.CopyLowerH(
start,
count,
conditions.donLowerHs //
);
//
don.CopyUpperL(
start,
count,
conditions.donUpperLs //
);
//
don.CopyLowerL(
start,
count,
conditions.donLowerLs //
);
//
// XPV ...
//
pv.CopyPeak(
start,
count,
conditions.pvPeaks //
);
//
pv.CopyVale(
start,
count,
conditions.pvVales //
);
//
pv.CopyResistance(
start,
count,
conditions.pvResistances //
);
//
pv.CopySupport(
start,
count,
conditions.pvSupports //
);
//
pv.CopyFib1(
start,
count,
conditions.pvFib1s //
);
//
pv.CopyFib2(
start,
count,
conditions.pvFib2s //
);
//
pv.CopyFib3(
start,
count,
conditions.pvFib3s //
);
//
pv.CopyFib4(
start,
count,
conditions.pvFib4s //
);
//
pv.CopyFib5(
start,
count,
conditions.pvFib5s //
);
//
pv.CopySCHH(
start,
count,
conditions.pvSCHHs //
);
//
pv.CopySCLL(
start,
count,
conditions.pvSCLLs //
);
//
pv.CopyMCHH(
start,
count,
conditions.pvMCHHs //
);
//
pv.CopyMCLL(
start,
count,
conditions.pvMCLLs //
);
//
pv.CopyLCHH(
start,
count,
conditions.pvLCHHs //
);
//
pv.CopyLCLL(
start,
count,
conditions.pvLCLLs //
);
//
pv.CopyHCHH(
start,
count,
conditions.pvHCHHs //
);
//
pv.CopyHCLL(
start,
count,
conditions.pvHCLLs //
);
//
// XOSC ...
//
// ATR ...
osc.CopyATR(
start,
count,
conditions.oscAtrs //
);
//
// VOLUE ...
osc.CopyVolume(
start,
count,
conditions.oscVolumes //
);
//
// MOMENTUM ...
osc.CopyMomentum(
start,
count,
conditions.oscMomentums //
);
//
// SAR ...
osc.CopySAR(
start,
count,
conditions.oscSars //
);
//
// RSI ...
osc.CopyRSI(
start,
count,
conditions.oscRsis //
);
//
// CCI ...
osc.CopyCCI(
start,
count,
conditions.oscCcis //
);
//
// STDDEV ...
osc.CopySTDDEV(
start,
count,
conditions.oscStddevs //
);
//
// BULLPOWER ...
osc.CopyBullPower(
start,
count,
conditions.oscBullPs //
);
//
// BEARPOWER ...
osc.CopyBearPower(
start,
count,
conditions.oscBearPs //
);
//
// RVI ...
//
osc.CopyRVI(
start,
count,
conditions.oscRviMains //
);
//
osc.CopyRVISignal(
start,
count,
conditions.oscRviSignals //
);
//
// MACD ...
//
osc.CopyMACD(
start,
count,
conditions.oscMacdMains //
);
//
osc.CopyMACDSignal(
start,
count,
conditions.oscMacdSignals //
);
//
// STOCH ...
//
osc.CopySTOCH(
start,
count,
conditions.oscStochMains //
);
//
osc.CopySTOCHSignal(
start,
count,
conditions.oscStochSignals //
);
//
// Now we Have all Buffers ...
// Going to Extract Market Conditions Variables ...
//
XOHCL zBar = conditions.bars[zIndex];
XOHCL cBar = conditions.bars[cIndex];
XOHCL pBar = conditions.bars[pIndex];
//
// Candlestic ...
//
bool isLastBullish =
//
cBar.IsBullish()
//
;
//
bool isLastBearish =
//
cBar.IsBearish()
//
;
//
bool isCurrentBullish =
//
zBar.IsBullish()
//
;
//
bool isCurrentBearish =
//
zBar.IsBearish()
//
;
//
bool isCurrentMidLineOverLastHigh =
//
zBar.GetMid() > cBar.high;
//
;
//
bool isCurrentMidLineUnderLastLow =
//
zBar.GetMid() < cBar.low
//
;
//
bool isCurrentMidLineOverLastUp =
//
zBar.GetMid() > cBar.GetUp()
//
;
//
bool isCurrentMidLineUnderLastDown =
//
zBar.GetMid() < cBar.GetDown()
//
;
//
bool isCurrentMidLineOverLastMidLine =
//
zBar.GetMid() > cBar.GetMid()
//
;
//
bool isCurrentMidLineUnderLastMidLine =
//
zBar.GetMid() < cBar.GetMid()
//
;
//
// XHK ...
//
XOHCL zHKBar = conditions.hkBars[zIndex];
XOHCL cHKBar = conditions.hkBars[cIndex];
XOHCL pHKBar = conditions.hkBars[pIndex];
//
bool isHKBullish = cHKBar.IsBullish();
bool isHKBearish = cHKBar.IsBearish();
bool isClosedOverHK = cBar.close > cHKBar.high;
bool isClosedUnderHK = cBar.close < cHKBar.low;
bool isHKSwitchedToBullish = cHKBar.IsBullish() && !pHKBar.IsBullish();
bool isHKSwitchedToBearish = cHKBar.IsBearish() && !pHKBar.IsBearish();
//
XOHCL zSMHKBar = conditions.smHKBars[zIndex];
XOHCL cSMHKBar = conditions.smHKBars[cIndex];
XOHCL pSMHKBar = conditions.smHKBars[pIndex];
//
bool isSMHKBullish = cSMHKBar.IsBullish();
bool isSMHKBearish = cSMHKBar.IsBearish();
bool isClosedOverSMHK = cBar.close > cSMHKBar.high;
bool isClosedUnderSMHK = cBar.close < cSMHKBar.low;
bool isSMHKSwitchedToBullish = cSMHKBar.IsBullish() && !pSMHKBar.IsBullish();
bool isSMHKSwitchedToBearish = cSMHKBar.IsBearish() && !pSMHKBar.IsBearish();
//
// XASCT ...
//
bool isASCTLong = conditions.asctLongs[zIndex] > 0;
bool isASCTShort = conditions.asctShorts[zIndex] > 0;
//
// XSSLC ...
//
bool isSSLCBullish = conditions.sslcUps[cIndex] > conditions.sslcDowns[cIndex];
bool isSSLCBullishPrev = conditions.sslcUps[pIndex] > conditions.sslcDowns[pIndex];
//
bool isSSLCBearish = conditions.sslcDowns[cIndex] > conditions.sslcUps[cIndex];
bool isSSLCBearishPrev = conditions.sslcDowns[pIndex] > conditions.sslcUps[pIndex];
//
bool isSSLCSwitchedToBullish = isSSLCBullish &&
!isSSLCBullishPrev;
bool isSSLCSwitchedToBearish = isSSLCBearish &&
!isSSLCBearishPrev;
//
// XHULL ...
//
bool isHullUpBullish = conditions.hullUps[cIndex] > conditions.hullUps[pIndex];
bool isHullUpBullishPrev = conditions.hullUps[pIndex] > conditions.hullUps[ppIndex];
//
bool isHullUpBearish = conditions.hullUps[cIndex] < conditions.hullUps[pIndex];
bool isHullUpBearishPrev = conditions.hullUps[pIndex] < conditions.hullUps[ppIndex];
//
bool isHullDownBullish = conditions.hullDowns[cIndex] > conditions.hullDowns[pIndex];
bool isHullDownBullishPrev = conditions.hullDowns[pIndex] > conditions.hullDowns[ppIndex];
//
bool isHullDownBearish = conditions.hullDowns[cIndex] < conditions.hullDowns[pIndex];
bool isHullDownBearishPrev = conditions.hullDowns[pIndex] < conditions.hullDowns[ppIndex];
//
bool isHullBullish = isHullUpBullish && isHullDownBullish;
bool isHullBullishPrev = isHullUpBullishPrev && isHullDownBullishPrev;
//
bool isHullBearish = isHullUpBearish && isHullDownBearish;
bool isHullBearishPrev = isHullUpBearishPrev && isHullDownBearishPrev;
bool isHullSwitchedToBullish = isHullBullish &&
!isHullBullishPrev;
bool isHullSwitchedToBearish = isHullBearish &&
!isHullBearishPrev;
//
// XICH ...
//
bool isClosedOverKijunSen = cBar.close > conditions.ichKijunSens[cIndex];
bool isClosedUnderKijunSen = cBar.close < conditions.ichKijunSens[cIndex];
bool isTenkanSenOverKijunSen = conditions.ichTenkanSens[cIndex] > conditions.ichKijunSens[cIndex];
bool isTenkanSenUnderKijunSen = conditions.ichTenkanSens[cIndex] < conditions.ichKijunSens[cIndex];
//
bool isTenkanSenOverKijunSenPrev = conditions.ichTenkanSens[pIndex] > conditions.ichKijunSens[pIndex];
bool isTenkanSenUnderKijunSenPrev = conditions.ichTenkanSens[pIndex] < conditions.ichKijunSens[pIndex];
//
bool isTenkanSenCrossedOverKijunSen = isTenkanSenOverKijunSen &&
!isTenkanSenOverKijunSenPrev;
bool isTenkanSenCrossedUnderKijunSen = isTenkanSenUnderKijunSen &&
!isTenkanSenUnderKijunSenPrev;
//
bool isSenkouSpanAOverB = conditions.ichSenkouSpanAs[cIndex] > conditions.ichSenkouSpanBs[cIndex];
bool isSenkouSpanAUnderB = conditions.ichSenkouSpanAs[cIndex] < conditions.ichSenkouSpanBs[cIndex];
//
bool isSenkouSpanAOverBPrev = conditions.ichSenkouSpanAs[pIndex] > conditions.ichSenkouSpanBs[pIndex];
bool isSenkouSpanAUnderBPrev = conditions.ichSenkouSpanAs[pIndex] < conditions.ichSenkouSpanBs[pIndex];
//
bool isSenkouSpanAOverLast = conditions.ichSenkouSpanAs[cIndex] > conditions.ichSenkouSpanAs[pIndex];
bool isSenkouSpanAUnderLast = conditions.ichSenkouSpanAs[cIndex] < conditions.ichSenkouSpanAs[pIndex];
//
bool isSenkouSpanAOverLastPrev = conditions.ichSenkouSpanAs[pIndex] > conditions.ichSenkouSpanAs[ppIndex];
bool isSenkouSpanAUnderLastPrev = conditions.ichSenkouSpanAs[pIndex] < conditions.ichSenkouSpanAs[ppIndex];
//
bool isFutureSenkouSpanAOverB = conditions.ichFutureSenkouSpanAs[cIndex] > conditions.ichFutureSenkouSpanBs[cIndex];
bool isFutureSenkouSpanAUnderB = conditions.ichFutureSenkouSpanAs[cIndex] < conditions.ichFutureSenkouSpanBs[cIndex];
//
bool isFutureSenkouSpanAOverBPrev = conditions.ichFutureSenkouSpanAs[pIndex] > conditions.ichFutureSenkouSpanBs[pIndex];
bool isFutureSenkouSpanAUnderBPrev = conditions.ichFutureSenkouSpanAs[pIndex] < conditions.ichFutureSenkouSpanBs[pIndex];
//
bool isFutureSenkouSpanAOverLast = conditions.ichFutureSenkouSpanAs[cIndex] > conditions.ichFutureSenkouSpanAs[pIndex];
bool isFutureSenkouSpanAUnderLast = conditions.ichFutureSenkouSpanAs[cIndex] < conditions.ichFutureSenkouSpanAs[pIndex];
//
bool isFutureSenkouSpanAOverLastPrev = conditions.ichFutureSenkouSpanAs[pIndex] > conditions.ichFutureSenkouSpanAs[ppIndex];
bool isFutureSenkouSpanAUnderLastPrev = conditions.ichFutureSenkouSpanAs[pIndex] < conditions.ichFutureSenkouSpanAs[ppIndex];
//
bool isSenkouSpanACrossedOverB = isSenkouSpanAOverB &&
!isSenkouSpanAOverBPrev;
bool isSenkouSpanACrossedUnderB = isSenkouSpanAUnderB &&
!isSenkouSpanAUnderBPrev;
bool isSenkouSpanACrossedOverLast = isSenkouSpanAOverLast &&
!isSenkouSpanAOverLastPrev;
bool isSenkouSpanACrossedUnderLast = isSenkouSpanAUnderLast &&
!isSenkouSpanAUnderLastPrev;
bool isFutureSenkouSpanACrossedOverB = isFutureSenkouSpanAOverB &&
!isFutureSenkouSpanAOverBPrev;
bool isFutureSenkouSpanACrossedUnderB = isFutureSenkouSpanAUnderB &&
!isFutureSenkouSpanAUnderBPrev;
bool isFutureSenkouSpanACrossedOverLast = isFutureSenkouSpanAOverLast &&
!isFutureSenkouSpanAOverLastPrev;
bool isFutureSenkouSpanACrossedUnderLast = isFutureSenkouSpanAUnderLast &&
!isFutureSenkouSpanAUnderLastPrev;
//
// XMC ...
//
bool isMCFastOverSlow = conditions.mcFasts[cIndex] > conditions.mcSlows[cIndex];
bool isMCFastUnderSlow = conditions.mcFasts[cIndex] < conditions.mcSlows[cIndex];
//
bool isMCFastOverSlowPrev = conditions.mcFasts[pIndex] > conditions.mcSlows[pIndex];
bool isMCFastUnderSlowPrev = conditions.mcFasts[pIndex] < conditions.mcSlows[pIndex];
//
bool isMCFastOverVerifier = conditions.mcFasts[cIndex] > conditions.mcVerifiers[cIndex];
bool isMCFastUnderVerifier = conditions.mcFasts[cIndex] < conditions.mcVerifiers[cIndex];
//
bool isMCFastOverVerifierPrev = conditions.mcFasts[pIndex] > conditions.mcVerifiers[pIndex];
bool isMCFastUnderVerifierPrev = conditions.mcFasts[pIndex] < conditions.mcVerifiers[pIndex];
//
bool isMCSlowOverVerifier = conditions.mcSlows[cIndex] > conditions.mcVerifiers[cIndex];
bool isMCSlowUnderVerifier = conditions.mcSlows[cIndex] < conditions.mcVerifiers[cIndex];
//
bool isMCSlowOverVerifierPrev = conditions.mcSlows[pIndex] > conditions.mcVerifiers[pIndex];
bool isMCSlowUnderVerifierPrev = conditions.mcSlows[pIndex] < conditions.mcVerifiers[pIndex];
//
bool isMCFastCrossedOverSlow = isMCFastOverSlow &&
!isMCFastOverSlowPrev;
bool isMCFastCrossedUnderSlow = isMCFastUnderSlow &&
!isMCFastUnderSlowPrev;
bool isMCFastCrossedOverVerifier = isMCFastOverVerifier &&
!isMCFastOverVerifierPrev;
bool isMCFastCrossedUnderVerifier = isMCFastUnderVerifier &&
!isMCFastUnderVerifierPrev;
bool isMCSlowCrossedOverVerifier = isMCSlowOverVerifier &&
!isMCSlowOverVerifierPrev;
bool isMCSlowCrossedUnderVerifier = isMCSlowUnderVerifier &&
!isMCSlowUnderVerifierPrev;
//
// XSTR ...
//
bool isTrendBullish = str.IsBullish(conditions.strStates[cIndex]);
bool isTrendBearish = str.IsBearish(conditions.strStates[cIndex]);
bool isTrendSwitchedToBullish = str.IsBullish(conditions.strStates[cIndex]) &&
!str.IsBullish(conditions.strStates[pIndex]);
bool isTrendSwitchedToBearish = str.IsBearish(conditions.strStates[cIndex]) &&
!str.IsBearish(conditions.strStates[pIndex]);
//
// XZG ...
//
bool isZigZagInPeak = conditions.zigzags[cIndex] < conditions.zigzagPVs[cIndex];
bool isZigZagInVale = conditions.zigzags[cIndex] > conditions.zigzagPVs[cIndex];
//
// XMRB ...
//
bool isMRBFastOverSlow = conditions.mrbFasts[cIndex] > conditions.mrbSlows[cIndex];
bool isMRBFastUnderSlow = conditions.mrbFasts[cIndex] < conditions.mrbSlows[cIndex];
//
bool isMRBFastOverSlowPrev = conditions.mrbFasts[pIndex] > conditions.mrbSlows[pIndex];
bool isMRBFastUnderSlowPrev = conditions.mrbFasts[pIndex] < conditions.mrbSlows[pIndex];
//
bool isMRBFastCrossedOverSlow = isMRBFastOverSlow &&
!isMRBFastOverSlowPrev;
bool isMRBFastCrossedUnderSlow = isMRBFastUnderSlow &&
!isMRBFastUnderSlowPrev;
//
bool isMRBFastOverVerifier = conditions.mrbFasts[cIndex] > conditions.mcVerifiers[cIndex];
bool isMRBFastUnderVerifier = conditions.mrbFasts[cIndex] < conditions.mcVerifiers[cIndex];
//
bool isMRBFastOverVerifierPrev = conditions.mrbFasts[pIndex] > conditions.mcVerifiers[pIndex];
bool isMRBFastUnderVerifierPrev = conditions.mrbFasts[pIndex] < conditions.mcVerifiers[pIndex];
//
bool isMRBFastCrossedtOverVerifier = isMRBFastOverVerifier &&
!isMRBFastOverVerifierPrev;
bool isMRBFastCrossedUnderVerifier = isMRBFastUnderVerifier &&
!isMRBFastUnderVerifierPrev;
//
bool isMRBSlowOverVerifier = conditions.mrbSlows[cIndex] > conditions.mcVerifiers[cIndex];
bool isMRBSlowUnderVerifier = conditions.mrbSlows[cIndex] < conditions.mcVerifiers[cIndex];
//
bool isMRBSlowOverVerifierPrev = conditions.mrbSlows[pIndex] > conditions.mcVerifiers[pIndex];
bool isMRBSlowUnderVerifierPrev = conditions.mrbSlows[pIndex] < conditions.mcVerifiers[pIndex];
//
bool isMRBSlowCrossedtOverVerifier = isMRBSlowOverVerifier &&
!isMRBSlowOverVerifierPrev;
bool isMRBSlowCrossedUnderVerifier = isMRBSlowUnderVerifier &&
!isMRBSlowUnderVerifierPrev;
//
// XCHE ...
//
bool isCHEBullish = NotEmpty(conditions.cheLongExit1s[cIndex]) &&
NotEmpty(conditions.cheLongExit2s[cIndex]);
bool isCHEBearish = NotEmpty(conditions.cheShortExit1s[cIndex]) &&
NotEmpty(conditions.cheShortExit2s[cIndex]);
//
bool isCHEBullishPrev = NotEmpty(conditions.cheLongExit1s[pIndex]) &&
NotEmpty(conditions.cheLongExit2s[pIndex]);
bool isCHEBearishPrev = NotEmpty(conditions.cheShortExit1s[pIndex]) &&
NotEmpty(conditions.cheShortExit2s[pIndex]);
//
bool isCHESwitchedToBullish = isCHEBullish &&
!isCHEBullishPrev;
bool isCHESwitchedToBearish = isCHEBearish &&
!isCHEBearishPrev;
//
// XTD ...
//
bool isTDBullish = conditions.tdBullishs[cIndex] > conditions.tdBearishs[cIndex];
bool isTDBearish = conditions.tdBearishs[cIndex] > conditions.tdBullishs[cIndex];
//
bool isTDBullishPrev = conditions.tdBullishs[pIndex] > conditions.tdBearishs[pIndex];
bool isTDBearishPrev = conditions.tdBearishs[pIndex] > conditions.tdBullishs[pIndex];
//
bool isTDSwitchedToBullish = isTDBullish &&
!isTDBullishPrev;
bool isTDSwitchedToBearish = isTDBearish &&
!isTDBearishPrev;
//
// XDON ...
//
double cDonMaxUpper = don.GetMaxUpper(cIndex);
double pDonMaxUpper = don.GetMaxUpper(pIndex);
//
double cDonMinUpper = don.GetMinUpper(cIndex);
double pDonMinUpper = don.GetMinUpper(pIndex);
//
double cDonMaxLower = don.GetMaxLower(cIndex);
double pDonMaxLower = don.GetMaxLower(pIndex);
//
double cDonMinLower = don.GetMinLower(cIndex);
double pDonMinLower = don.GetMinLower(pIndex);
//
bool isDONAttachedMaxLower = cBar.low <= cDonMaxLower;
bool isDONAttachedMinLower = cBar.low <= cDonMinLower;
//
bool isDONAttachedMaxLowerPrev = pBar.low <= pDonMaxLower;
bool isDONAttachedMinLowerPrev = pBar.low <= pDonMinLower;
//
bool isDONCrossedOverMaxLower = !isDONAttachedMaxLower &&
isDONAttachedMaxLowerPrev;
bool isDONCrossedUnderMaxLower = isDONAttachedMaxLower &&
!isDONAttachedMaxLowerPrev;
//
bool isDONCrossedOverMinLower = !isDONAttachedMinLower &&
isDONAttachedMinLowerPrev;
bool isDONCrossedUnderMinLower = isDONAttachedMinLower &&
!isDONAttachedMinLowerPrev;
//
bool isDONAttachedMaxUpper = cBar.high >= cDonMaxUpper;
bool isDONAttachedMinUpper = cBar.high >= cDonMinUpper;
//
bool isDONAttachedMaxUpperPrev = pBar.high >= pDonMaxUpper;
bool isDONAttachedMinUpperPrev = pBar.high >= pDonMinUpper;
//
bool isDONCrossedOverMaxUpper = isDONAttachedMaxUpper &&
!isDONAttachedMaxUpperPrev;
bool isDONCrossedUnderMaxUpper = !isDONAttachedMaxUpper &&
isDONAttachedMaxUpperPrev;
//
bool isDONCrossedOverMinUpper = isDONAttachedMinUpper &&
!isDONAttachedMinUpperPrev;
bool isDONCrossedUnderMinUpper = !isDONAttachedMinUpper &&
isDONAttachedMinUpperPrev;
//
// XPV ...
//
bool isNewPeak = conditions.pvPeaks[cIndex] != conditions.pvPeaks[pIndex];
bool isNewPeakOverLast = isNewPeak &&
conditions.pvPeaks[cIndex] > conditions.pvPeaks[pIndex];
bool isNewPeakUnderLast = isNewPeak &&
conditions.pvPeaks[cIndex] < conditions.pvPeaks[pIndex];
//
bool isNewVale = conditions.pvVales[cIndex] != conditions.pvVales[pIndex];
bool isNewValeOverLast = isNewVale &&
conditions.pvVales[cIndex] > conditions.pvVales[pIndex];
bool isNewValeUnderLast = isNewVale &&
conditions.pvVales[cIndex] < conditions.pvVales[pIndex];
//
bool isFiboIncreased =
//
conditions.pvFib1s[cIndex] > conditions.pvFib1s[pIndex] &&
conditions.pvFib2s[cIndex] > conditions.pvFib2s[pIndex] &&
conditions.pvFib3s[cIndex] > conditions.pvFib3s[pIndex] &&
conditions.pvFib4s[cIndex] > conditions.pvFib4s[pIndex] &&
conditions.pvFib5s[cIndex] > conditions.pvFib5s[pIndex]
//
;
bool isFiboDecreased =
//
conditions.pvFib1s[cIndex] < conditions.pvFib1s[pIndex] &&
conditions.pvFib2s[cIndex] < conditions.pvFib2s[pIndex] &&
conditions.pvFib3s[cIndex] < conditions.pvFib3s[pIndex] &&
conditions.pvFib4s[cIndex] < conditions.pvFib4s[pIndex] &&
conditions.pvFib5s[cIndex] < conditions.pvFib5s[pIndex]
//
;
bool isFiboSectionChanged =
//
(isFiboDecreased &&
isNewPeakUnderLast)
//
||
//
(isFiboIncreased &&
isNewValeOverLast)
//
;
//
// SC ...
//
bool isSCHHBullish = conditions.pvSCHHs[cIndex] > conditions.pvSCHHs[pIndex];
bool isSCLLBullish = conditions.pvSCLLs[cIndex] > conditions.pvSCLLs[pIndex];
//
bool isSCHHBullishPrev = conditions.pvSCHHs[pIndex] > conditions.pvSCHHs[ppIndex];
bool isSCLLBullishPrev = conditions.pvSCLLs[pIndex] > conditions.pvSCLLs[ppIndex];
//
bool isSCBullish = isSCHHBullish &&
isSCLLBullish;
//
bool isSCBullishPrev = isSCHHBullishPrev &&
isSCLLBullishPrev;
//
bool isSCHHSwitchedToBullish = isSCHHBullish &&
!isSCHHBullishPrev;
bool isSCLLSwitchedToBullish = isSCLLBullish &&
!isSCLLBullishPrev;
//
bool isSCHHBearish = conditions.pvSCHHs[cIndex] < conditions.pvSCHHs[pIndex];
bool isSCLLBearish = conditions.pvSCLLs[cIndex] < conditions.pvSCLLs[pIndex];
//
bool isSCHHBearishPrev = conditions.pvSCHHs[pIndex] < conditions.pvSCHHs[ppIndex];
bool isSCLLBearishPrev = conditions.pvSCLLs[pIndex] < conditions.pvSCLLs[ppIndex];
//
bool isSCBearish = isSCHHBearish &&
isSCLLBearish;
//
bool isSCBearishPrev = isSCHHBearishPrev &&
isSCLLBearishPrev;
//
bool isSCHHSwitchedToBearish = isSCHHBearish &&
!isSCHHBearishPrev;
bool isSCLLSwitchedToBeraish = isSCLLBearish &&
!isSCLLBearishPrev;
//
bool isSCSwitchedToBullish =
//
(isSCHHSwitchedToBullish &&
!isSCLLBearish)
//
||
//
(isSCLLSwitchedToBullish &&
!isSCHHBearish)
//
;
//
bool isSCSwitchedToBearish =
//
(isSCHHSwitchedToBearish &&
!isSCLLBullish)
//
||
//
(isSCLLSwitchedToBeraish &&
!isSCHHBullish)
//
;
//
// MC ...
//
bool isMCHHBullish = conditions.pvMCHHs[cIndex] > conditions.pvMCHHs[pIndex];
bool isMCLLBullish = conditions.pvMCLLs[cIndex] > conditions.pvMCLLs[pIndex];
//
bool isMCHHBullishPrev = conditions.pvMCHHs[pIndex] > conditions.pvMCHHs[ppIndex];
bool isMCLLBullishPrev = conditions.pvMCLLs[pIndex] > conditions.pvMCLLs[ppIndex];
//
bool isMCBullish = isMCHHBullish &&
isMCLLBullish;
//
bool isMCBullishPrev = isMCHHBullishPrev &&
isMCLLBullishPrev;
//
bool isMCHHSwitchedToBullish = isMCHHBullish &&
!isMCHHBullishPrev;
bool isMCLLSwitchedToBullish = isMCLLBullish &&
!isMCLLBullishPrev;
//
bool isMCHHBearish = conditions.pvMCHHs[cIndex] < conditions.pvMCHHs[pIndex];
bool isMCLLBearish = conditions.pvMCLLs[cIndex] < conditions.pvMCLLs[pIndex];
//
bool isMCHHBearishPrev = conditions.pvMCHHs[pIndex] < conditions.pvMCHHs[ppIndex];
bool isMCLLBearishPrev = conditions.pvMCLLs[pIndex] < conditions.pvMCLLs[ppIndex];
//
bool isMCBearish = isMCHHBearish &&
isMCLLBearish;
//
bool isMCBearishPrev = isMCHHBearishPrev &&
isMCLLBearishPrev;
//
bool isMCHHSwitchedToBearish = isMCHHBearish &&
!isMCHHBearishPrev;
bool isMCLLSwitchedToBeraish = isMCLLBearish &&
!isMCLLBearishPrev;
//
bool isMCSwitchedToBullish =
//
(isMCHHSwitchedToBullish &&
!isMCLLBearish)
//
||
//
(isMCLLSwitchedToBullish &&
!isMCHHBearish)
//
;
//
bool isMCSwitchedToBearish =
//
(isMCHHSwitchedToBearish &&
!isMCLLBullish)
//
||
//
(isMCLLSwitchedToBeraish &&
!isMCHHBullish)
//
;
//
// LC ...
//
bool isLCHHBullish = conditions.pvLCHHs[cIndex] > conditions.pvLCHHs[pIndex];
bool isLCLLBullish = conditions.pvLCLLs[cIndex] > conditions.pvLCLLs[pIndex];
//
bool isLCHHBullishPrev = conditions.pvLCHHs[pIndex] > conditions.pvLCHHs[ppIndex];
bool isLCLLBullishPrev = conditions.pvLCLLs[pIndex] > conditions.pvLCLLs[ppIndex];
//
bool isLCBullish = isLCHHBullish &&
isLCLLBullish;
//
bool isLCBullishPrev = isLCHHBullishPrev &&
isLCLLBullishPrev;
//
bool isLCHHSwitchedToBullish = isLCHHBullish &&
!isLCHHBullishPrev;
bool isLCLLSwitchedToBullish = isLCLLBullish &&
!isLCLLBullishPrev;
//
bool isLCHHBearish = conditions.pvLCHHs[cIndex] < conditions.pvLCHHs[pIndex];
bool isLCLLBearish = conditions.pvLCLLs[cIndex] < conditions.pvLCLLs[pIndex];
//
bool isLCHHBearishPrev = conditions.pvLCHHs[pIndex] < conditions.pvLCHHs[ppIndex];
bool isLCLLBearishPrev = conditions.pvLCLLs[pIndex] < conditions.pvLCLLs[ppIndex];
//
bool isLCBearish = isLCHHBearish &&
isLCLLBearish;
//
bool isLCBearishPrev = isLCHHBearishPrev &&
isLCLLBearishPrev;
//
bool isLCHHSwitchedToBearish = isLCHHBearish &&
!isLCHHBearishPrev;
bool isLCLLSwitchedToBeraish = isLCLLBearish &&
!isLCLLBearishPrev;
//
bool isLCSwitchedToBullish =
//
(isLCHHSwitchedToBullish &&
!isLCLLBearish)
//
||
//
(isLCLLSwitchedToBullish &&
!isLCHHBearish)
//
;
//
bool isLCSwitchedToBearish =
//
(isLCHHSwitchedToBearish &&
!isLCLLBullish)
//
||
//
(isLCLLSwitchedToBeraish &&
!isLCHHBullish)
//
;
//
// HC ...
//
bool isHCHHBullish = conditions.pvHCHHs[cIndex] > conditions.pvHCHHs[pIndex];
bool isHCLLBullish = conditions.pvHCLLs[cIndex] > conditions.pvHCLLs[pIndex];
//
bool isHCHHBullishPrev = conditions.pvHCHHs[pIndex] > conditions.pvHCHHs[ppIndex];
bool isHCLLBullishPrev = conditions.pvHCLLs[pIndex] > conditions.pvHCLLs[ppIndex];
//
bool isHCBullish = isHCHHBullish &&
isHCLLBullish;
//
bool isHCBullishPrev = isHCHHBullishPrev &&
isHCLLBullishPrev;
//
bool isHCHHSwitchedToBullish = isHCHHBullish &&
!isHCHHBullishPrev;
bool isHCLLSwitchedToBullish = isHCLLBullish &&
!isHCLLBullishPrev;
//
bool isHCHHBearish = conditions.pvHCHHs[cIndex] < conditions.pvHCHHs[pIndex];
bool isHCLLBearish = conditions.pvHCLLs[cIndex] < conditions.pvHCLLs[pIndex];
//
bool isHCHHBearishPrev = conditions.pvHCHHs[pIndex] < conditions.pvHCHHs[ppIndex];
bool isHCLLBearishPrev = conditions.pvHCLLs[pIndex] < conditions.pvHCLLs[ppIndex];
//
bool isHCBearish = isHCHHBearish &&
isHCLLBearish;
//
bool isHCBearishPrev = isHCHHBearishPrev &&
isHCLLBearishPrev;
//
bool isHCHHSwitchedToBearish = isHCHHBearish &&
!isHCHHBearishPrev;
bool isHCLLSwitchedToBeraish = isHCLLBearish &&
!isHCLLBearishPrev;
//
bool isHCSwitchedToBullish =
//
(isHCHHSwitchedToBullish &&
!isHCLLBearish)
//
||
//
(isHCLLSwitchedToBullish &&
!isHCHHBearish)
//
;
//
bool isHCSwitchedToBearish =
//
(isHCHHSwitchedToBearish &&
!isHCLLBullish)
//
||
//
(isHCLLSwitchedToBeraish &&
!isHCHHBullish)
//
;
//
// Setting Conditional Variables ...
//
conditions.isLastBullish = isLastBullish;
conditions.isLastBearish = isLastBearish;
conditions.isCurrentBullish = isCurrentBullish;
conditions.isCurrentBearish = isCurrentBearish;
conditions.isCurrentMidLineOverLastHigh = isCurrentMidLineOverLastHigh;
conditions.isCurrentMidLineUnderLastLow = isCurrentMidLineUnderLastLow;
conditions.isCurrentMidLineOverLastUp = isCurrentMidLineOverLastUp;
conditions.isCurrentMidLineUnderLastDown = isCurrentMidLineUnderLastDown;
conditions.isCurrentMidLineOverLastMidLine = isCurrentMidLineOverLastMidLine;
conditions.isCurrentMidLineUnderLastMidLine = isCurrentMidLineUnderLastMidLine;
//
conditions.isASCTLong = isASCTLong;
conditions.isASCTShort = isASCTShort;
//
conditions.isSSLCBullish = isSSLCBullish;
conditions.isSSLCBearish = isSSLCBearish;
conditions.isSSLCSwitchedToBullish = isSSLCSwitchedToBullish;
conditions.isSSLCSwitchedToBearish = isSSLCSwitchedToBearish;
//
conditions.isHullBullish = isHullBullish;
conditions.isHullBearish = isHullBearish;
conditions.isHullUpBullish = isHullUpBullish;
conditions.isHullUpBearish = isHullUpBearish;
conditions.isHullDownBullish = isHullDownBullish;
conditions.isHullDownBearish = isHullDownBearish;
conditions.isHullSwitchedToBullish = isHullSwitchedToBullish;
conditions.isHullSwitchedToBearish = isHullSwitchedToBearish;
//
conditions.isHKBullish = isHKBullish;
conditions.isHKBearish = isHKBearish;
conditions.isClosedOverHK = isClosedOverHK;
conditions.isClosedUnderHK = isClosedUnderHK;
conditions.isHKSwitchedToBullish = isHKSwitchedToBullish;
conditions.isHKSwitchedToBearish = isHKSwitchedToBearish;
//
conditions.isSMHKBullish = isSMHKBullish;
conditions.isSMHKBearish = isSMHKBearish;
conditions.isClosedOverSMHK = isClosedOverSMHK;
conditions.isClosedUnderSMHK = isClosedUnderSMHK;
conditions.isSMHKSwitchedToBullish = isSMHKSwitchedToBullish;
conditions.isSMHKSwitchedToBearish = isSMHKSwitchedToBearish;
//
conditions.isClosedOverKijunSen = isClosedOverKijunSen;
conditions.isClosedUnderKijunSen = isClosedUnderKijunSen;
conditions.isTenkanSenOverKijunSen = isTenkanSenOverKijunSen;
conditions.isTenkanSenUnderKijunSen = isTenkanSenUnderKijunSen;
conditions.isTenkanSenCrossedOverKijunSen = isTenkanSenCrossedOverKijunSen;
conditions.isTenkanSenCrossedUnderKijunSen = isTenkanSenCrossedUnderKijunSen;
//
conditions.isSenkouSpanAOverB = isSenkouSpanAOverB;
conditions.isSenkouSpanAUnderB = isSenkouSpanAUnderB;
conditions.isSenkouSpanAOverLast = isSenkouSpanAOverLast;
conditions.isSenkouSpanAUnderLast = isSenkouSpanAUnderLast;
conditions.isFutureSenkouSpanAOverB = isFutureSenkouSpanAOverB;
conditions.isFutureSenkouSpanAUnderB = isFutureSenkouSpanAUnderB;
conditions.isFutureSenkouSpanAOverLast = isFutureSenkouSpanAOverLast;
conditions.isFutureSenkouSpanAUnderLast = isFutureSenkouSpanAUnderLast;
//
conditions.isSenkouSpanACrossedOverB = isSenkouSpanACrossedOverB;
conditions.isSenkouSpanACrossedUnderB = isSenkouSpanACrossedUnderB;
conditions.isSenkouSpanACrossedOverLast = isSenkouSpanACrossedOverLast;
conditions.isSenkouSpanACrossedUnderLast = isSenkouSpanACrossedUnderLast;
conditions.isFutureSenkouSpanACrossedOverB = isFutureSenkouSpanACrossedOverB;
conditions.isFutureSenkouSpanACrossedUnderB = isFutureSenkouSpanACrossedUnderB;
conditions.isFutureSenkouSpanACrossedOverLast = isFutureSenkouSpanACrossedOverLast;
conditions.isFutureSenkouSpanACrossedUnderLast = isFutureSenkouSpanACrossedUnderLast;
//
conditions.isMCFastOverSlow = isMCFastOverSlow;
conditions.isMCFastUnderSlow = isMCFastUnderSlow;
conditions.isMCFastOverVerifier = isMCFastOverVerifier;
conditions.isMCFastUnderVerifier = isMCFastUnderVerifier;
conditions.isMCSlowOverVerifier = isMCSlowOverVerifier;
conditions.isMCSlowUnderVerifier = isMCSlowUnderVerifier;
conditions.isMCFastCrossedOverSlow = isMCFastCrossedOverSlow;
conditions.isMCFastCrossedUnderSlow = isMCFastCrossedUnderSlow;
conditions.isMCFastCrossedOverVerifier = isMCFastCrossedOverVerifier;
conditions.isMCFastCrossedUnderVerifier = isMCFastCrossedUnderVerifier;
conditions.isMCSlowCrossedOverVerifier = isMCSlowCrossedOverVerifier;
conditions.isMCSlowCrossedUnderVerifier = isMCSlowCrossedUnderVerifier;
//
conditions.isTrendBullish = isTrendBullish;
conditions.isTrendBearish = isTrendBearish;
conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish;
conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish;
//
conditions.isZigZagInPeak = isZigZagInPeak;
conditions.isZigZagInVale = isZigZagInVale;
//
conditions.isMRBFastOverSlow = isMRBFastOverSlow;
conditions.isMRBFastUnderSlow = isMRBFastUnderSlow;
conditions.isMRBFastCrossedOverSlow = isMRBFastCrossedOverSlow;
conditions.isMRBFastCrossedUnderSlow = isMRBFastCrossedUnderSlow;
conditions.isMRBFastOverVerifier = isMRBFastOverVerifier;
conditions.isMRBFastUnderVerifier = isMRBFastUnderVerifier;
conditions.isMRBFastCrossedtOverVerifier = isMRBFastCrossedtOverVerifier;
conditions.isMRBFastCrossedUnderVerifier = isMRBFastCrossedUnderVerifier;
conditions.isMRBSlowOverVerifier = isMRBSlowOverVerifier;
conditions.isMRBSlowUnderVerifier = isMRBSlowUnderVerifier;
conditions.isMRBSlowCrossedtOverVerifier = isMRBSlowCrossedtOverVerifier;
conditions.isMRBSlowCrossedUnderVerifier = isMRBSlowCrossedUnderVerifier;
//
conditions.isCHEBullish = isCHEBullish;
conditions.isCHEBearish = isCHEBearish;
conditions.isCHESwitchedToBullish = isCHESwitchedToBullish;
conditions.isCHESwitchedToBearish = isCHESwitchedToBearish;
//
conditions.isTDBullish = isTDBullish;
conditions.isTDBearish = isTDBearish;
conditions.isTDSwitchedToBullish = isTDSwitchedToBullish;
conditions.isTDSwitchedToBearish = isTDSwitchedToBearish;
//
conditions.isDONAttachedMaxLower = isDONAttachedMaxLower;
conditions.isDONAttachedMinLower = isDONAttachedMinLower;
conditions.isDONCrossedOverMaxLower = isDONCrossedOverMaxLower;
conditions.isDONCrossedUnderMaxLower = isDONCrossedUnderMaxLower;
conditions.isDONCrossedOverMinLower = isDONCrossedOverMinLower;
conditions.isDONCrossedUnderMinLower = isDONCrossedUnderMinLower;
//
conditions.isDONAttachedMaxUpper = isDONAttachedMaxUpper;
conditions.isDONAttachedMinUpper = isDONAttachedMinUpper;
conditions.isDONCrossedOverMaxUpper = isDONCrossedOverMaxUpper;
conditions.isDONCrossedUnderMaxUpper = isDONCrossedUnderMaxUpper;
conditions.isDONCrossedOverMinUpper = isDONCrossedOverMinUpper;
conditions.isDONCrossedUnderMinUpper = isDONCrossedUnderMinUpper;
//
conditions.isNewPeak = isNewPeak;
conditions.isNewPeakOverLast = isNewPeakOverLast;
conditions.isNewPeakUnderLast = isNewPeakUnderLast;
//
conditions.isNewVale = isNewVale;
conditions.isNewValeOverLast = isNewValeOverLast;
conditions.isNewValeUnderLast = isNewValeUnderLast;
//
conditions.isFiboIncreased = isFiboIncreased;
conditions.isFiboDecreased = isFiboDecreased;
conditions.isFiboSectionChanged = isFiboSectionChanged;
//
conditions.isSCBullish = isSCBullish;
conditions.isSCHHBullish = isSCHHBullish;
conditions.isSCLLBullish = isSCLLBullish;
conditions.isSCSwitchedToBullish = isSCSwitchedToBullish;
conditions.isSCHHSwitchedToBullish = isSCHHSwitchedToBullish;
conditions.isSCLLSwitchedToBullish = isSCLLSwitchedToBullish;
//
conditions.isSCBearish = isSCBearish;
conditions.isSCHHBearish = isSCHHBearish;
conditions.isSCLLBearish = isSCLLBearish;
conditions.isSCSwitchedToBearish = isSCSwitchedToBearish;
conditions.isSCHHSwitchedToBearish = isSCHHSwitchedToBearish;
conditions.isSCLLSwitchedToBeraish = isSCLLSwitchedToBeraish;
//
conditions.isMCBullish = isMCBullish;
conditions.isMCHHBullish = isMCHHBullish;
conditions.isMCLLBullish = isMCLLBullish;
conditions.isMCSwitchedToBullish = isMCSwitchedToBullish;
conditions.isMCHHSwitchedToBullish = isMCHHSwitchedToBullish;
conditions.isMCLLSwitchedToBullish = isMCLLSwitchedToBullish;
//
conditions.isMCBearish = isMCBearish;
conditions.isMCHHBearish = isMCHHBearish;
conditions.isMCLLBearish = isMCLLBearish;
conditions.isMCSwitchedToBearish = isMCSwitchedToBearish;
conditions.isMCHHSwitchedToBearish = isMCHHSwitchedToBearish;
conditions.isMCLLSwitchedToBeraish = isMCLLSwitchedToBeraish;
//
conditions.isLCBullish = isLCBullish;
conditions.isLCHHBullish = isLCHHBullish;
conditions.isLCLLBullish = isLCLLBullish;
conditions.isLCSwitchedToBullish = isLCSwitchedToBullish;
conditions.isLCHHSwitchedToBullish = isLCHHSwitchedToBullish;
conditions.isLCLLSwitchedToBullish = isLCLLSwitchedToBullish;
//
conditions.isLCBearish = isLCBearish;
conditions.isLCHHBearish = isLCHHBearish;
conditions.isLCLLBearish = isLCLLBearish;
conditions.isLCSwitchedToBearish = isLCSwitchedToBearish;
conditions.isLCHHSwitchedToBearish = isLCHHSwitchedToBearish;
conditions.isLCLLSwitchedToBeraish = isLCLLSwitchedToBeraish;
//
conditions.isHCBullish = isHCBullish;
conditions.isHCHHBullish = isHCHHBullish;
conditions.isHCLLBullish = isHCLLBullish;
conditions.isHCSwitchedToBullish = isHCSwitchedToBullish;
conditions.isHCHHSwitchedToBullish = isHCHHSwitchedToBullish;
conditions.isHCLLSwitchedToBullish = isHCLLSwitchedToBullish;
//
conditions.isHCBearish = isHCBearish;
conditions.isHCHHBearish = isHCHHBearish;
conditions.isHCLLBearish = isHCLLBearish;
conditions.isHCSwitchedToBearish = isHCSwitchedToBearish;
conditions.isHCHHSwitchedToBearish = isHCHHSwitchedToBearish;
conditions.isHCLLSwitchedToBeraish = isHCLLSwitchedToBeraish;
}
//
// Initial Market Cycle ...
bool Init(
X121MCycleInputs &inputs // Inputs for Initialization
)
{
//
bool result = false;
//
// Validate Input ...
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
string symbol = mInputs.cycle.symbol;
ENUM_TIMEFRAMES period = mInputs.cycle.period;
//
// Init Helpers ...
//
// XASCT ...
result = asct.Init(
symbol,
period,
mInputs.asctInputs
//
);
if (!result)
{
return result;
}
//
// XHULL ...
result = hull.Init(
symbol,
period,
mInputs.hullInputs
//
);
if (!result)
{
return result;
}
//
// XSSLC ...
result = sslc.Init(
symbol,
period,
mInputs.sslcInputs
//
);
if (!result)
{
return result;
}
//
// XHK ...
result = hk.Init(
symbol,
period,
mInputs.hkInputs
//
);
if (!result)
{
return result;
}
//
// XMC ...
result = mc.Init(
symbol,
period,
mInputs.mcInputs
//
);
if (!result)
{
return result;
}
//
// XPV ...
result = pv.Init(
symbol,
period,
mInputs.pvInputs
//
);
if (!result)
{
return result;
}
//
// XZG ...
result = zg.Init(
symbol,
period,
mInputs.zgInputs
//
);
if (!result)
{
return result;
}
//
// XTD ...
result = td.Init(
symbol,
period,
mInputs.tdInputs
//
);
if (!result)
{
return result;
}
//
// XMRB ...
result = mrb.Init(
symbol,
period,
mInputs.mrbInputs
//
);
if (!result)
{
return result;
}
//
// XSTR ...
result = str.Init(
symbol,
period,
mInputs.strInputs
//
);
if (!result)
{
return result;
}
//
// XCHE ...
result = che.Init(
symbol,
period,
mInputs.cheInputs
//
);
if (!result)
{
return result;
}
//
// XOSC ...
result = osc.Init(
symbol,
period,
mInputs.oscInputs
//
);
if (!result)
{
return result;
}
//
// XICH ...
result = ich.Init(
symbol,
period,
mInputs.ichInputs
//
);
if (!result)
{
return result;
}
//
// XDON ...
result = don.Init(
symbol,
period,
mInputs.donInputs
//
);
if (!result)
{
return result;
}
//
return result;
}
//
// Draw Tools ...
//
// Completely Draw Bars ...
void Draw(
long chartID, // Chart ID ...
int subWindow, // Chart Sub Window ...
int &offset // Distance used for Labels ...
)
{
//
if (mInputs.drawCBar || mInputs.drawPBar)
{
//
DrawOHCL(
chartID,
subWindow,
mInputs.drawLabels,
!mInputs.drawCBar && mInputs.drawPBar,
!mInputs.drawPBar && mInputs.drawCBar,
offset
//
);
//
if (mInputs.drawLabels)
{
offset += 3;
}
}
//
if (mInputs.drawCBarMid || mInputs.drawPBarMid)
{
//
DrawMidLine(
chartID,
subWindow,
mInputs.drawLabels,
!mInputs.drawCBarMid && mInputs.drawPBarMid,
!mInputs.drawPBarMid && mInputs.drawCBarMid,
offset
//
);
//
if (mInputs.drawLabels)
{
//
if (mInputs.drawCBarMid)
{
offset++;
}
//
if (mInputs.drawPBarMid)
{
offset++;
}
}
}
}
//
// Draw Functions ...
//
// Draw Middle Line of Cycle ...
void DrawOHCL(
long chartID,
int subWindow,
bool drawLabel = false, // Specify Draw Label of Mid Line or not ...
bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ...
bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ...
int offset = 0 // Distance used for Labels ...
)
{
//
if (offset < 0)
{
offset = 0;
}
//
string baseTag = ToString(mInputs.cycle.cycle);
//
XOHCL cBar = GetBar(0);
XOHCL pBar = GetBar(1);
//
datetime fromCDate = GetBarTime(0);
datetime fromPDate = GetBarTime(1);
//
datetime cTime = TimeCurrent();
//
// Try to Draw ...
//
bool canDrawPrev = !drawOnlyCurrent;
bool canDrawCurrent = !drawOnlyPrev;
//
// Set Cycles Color based on Current Candle ...
//
bool isCBarBullish =
cBar.IsBullish();
//
bool isPBarBullish =
pBar.IsBearish();
//
color clrTemoBullishColor = mInputs.cBarDrawSpecs.openStyle.clr;
color clrTemoBearishColor = mInputs.cBarDrawSpecs.closeStyle.clr;
//
color cBarSelectedColor = isCBarBullish ? clrTemoBullishColor : clrTemoBearishColor;
color pBarSelectedColor = isPBarBullish ? clrTemoBullishColor : clrTemoBearishColor;
//
mInputs.cBarDrawSpecs.openStyle.clr = cBarSelectedColor;
mInputs.cBarDrawSpecs.openStyle.labelColor = cBarSelectedColor;
//
mInputs.cBarDrawSpecs.closeStyle.clr = cBarSelectedColor;
mInputs.cBarDrawSpecs.closeStyle.labelColor = cBarSelectedColor;
//
mInputs.pBarDrawSpecs.openStyle.clr = pBarSelectedColor;
mInputs.pBarDrawSpecs.openStyle.labelColor = pBarSelectedColor;
//
mInputs.pBarDrawSpecs.closeStyle.clr = pBarSelectedColor;
mInputs.pBarDrawSpecs.closeStyle.labelColor = pBarSelectedColor;
//
if (canDrawPrev)
{
offset++;
}
//
// Label ...
if (drawLabel)
{
//
if (canDrawPrev)
{
//
// Draw Prev Bar Lables ...
//
DrawXOHCLLabel(
chartID,
subWindow,
pBar,
mInputs.pBarDrawSpecs,
"P",
cTime,
offset - 1
//
);
//
offset += 3;
}
//
if (canDrawCurrent)
{
//
// Draw Current Bar Lables ...
//
DrawXOHCLLabel(
chartID,
subWindow,
cBar,
mInputs.cBarDrawSpecs,
"C",
cTime,
offset
//
);
}
}
//
// Line ...
//
if (canDrawPrev)
{
//
// Draw Cycle Prev Bar ...
DrawXOHCLContent(
chartID,
subWindow,
pBar,
mInputs.pBarDrawSpecs,
"P",
fromPDate
//
);
}
//
if (canDrawCurrent)
{
//
// Draw Cycle Current Bar ...
DrawXOHCLContent(
chartID,
subWindow,
cBar,
mInputs.cBarDrawSpecs,
"C",
fromCDate
//
);
}
}
//
// Draw Middle Line of Cycle ...
void DrawMidLine(
long chartID,
int subWindow,
bool drawLabel = false, // Specify Draw Label of Mid Line or not ...
bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ...
bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ...
int offset = 0 // Distance used for Labels ...
)
{
//
if (offset < 0)
{
offset = 0;
}
//
// Calculate Mid Line ...
XOHCL cBar = GetBar(0);
double cMidLine = cBar.GetMid();
//
XOHCL pBar = GetBar(1);
double pMidLine = pBar.GetMid();
//
string baseTag = ToString(mInputs.cycle.cycle);
//
string midCTag = baseTag + "|MID|C|";
string midPTag = baseTag + "|MID|P|";
//
string midCLblTag = midCTag + "lbl";
string midPLblTag = midPTag + "lbl";
//
datetime fromCDate = GetBarTime(0);
datetime fromPDate = GetBarTime(1);
//
datetime cTime = TimeCurrent();
//
// Try to Draw ...
//
bool canDrawPrev = !drawOnlyCurrent;
bool canDrawCurrent = !drawOnlyPrev;
//
if (canDrawPrev)
{
offset++;
}
//
// Label ...
if (drawLabel)
{
//
if (canDrawPrev)
{
//
// Draw Prev Candle MidLine Lable ...
DrawLabel(
chartID,
subWindow,
mInputs.pBarMidDrawSpecs,
midPLblTag,
cTime,
pMidLine,
offset //
);
}
//
if (canDrawCurrent)
{
//
// Draw Current Candle MidLine Label ...
DrawLabel(
chartID,
subWindow,
mInputs.cBarMidDrawSpecs,
midCLblTag,
cTime,
cMidLine,
offset - 1 //
);
}
}
//
// Line ...
//
if (canDrawPrev)
{
//
// Draw Prev Candle MidLine ...
DrawLine(
chartID,
subWindow,
mInputs.pBarMidDrawSpecs,
midPTag,
fromPDate,
pMidLine //
);
}
//
if (canDrawCurrent)
{
//
// Draw Current Candle MidLine ...
DrawLine(
chartID,
subWindow,
mInputs.cBarMidDrawSpecs,
midCTag,
fromCDate,
cMidLine //
);
}
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
//
X121MCycleInputs mInputs;
//
// Tools ...
//
bool Update(int hostBarIndex = 0)
{
return mInputs.cycle.Update(hostBarIndex);
}
//
// Draw Functions ...
//
// Draw OHCL Labels ...
void DrawXOHCLLabel(
long chartID,
int subWindow,
XOHCL &bar, // Specify Cycle XOHCL Model to Draw ...
XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ...
string baseTag, // Specify a Unique Tag ...
datetime time, // Draw Time ...
int offset = 0 //
)
{
//
// Open ...
string openTag = mInputs.cycle.prefix + "_" + baseTag + "_O_lbl";
DrawLabel(
chartID,
subWindow,
specs.openStyle,
openTag,
time,
bar.open,
offset
//
);
//
// High ...
string highTag = mInputs.cycle.prefix + "_" + baseTag + "_H_lbl";
DrawLabel(
chartID,
subWindow,
specs.highStyle,
highTag,
time,
bar.high,
offset + 1
//
);
//
// Close ...
string closeTag = mInputs.cycle.prefix + "_" + baseTag + "_C_lbl";
DrawLabel(
chartID,
subWindow,
specs.closeStyle,
closeTag,
time,
bar.close,
offset + 2
//
);
//
// Low ...
string lowTag = mInputs.cycle.prefix + "_" + baseTag + "_L_lbl";
DrawLabel(
chartID,
subWindow,
specs.lowStyle,
lowTag,
time,
bar.low,
offset + 3
//
);
}
//
// Draw XOHCL Content ...
void DrawXOHCLContent(
long chartID,
int subWindow,
XOHCL &bar, // Specify Cycle XOHCL Model to Draw ...
XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ...
string baseTag, // Specify a Unique Tag ...
datetime time // Draw Time ...
)
{
//
// Open ...
string openTag = mInputs.cycle.prefix + "_" + baseTag + "_O";
DrawLine(
chartID,
subWindow,
specs.openStyle,
openTag,
time,
bar.open
//
);
//
// High ...
string highTag = mInputs.cycle.prefix + "_" + baseTag + "_H";
DrawLine(
chartID,
subWindow,
specs.highStyle,
highTag,
time,
bar.high
//
);
//
// Close ...
string closeTag = mInputs.cycle.prefix + "_" + baseTag + "_C";
DrawLine(
chartID,
subWindow,
specs.closeStyle,
closeTag,
time,
bar.close
//
);
//
// Low ...
string lowTag = mInputs.cycle.prefix + "_" + baseTag + "_L";
DrawLine(
chartID,
subWindow,
specs.lowStyle,
lowTag,
time,
bar.low
//
);
}
//
// Draw Label Using Specifications ...
void DrawLabel(
long chartID,
int subWindow,
XDrawSpecifications &specs,
string tag,
datetime time,
double price,
int offset = 0 //
)
{
//
if (offset < 0)
{
offset = 0;
}
//
int offsetSeconds = PeriodSeconds(mInputs.cycle.hostPeriod) * offset;
//
string value = specs.label;
//
DrawText(
chartID,
tag,
subWindow,
time - offsetSeconds,
price,
specs.label,
specs.labelFont,
specs.labelFontSize,
specs.labelColor,
specs.labelAngel,
specs.labelAnchor,
specs.back,
specs.selection,
specs.hidden,
specs.zOrder //
);
}
//
// Draw TrendLine Using Specifications ...
void DrawLine(
long chartID,
int subWindow,
XDrawSpecifications &specs,
string tag,
datetime fromDate,
double fromPrice,
datetime toDate = NULL,
double toPrice = 0 //
)
{
//
if (toPrice <= 0)
{
toPrice = fromPrice;
}
//
if (toDate == 0 || toDate == NULL)
{
toDate = TimeCurrent();
}
//
DrawTrendLine(
chartID,
tag,
subWindow,
fromDate,
fromPrice,
toDate,
toPrice,
specs.clr,
specs.style,
specs.width,
specs.back,
specs.selection,
specs.rayRight,
specs.hidden,
specs.zOrder //
);
}
};
//
// Tools ...
//
struct X121MarketCycleDescriptor
{
//
string symbol; // Trading Symbol
ENUM_TIMEFRAMES hostPeriod; // Host Period
ENUM_X_MARKET_CYCLES cycle; // Init Cycle
ENUM_TIMEFRAMES period; // Cycle Period
ENUM_X_PERIOD_METHOD periodMethod; // Cycle Period Method
string prefix; // Prefix
bool useDefaults; // Use Inputs Default Settings ...
//
X121MCycleInputs inputs; // Inputs
//
XSCX121Market *market; // Market
//
// Tools ...
//
bool Init()
{
//
bool result = false;
//
result = inputs.Init(
symbol,
hostPeriod,
cycle,
period,
periodMethod,
prefix,
useDefaults //
);
if (!result)
{
return result;
}
//
//
// Instantiate Market ...
market = new XSCX121Market();
//
// Initialize Market ...
result = market.Init(inputs);
//
return result;
}
//
bool Init(
string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mHostPeriod, // Host Period
ENUM_X_MARKET_CYCLES mCycle, // Init Cycle
ENUM_TIMEFRAMES mPeriod, // Cycle Period
ENUM_X_PERIOD_METHOD mPeriodMethod, // Cycle Period Method
string mPrefix = "", // Prefix
bool mUseDefaults = true // Use Inputs Default Settings ...
)
{
//
bool result = false;
//
result =
//
IsValid(mSymbol) &&
IsValid(mHostPeriod) &&
IsValid(mPeriodMethod, mPeriod)
//
;
if (!result)
{
return result;
}
//
this.cycle = mCycle;
this.symbol = mSymbol;
this.period = mPeriod;
this.prefix = mPrefix;
this.hostPeriod = mHostPeriod;
this.useDefaults = mUseDefaults;
this.periodMethod = mPeriodMethod;
//
result = this.Init();
//
return result;
}
};
//
// Custom Draws ...
//
// Custom Struct Draws ...
bool DrawSupRes(
XOHCLSupRes &item, // Struct item to Draw ...
XDrawSpecifications &supSpecs, // Supports specs ...
XDrawSpecifications &resSpecs, // Resistances specs ...
long chartID = 0,
int subWindow = 0,
string prefix = "SupRes" //
)
{
//
bool result = false;
//
result = item.IsValid();
if (!result)
{
return result;
}
//
datetime cTime = TimeCurrent();
datetime pTime = TimeCurrent() - PeriodSeconds(PERIOD_M10);
//
// Support ...
int supCount = item.CountSupports();
bool canDrawSups = IsValidSize(supCount) && supSpecs.draw;
if (canDrawSups)
{
//
for (int i = 0; i < supCount; i++)
{
//
double iSup = item.sup[i];
//
string supName = prefix + "_" + "Sup_" + ToString(iSup);
//
DrawTrendLine(
chartID,
supName,
subWindow,
pTime,
iSup,
cTime,
iSup,
supSpecs.clr,
supSpecs.style,
supSpecs.width,
supSpecs.back,
supSpecs.selection,
supSpecs.rayRight,
supSpecs.hidden,
supSpecs.zOrder //
);
//
if (IsValid(supSpecs.label))
{
//
DrawText(
chartID,
supName + "_lbl",
subWindow,
cTime,
iSup,
supSpecs.label,
supSpecs.labelFont,
supSpecs.labelFontSize,
supSpecs.labelColor,
supSpecs.labelAngel,
supSpecs.labelAnchor,
supSpecs.back,
supSpecs.selection,
supSpecs.hidden,
supSpecs.zOrder //
);
}
}
}
//
// Resistance ...
int resCount = item.CountResistances();
bool canDrawRess = IsValidSize(supCount) && supSpecs.draw;
if (canDrawRess)
{
//
for (int i = 0; i < resCount; i++)
{
//
double iRes = item.res[i];
//
string resName = prefix + "_" + "Res_" + ToString(iRes);
//
DrawTrendLine(
chartID,
resName,
subWindow,
pTime,
iRes,
cTime,
iRes,
resSpecs.clr,
resSpecs.style,
resSpecs.width,
resSpecs.back,
resSpecs.selection,
resSpecs.rayRight,
resSpecs.hidden,
resSpecs.zOrder //
);
//
if (IsValid(resSpecs.label))
{
//
DrawText(
chartID,
resName + "_lbl",
subWindow,
cTime,
iRes,
resSpecs.label,
resSpecs.labelFont,
resSpecs.labelFontSize,
resSpecs.labelColor,
resSpecs.labelAngel,
resSpecs.labelAnchor,
resSpecs.back,
resSpecs.selection,
resSpecs.hidden,
resSpecs.zOrder //
);
}
}
}
//
result = canDrawSups || canDrawRess;
//
return result;
}
//