1075 lines
25 KiB
Plaintext
1075 lines
25 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCXTRNDHelper
|
|
// Description: provides all Indicator
|
|
// Helper requirements ...
|
|
//
|
|
//
|
|
// 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
|
|
|
|
//
|
|
// START Definitions ...
|
|
//
|
|
|
|
//
|
|
// XPERIOD Calculation Method ...
|
|
// USED For Multiple Time Frames ...
|
|
enum ENUM_X_PERIOD_METHOD
|
|
{
|
|
//
|
|
X_PERIOD_NOTHING,
|
|
//
|
|
X_PERIOD_AUTO,
|
|
//
|
|
X_PERIOD_MANUALLY
|
|
};
|
|
|
|
//
|
|
// Inputs ...
|
|
struct XTRNDInputs
|
|
{
|
|
//
|
|
// Makret ...
|
|
int cycleLength; // Cycle Length to Check
|
|
int numberOfVerifications; // Number of Verifications
|
|
|
|
//
|
|
// Calculation ...
|
|
ENUM_SERIESMODE hhMode; // Detect Up
|
|
ENUM_SERIESMODE llMode; // Detect Low
|
|
|
|
//
|
|
// Cycles ...
|
|
|
|
//
|
|
// Level 1 ...
|
|
ENUM_X_PERIOD_METHOD l1Method; // How to Find Period
|
|
ENUM_TIMEFRAMES l1Period; // Time Period
|
|
|
|
//
|
|
// Level 2 ...
|
|
ENUM_X_PERIOD_METHOD l2Method; // How to Find Period
|
|
ENUM_TIMEFRAMES l2Period; // Time Period
|
|
|
|
//
|
|
// Level 3 ...
|
|
ENUM_X_PERIOD_METHOD l3Method; // How to Find Period
|
|
ENUM_TIMEFRAMES l3Period; // Time Period
|
|
|
|
//
|
|
// Presentation ...
|
|
bool showConsolidations; // Show Consolidations
|
|
bool showTrend; // Show Trend
|
|
bool showL1Trend; // Show Cycle 1 Trend
|
|
bool showL2Trend; // Show Cycle 2 Trend
|
|
bool showL3Trend; // Show Cycle 3 Trend
|
|
};
|
|
|
|
//
|
|
// Index of Lines ...
|
|
enum ENUM_XTRND_BUFFERS
|
|
{
|
|
//
|
|
// Main Requirements ...
|
|
XTRND_UP_LINE = 0,
|
|
XTRND_UP_STATE_LINE = 16,
|
|
XTRND_DOWN_LINE = 2,
|
|
XTRND_DOWN_STATE_LINE = 17,
|
|
//
|
|
// LEVEL 1 ...
|
|
XTRND_L1_UP_LINE = 4,
|
|
XTRND_L1_UP_STATE_LINE = 18,
|
|
XTRND_L1_DOWN_LINE = 6,
|
|
XTRND_L1_DOWN_STATE_LINE = 19,
|
|
//
|
|
// LEVEL 2 ...
|
|
XTRND_L2_UP_LINE = 8,
|
|
XTRND_L2_UP_STATE_LINE = 20,
|
|
XTRND_L2_DOWN_LINE = 10,
|
|
XTRND_L2_DOWN_STATE_LINE = 21,
|
|
//
|
|
// LEVEL 3 ...
|
|
XTRND_L3_UP_LINE = 12,
|
|
XTRND_L3_UP_STATE_LINE = 22,
|
|
XTRND_L3_DOWN_LINE = 14,
|
|
XTRND_L3_DOWN_STATE_LINE = 23,
|
|
};
|
|
|
|
//
|
|
enum ENUM_XTRND_STATES
|
|
{
|
|
XTRND_STATE_BULLISH = 1,
|
|
XTRND_STATE_BEARISH = 2,
|
|
XTRND_STATE_CONSOLIDATION = 0,
|
|
};
|
|
|
|
//
|
|
// Retrieve Info Model ...
|
|
struct XTRNDInfo
|
|
{
|
|
//
|
|
// Symbol ...
|
|
string symbol;
|
|
|
|
//
|
|
// Period ...
|
|
ENUM_TIMEFRAMES period;
|
|
|
|
//
|
|
// Bar Time ...
|
|
datetime barTime;
|
|
|
|
//
|
|
// Bar Index ...
|
|
int barIndex;
|
|
|
|
//
|
|
// Values ...
|
|
double hh;
|
|
ENUM_XTRND_STATES hhState;
|
|
double ll;
|
|
double llState;
|
|
double l1hh;
|
|
ENUM_XTRND_STATES l1hhState;
|
|
double l1ll;
|
|
ENUM_XTRND_STATES l1llState;
|
|
double l2hh;
|
|
ENUM_XTRND_STATES l2hhState;
|
|
double l2ll;
|
|
ENUM_XTRND_STATES l2llState;
|
|
double l3hh;
|
|
ENUM_XTRND_STATES l3hhState;
|
|
double l3ll;
|
|
ENUM_XTRND_STATES l3llState;
|
|
|
|
//
|
|
// Conditions ...
|
|
//
|
|
bool isTrendBullish;
|
|
bool isTrendSwitchedToBullish;
|
|
bool isTrendBearish;
|
|
bool isTrendSwitchedToBearish;
|
|
bool isTrendConsolidation;
|
|
bool isTrendSwitchedToConsolidation;
|
|
|
|
//
|
|
bool isL1TrendBullish;
|
|
bool isL1TrendSwitchedToBullish;
|
|
bool isL1TrendBearish;
|
|
bool isL1TrendSwitchedToBearish;
|
|
bool isL1TrendConsolidation;
|
|
bool isL1TrendSwitchedToConsolidation;
|
|
|
|
//
|
|
bool isL2TrendBullish;
|
|
bool isL2TrendSwitchedToBullish;
|
|
bool isL2TrendBearish;
|
|
bool isL2TrendSwitchedToBearish;
|
|
bool isL2TrendConsolidation;
|
|
bool isL2TrendSwitchedToConsolidation;
|
|
|
|
//
|
|
bool isL3TrendBullish;
|
|
bool isL3TrendSwitchedToBullish;
|
|
bool isL3TrendBearish;
|
|
bool isL3TrendSwitchedToBearish;
|
|
bool isL3TrendConsolidation;
|
|
bool isL3TrendSwitchedToConsolidation;
|
|
};
|
|
|
|
//
|
|
// END Definitions ...
|
|
//
|
|
|
|
//
|
|
// START Import and Inclused requirements ...
|
|
//
|
|
|
|
//
|
|
// Includes ...
|
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
|
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
|
|
|
//
|
|
// END Import and Inclused requirements ...
|
|
//
|
|
|
|
//
|
|
// START Overrides ...
|
|
//
|
|
|
|
//
|
|
// END Overrides ...
|
|
//
|
|
|
|
//
|
|
// a Class for Helping Indicators Requirements ...
|
|
class XSCXTRNDHelper : public XSCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Buffers ...
|
|
double hhBuffer[];
|
|
double hhStateBuffer[];
|
|
double llBuffer[];
|
|
double llStateBuffer[];
|
|
double l1hhBuffer[];
|
|
double l1hhStateBuffer[];
|
|
double l1llBuffer[];
|
|
double l1llStateBuffer[];
|
|
double l2hhBuffer[];
|
|
double l2hhStateBuffer[];
|
|
double l2llBuffer[];
|
|
double l2llStateBuffer[];
|
|
double l3hhBuffer[];
|
|
double l3hhStateBuffer[];
|
|
double l3llBuffer[];
|
|
double l3llStateBuffer[];
|
|
|
|
//
|
|
// Constructor ...
|
|
void XSCXTRNDHelper(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period // Trading Time Frame
|
|
) : XSCBaseHelper(symbol, period)
|
|
{
|
|
PrepareTag();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XSCXTRNDHelper()
|
|
{
|
|
}
|
|
|
|
//
|
|
// START Properties ...
|
|
//
|
|
|
|
//
|
|
// Show Trend ...
|
|
bool ShowTrend(
|
|
bool show // Show or Hide
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mShowTrend == show)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//
|
|
mShowTrend = show;
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Show Cycle 1 Trend ...
|
|
bool ShowL1Trends(
|
|
bool show // Show or Hide
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mShowL1Trends == show)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//
|
|
mShowL1Trends = show;
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Show Cycle 2 Trend ...
|
|
bool ShowL2Trends(
|
|
bool show // Show or Hide
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mShowL2Trends == show)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//
|
|
mShowL2Trends = show;
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Show Cycle 3 Trend ...
|
|
bool ShowL3Trends(
|
|
bool show // Show or Hide
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mShowL3Trends == show)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//
|
|
mShowL3Trends = show;
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Properties ...
|
|
//
|
|
|
|
//
|
|
// START Provided Functions ...
|
|
//
|
|
|
|
//
|
|
// Prepare Tag ...
|
|
virtual void PrepareTag()
|
|
{
|
|
mTag = "XTRND" + GetTagPrefix();
|
|
}
|
|
|
|
//
|
|
virtual int GetMaxLength()
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
result = MathMax(
|
|
mCycleLength,
|
|
mNumberOfVerifications);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initial Indicator Handler ...
|
|
bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Inputs ...
|
|
//
|
|
//
|
|
result =
|
|
//
|
|
(mCycleLength > 0 &&
|
|
mNumberOfVerifications > 0)
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initialize Handler ...
|
|
mHandler = iCustom(
|
|
//
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.x121.xtrnd",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// Market ...
|
|
"",
|
|
//
|
|
// Cycle Length to Check ...
|
|
mCycleLength,
|
|
//
|
|
// Number of Verifications ...
|
|
mNumberOfVerifications,
|
|
//
|
|
// Calculations ...
|
|
"",
|
|
//
|
|
// Detect Up ...
|
|
mHHMode,
|
|
//
|
|
// Detect Low ...
|
|
mLLMode,
|
|
//
|
|
// Cycles ...
|
|
"",
|
|
//
|
|
// LEVEL 1 ...
|
|
"",
|
|
//
|
|
// How to Find Period ...
|
|
mLLMethod,
|
|
//
|
|
// Time Period ...
|
|
mL1Period,
|
|
//
|
|
// LEVEL 2 ...
|
|
"",
|
|
//
|
|
// How to Find Period ...
|
|
mL2Method,
|
|
//
|
|
// Time Period ...
|
|
mL2Period,
|
|
//
|
|
// LEVEL 3 ...
|
|
"",
|
|
//
|
|
// How to Find Period ...
|
|
mL3Method,
|
|
//
|
|
// Time Period ...
|
|
mL3Period,
|
|
//
|
|
// Presentation ...
|
|
"",
|
|
//
|
|
// Show Consolidations ...
|
|
mShowConsolidations,
|
|
//
|
|
// Show Trend ...
|
|
mShowTrend,
|
|
//
|
|
// Show Cycle 1 Trend ...
|
|
mShowL1Trends,
|
|
//
|
|
// Show Cycle 2 Trend ...
|
|
mShowL2Trends,
|
|
//
|
|
// Show Cycle 3 Trend ...
|
|
mShowL3Trends
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve Current Config ...
|
|
XTRNDInputs GetConfig()
|
|
{
|
|
//
|
|
XTRNDInputs result;
|
|
|
|
//
|
|
result.cycleLength = mCycleLength;
|
|
result.numberOfVerifications = mNumberOfVerifications;
|
|
result.hhMode = mHHMode;
|
|
result.llMode = mLLMode;
|
|
result.l1Method = mLLMethod;
|
|
result.l1Period = mL1Period;
|
|
result.l2Method = mL2Method;
|
|
result.l2Period = mL2Period;
|
|
result.l3Method = mL3Method;
|
|
result.l3Period = mL3Period;
|
|
result.showConsolidations = mShowConsolidations;
|
|
result.showTrend = mShowTrend;
|
|
result.showL1Trend = mShowL1Trends;
|
|
result.showL2Trend = mShowL2Trends;
|
|
result.showL3Trend = mShowL3Trends;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Config ...
|
|
bool SetConfig(XTRNDInputs &config)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mCycleLength = config.cycleLength;
|
|
mNumberOfVerifications = config.numberOfVerifications;
|
|
mHHMode = config.hhMode;
|
|
mLLMode = config.llMode;
|
|
mLLMethod = config.l1Method;
|
|
mL1Period = config.l1Period;
|
|
mL2Method = config.l2Method;
|
|
mL2Period = config.l2Period;
|
|
mL3Method = config.l3Method;
|
|
mL3Period = config.l3Period;
|
|
mShowConsolidations = config.showConsolidations;
|
|
mShowTrend = config.showTrend;
|
|
mShowL1Trends = config.showL1Trend;
|
|
mShowL2Trends = config.showL2Trend;
|
|
mShowL3Trends = config.showL3Trend;
|
|
|
|
//
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Reading Buffers based on Given Bar Index ...
|
|
virtual void Calculate(
|
|
int barIndex // Given Bar Index
|
|
)
|
|
{
|
|
//
|
|
// HH ...
|
|
ArraySetAsSeries(hhBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_UP_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
hhBuffer);
|
|
|
|
//
|
|
// HH State ...
|
|
ArraySetAsSeries(hhStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_UP_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
hhStateBuffer);
|
|
|
|
//
|
|
// LL ...
|
|
ArraySetAsSeries(llBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_DOWN_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
llBuffer);
|
|
|
|
//
|
|
// LL State ...
|
|
ArraySetAsSeries(llStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_DOWN_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
llStateBuffer);
|
|
|
|
//
|
|
// CYCLES ...
|
|
|
|
//
|
|
// LEVEL 1 ...
|
|
|
|
//
|
|
// HH ...
|
|
ArraySetAsSeries(l1hhBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L1_UP_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l1hhBuffer);
|
|
|
|
//
|
|
// HH State ...
|
|
ArraySetAsSeries(l1hhStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L1_UP_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l1hhStateBuffer);
|
|
|
|
//
|
|
// LL ...
|
|
ArraySetAsSeries(l1llBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L1_DOWN_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l1llBuffer);
|
|
|
|
//
|
|
// LL State ...
|
|
ArraySetAsSeries(l1llStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L1_DOWN_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l1llStateBuffer);
|
|
|
|
//
|
|
// LEVEL 2 ...
|
|
|
|
//
|
|
// HH ...
|
|
ArraySetAsSeries(l2hhBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L2_UP_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l2hhBuffer);
|
|
|
|
//
|
|
// HH State ...
|
|
ArraySetAsSeries(l2hhStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L2_UP_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l2hhStateBuffer);
|
|
|
|
//
|
|
// LL ...
|
|
ArraySetAsSeries(l2llBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L2_DOWN_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l2llBuffer);
|
|
|
|
//
|
|
// LL State ...
|
|
ArraySetAsSeries(l2llStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L2_DOWN_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l2llStateBuffer);
|
|
|
|
//
|
|
// LEVEL 3 ...
|
|
|
|
//
|
|
// HH ...
|
|
ArraySetAsSeries(l3hhBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L3_UP_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l3hhBuffer);
|
|
|
|
//
|
|
// HH State ...
|
|
ArraySetAsSeries(l3hhStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L3_UP_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l3hhStateBuffer);
|
|
|
|
//
|
|
// LL ...
|
|
ArraySetAsSeries(l3llBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L3_DOWN_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l3llBuffer);
|
|
|
|
//
|
|
// LL State ...
|
|
ArraySetAsSeries(l3llStateBuffer, true);
|
|
CopyBuffer(
|
|
mHandler,
|
|
XTRND_L3_DOWN_STATE_LINE,
|
|
barIndex,
|
|
mLoopbackBars,
|
|
l3llStateBuffer);
|
|
}
|
|
|
|
//
|
|
// Retrieve Info at Specific Bar Index ...
|
|
XTRNDInfo GetInfo(
|
|
int barIndex // Given Bar Index
|
|
)
|
|
{
|
|
//
|
|
XTRNDInfo result;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
barIndex--;
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
// Do Calculations ...
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
// Generate Candle Time ...
|
|
datetime barTime = GetCandleTime(
|
|
mSymbol,
|
|
mPeriod,
|
|
barIndex);
|
|
|
|
//
|
|
// Fill Result ...
|
|
result.symbol = mSymbol;
|
|
result.period = mPeriod;
|
|
result.barTime = barTime;
|
|
result.barIndex = barIndex;
|
|
|
|
//
|
|
double hh = hhBuffer[barIndex];
|
|
ENUM_XTRND_STATES hhState = (ENUM_XTRND_STATES)hhStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES hhStatePrev = (ENUM_XTRND_STATES)hhStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double ll = llBuffer[barIndex];
|
|
ENUM_XTRND_STATES llState = (ENUM_XTRND_STATES)llStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES llStatePrev = (ENUM_XTRND_STATES)llStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l1hh = l1hhBuffer[barIndex];
|
|
ENUM_XTRND_STATES l1hhState = (ENUM_XTRND_STATES)l1hhStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l1hhStatePrev = (ENUM_XTRND_STATES)l1hhStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l1ll = l1llBuffer[barIndex];
|
|
ENUM_XTRND_STATES l1llState = (ENUM_XTRND_STATES)l1llStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l1llStatePrev = (ENUM_XTRND_STATES)l1llStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l2hh = l2hhBuffer[barIndex];
|
|
ENUM_XTRND_STATES l2hhState = (ENUM_XTRND_STATES)l2hhStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l2hhStatePrev = (ENUM_XTRND_STATES)l2hhStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l2ll = l2llBuffer[barIndex];
|
|
ENUM_XTRND_STATES l2llState = (ENUM_XTRND_STATES)l2llStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l2llStatePrev = (ENUM_XTRND_STATES)l2llStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l3hh = l3hhBuffer[barIndex];
|
|
ENUM_XTRND_STATES l3hhState = (ENUM_XTRND_STATES)l3hhStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l3hhStatePrev = (ENUM_XTRND_STATES)l3hhStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
double l3ll = l3llBuffer[barIndex];
|
|
ENUM_XTRND_STATES l3llState = (ENUM_XTRND_STATES)l3llStateBuffer[barIndex];
|
|
ENUM_XTRND_STATES l3llStatePrev = (ENUM_XTRND_STATES)l3llStateBuffer[barIndex + 1];
|
|
|
|
//
|
|
bool isTrendBullish =
|
|
hhState == XTRND_STATE_BULLISH &&
|
|
llState == XTRND_STATE_BULLISH;
|
|
bool isPrevTrendBullish =
|
|
hhStatePrev == XTRND_STATE_BULLISH &&
|
|
llStatePrev == XTRND_STATE_BULLISH;
|
|
bool isTrendBearish =
|
|
hhState == XTRND_STATE_BEARISH &&
|
|
llState == XTRND_STATE_BEARISH;
|
|
bool isPrevTrendBearish =
|
|
hhStatePrev == XTRND_STATE_BEARISH &&
|
|
llStatePrev == XTRND_STATE_BEARISH;
|
|
bool isTrendConsolidation =
|
|
hhState == XTRND_STATE_CONSOLIDATION &&
|
|
llState == XTRND_STATE_CONSOLIDATION;
|
|
bool isPrevTrendConsolidation =
|
|
hhStatePrev == XTRND_STATE_CONSOLIDATION &&
|
|
llStatePrev == XTRND_STATE_CONSOLIDATION;
|
|
|
|
//
|
|
bool isTrendSwitchedToBullish =
|
|
isTrendBullish &&
|
|
!isPrevTrendBullish;
|
|
bool isTrendSwitchedToBearish =
|
|
isTrendBearish &&
|
|
!isPrevTrendBearish;
|
|
bool isTrendSwitchedToConsolidation =
|
|
isTrendConsolidation &&
|
|
!isPrevTrendConsolidation;
|
|
|
|
//
|
|
bool isL1TrendBullish =
|
|
l1hhState == XTRND_STATE_BULLISH &&
|
|
l1llState == XTRND_STATE_BULLISH;
|
|
bool isL1PrevTrendBullish =
|
|
l1hhStatePrev == XTRND_STATE_BULLISH &&
|
|
l1llStatePrev == XTRND_STATE_BULLISH;
|
|
bool isL1TrendBearish =
|
|
l1hhState == XTRND_STATE_BEARISH &&
|
|
l1llState == XTRND_STATE_BEARISH;
|
|
bool isL1PrevTrendBearish =
|
|
l1hhStatePrev == XTRND_STATE_BEARISH &&
|
|
l1llStatePrev == XTRND_STATE_BEARISH;
|
|
bool isL1TrendConsolidation =
|
|
l1hhState == XTRND_STATE_CONSOLIDATION &&
|
|
l1llState == XTRND_STATE_CONSOLIDATION;
|
|
bool isL1PrevTrendConsolidation =
|
|
l1hhStatePrev == XTRND_STATE_CONSOLIDATION &&
|
|
l1llStatePrev == XTRND_STATE_CONSOLIDATION;
|
|
|
|
//
|
|
bool isL1TrendSwitchedToBullish =
|
|
isL1TrendBullish &&
|
|
!isL1PrevTrendBullish;
|
|
bool isL1TrendSwitchedToBearish =
|
|
isL1TrendBearish &&
|
|
!isL1PrevTrendBearish;
|
|
bool isL1TrendSwitchedToConsolidation =
|
|
isL1TrendConsolidation &&
|
|
!isL1PrevTrendConsolidation;
|
|
|
|
//
|
|
bool isL2TrendBullish =
|
|
l2hhState == XTRND_STATE_BULLISH &&
|
|
l2llState == XTRND_STATE_BULLISH;
|
|
bool isL2PrevTrendBullish =
|
|
l2hhStatePrev == XTRND_STATE_BULLISH &&
|
|
l2llStatePrev == XTRND_STATE_BULLISH;
|
|
bool isL2TrendBearish =
|
|
l2hhState == XTRND_STATE_BEARISH &&
|
|
l2llState == XTRND_STATE_BEARISH;
|
|
bool isL2PrevTrendBearish =
|
|
l2hhStatePrev == XTRND_STATE_BEARISH &&
|
|
l2llStatePrev == XTRND_STATE_BEARISH;
|
|
bool isL2TrendConsolidation =
|
|
l2hhState == XTRND_STATE_CONSOLIDATION &&
|
|
l2llState == XTRND_STATE_CONSOLIDATION;
|
|
bool isL2PrevTrendConsolidation =
|
|
l2hhStatePrev == XTRND_STATE_CONSOLIDATION &&
|
|
l2llStatePrev == XTRND_STATE_CONSOLIDATION;
|
|
|
|
//
|
|
bool isL2TrendSwitchedToBullish =
|
|
isL2TrendBullish &&
|
|
!isL2PrevTrendBullish;
|
|
bool isL2TrendSwitchedToBearish =
|
|
isL2TrendBearish &&
|
|
!isL2PrevTrendBearish;
|
|
bool isL2TrendSwitchedToConsolidation =
|
|
isL2TrendConsolidation &&
|
|
!isL2PrevTrendConsolidation;
|
|
|
|
//
|
|
bool isL3TrendBullish =
|
|
l3hhState == XTRND_STATE_BULLISH &&
|
|
l3llState == XTRND_STATE_BULLISH;
|
|
bool isL3PrevTrendBullish =
|
|
l3hhStatePrev == XTRND_STATE_BULLISH &&
|
|
l3llStatePrev == XTRND_STATE_BULLISH;
|
|
bool isL3TrendBearish =
|
|
l3hhState == XTRND_STATE_BEARISH &&
|
|
l3llState == XTRND_STATE_BEARISH;
|
|
bool isL3PrevTrendBearish =
|
|
l3hhStatePrev == XTRND_STATE_BEARISH &&
|
|
l3llStatePrev == XTRND_STATE_BEARISH;
|
|
bool isL3TrendConsolidation =
|
|
l3hhState == XTRND_STATE_CONSOLIDATION &&
|
|
l3llState == XTRND_STATE_CONSOLIDATION;
|
|
bool isL3PrevTrendConsolidation =
|
|
l3hhStatePrev == XTRND_STATE_CONSOLIDATION &&
|
|
l3llStatePrev == XTRND_STATE_CONSOLIDATION;
|
|
|
|
//
|
|
bool isL3TrendSwitchedToBullish =
|
|
isL3TrendBullish &&
|
|
!isL3PrevTrendBullish;
|
|
bool isL3TrendSwitchedToBearish =
|
|
isL3TrendBearish &&
|
|
!isL3PrevTrendBearish;
|
|
bool isL3TrendSwitchedToConsolidation =
|
|
isL3TrendConsolidation &&
|
|
!isL3PrevTrendConsolidation;
|
|
|
|
//
|
|
result.hh = hh;
|
|
result.hhState = hhState;
|
|
result.ll = ll;
|
|
result.llState = llState;
|
|
result.l1hh = l1hh;
|
|
result.l1hhState = l1hhState;
|
|
result.l1ll = l1ll;
|
|
result.l1llState = l1llState;
|
|
result.l2hh = l2hh;
|
|
result.l2hhState = l2hhState;
|
|
result.l2ll = l2ll;
|
|
result.l2llState = l2llState;
|
|
result.l3hh = l3hh;
|
|
result.l3hhState = l3hhState;
|
|
result.l3ll = l3ll;
|
|
result.l3llState = l3llState;
|
|
|
|
//
|
|
result.isTrendBullish = isTrendBullish;
|
|
result.isTrendBearish = isTrendBearish;
|
|
result.isTrendConsolidation = isTrendConsolidation;
|
|
|
|
//
|
|
result.isTrendSwitchedToBullish = isTrendSwitchedToBullish;
|
|
result.isTrendSwitchedToBearish = isTrendSwitchedToBearish;
|
|
result.isTrendSwitchedToConsolidation = isTrendSwitchedToConsolidation;
|
|
|
|
//
|
|
result.isL1TrendBullish = isL1TrendBullish;
|
|
result.isL1TrendBearish = isL1TrendBearish;
|
|
result.isL1TrendConsolidation = isL1TrendConsolidation;
|
|
|
|
//
|
|
result.isL1TrendSwitchedToBullish = isL1TrendSwitchedToBullish;
|
|
result.isL1TrendSwitchedToBearish = isL1TrendSwitchedToBearish;
|
|
result.isL1TrendSwitchedToConsolidation = isL1TrendSwitchedToConsolidation;
|
|
|
|
//
|
|
result.isL2TrendBullish = isL2TrendBullish;
|
|
result.isL2TrendBearish = isL2TrendBearish;
|
|
result.isL2TrendConsolidation = isL2TrendConsolidation;
|
|
|
|
//
|
|
result.isL2TrendSwitchedToBullish = isL2TrendSwitchedToBullish;
|
|
result.isL2TrendSwitchedToBearish = isL2TrendSwitchedToBearish;
|
|
result.isL2TrendSwitchedToConsolidation = isL2TrendSwitchedToConsolidation;
|
|
|
|
//
|
|
result.isL3TrendBullish = isL3TrendBullish;
|
|
result.isL3TrendBearish = isL3TrendBearish;
|
|
result.isL3TrendConsolidation = isL3TrendConsolidation;
|
|
|
|
//
|
|
result.isL3TrendSwitchedToBullish = isL3TrendSwitchedToBullish;
|
|
result.isL3TrendSwitchedToBearish = isL3TrendSwitchedToBearish;
|
|
result.isL3TrendSwitchedToConsolidation = isL3TrendSwitchedToConsolidation;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Provided Functions ...
|
|
//
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Indicator Properties ...
|
|
//
|
|
// Market ...
|
|
//
|
|
// Cycle Length to Check ...
|
|
int mCycleLength;
|
|
//
|
|
// Number of Verifications ...
|
|
int mNumberOfVerifications;
|
|
//
|
|
// Calculations ...
|
|
//
|
|
// Detect Up ...
|
|
ENUM_SERIESMODE mHHMode;
|
|
//
|
|
// Detect Low ...
|
|
ENUM_SERIESMODE mLLMode;
|
|
//
|
|
// Cycles ...
|
|
//
|
|
// LEVEL 1 ...
|
|
//
|
|
// How to Find Period ...
|
|
ENUM_X_PERIOD_METHOD mLLMethod;
|
|
//
|
|
// Time Period ...
|
|
ENUM_TIMEFRAMES mL1Period;
|
|
//
|
|
// LEVEL 2 ...
|
|
//
|
|
// How to Find Period ...
|
|
ENUM_X_PERIOD_METHOD mL2Method;
|
|
//
|
|
// Time Period ...
|
|
ENUM_TIMEFRAMES mL2Period;
|
|
//
|
|
// LEVEL 3 ...
|
|
//
|
|
// How to Find Period ...
|
|
ENUM_X_PERIOD_METHOD mL3Method;
|
|
//
|
|
// Time Period ...
|
|
ENUM_TIMEFRAMES mL3Period;
|
|
//
|
|
// Presentation ...
|
|
//
|
|
// Show Consolidations ...
|
|
bool mShowConsolidations;
|
|
//
|
|
// Show Trend ...
|
|
bool mShowTrend;
|
|
//
|
|
// Show Cycle 1 Trend ...
|
|
bool mShowL1Trends;
|
|
//
|
|
// Show Cycle 2 Trend ...
|
|
bool mShowL2Trends;
|
|
//
|
|
// Show Cycle 3 Trend ...
|
|
bool mShowL3Trends;
|
|
};
|
|
|
|
//
|
|
// START Usefull Functions ...
|
|
//
|
|
|
|
//
|
|
// END Usefull Functions ...
|
|
//
|