Files
xMQL5/BKPS/14030823/BKPs/14030802-X121/Helpers/x-saherelm.xchstr.helper.mq5
T
2024-11-15 10:50:11 +03:30

3240 lines
66 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHSTRHelper
// 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
//
// Imports ...
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XCHSTR_BUFFERS
{
//
XCHSTR_C_LINE = 0,
XCHSTR_C_STATE_LINE = 11,
//
XCHSTR_S_LINE = 2,
XCHSTR_S_STATE_LINE = 16,
//
XCHSTR_M_LINE = 4,
XCHSTR_M_STATE_LINE = 21,
//
XCHSTR_L_LINE = 6,
XCHSTR_L_STATE_LINE = 26,
//
XCHSTR_H_LINE = 8,
XCHSTR_H_STATE_LINE = 31,
};
//
enum ENUM_XCHSTR_TREND_STATES
{
X_STR_BULLISH = 1, // Bullish
X_STR_BEARISH = -1, // Bearish
};
//
// Input Models ...
struct XCHSTRInputs
{
//
// Props ...
//
// Market ...
int length; // Length
double multiplier; // Multiplier
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Cycles ...
//
// Short ...
ENUM_X_PERIOD_METHOD scMethod; // How to Find Period
ENUM_TIMEFRAMES scPeriod; // Time Period
//
// Medium ...
ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period
ENUM_TIMEFRAMES mcPeriod; // Time Period
//
// Long ...
ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period
ENUM_TIMEFRAMES lcPeriod; // Time Period
//
// Hind ...
ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period
ENUM_TIMEFRAMES hcPeriod; // Time Period
//
// Presentation ...
bool showCurrent; // Show Current Cycle
bool showShort; // Show Short Cycle
bool showMedium; // Show Medium Cycle
bool showLong; // Show Long Cycle
bool showHind; // Show Hind Cycle
//
// Constructor(s) ...
XCHSTRInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
multiplier = 0;
appliedTo = PRICE_CLOSE;
//
scMethod = X_PERIOD_AUTO;
scPeriod = NULL;
mcMethod = X_PERIOD_AUTO;
mcPeriod = NULL;
lcMethod = X_PERIOD_AUTO;
lcPeriod = NULL;
hcMethod = X_PERIOD_AUTO;
hcPeriod = NULL;
//
showCurrent = false;
showShort = false;
showMedium = false;
showLong = false;
showHind = false;
}
//
// Default ...
void Default()
{
//
length = 14;
multiplier = 3.5;
appliedTo = PRICE_MEDIAN;
//
scMethod = X_PERIOD_AUTO;
scPeriod = NULL;
mcMethod = X_PERIOD_AUTO;
mcPeriod = NULL;
lcMethod = X_PERIOD_AUTO;
lcPeriod = NULL;
hcMethod = X_PERIOD_AUTO;
hcPeriod = NULL;
//
showCurrent = true;
showShort = true;
showMedium = true;
showLong = true;
showHind = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 0 &&
multiplier > 0 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result =
//
MathMax(0, length)
//
;
//
return result;
}
};
//
// Define Conditions ...
struct XCHSTRConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
//
// Current ...
double cTrend[];
double cState[];
//
// Short ...
double sTrend[];
double sState[];
//
// Medium ...
double mTrend[];
double mState[];
//
// Long ...
double lTrend[];
double lState[];
//
// Hind ...
double hTrend[];
double hState[];
//
// Conditions ...
//
// Power ...
bool hasBullishPower;
bool hasBearishPower;
bool isBullishPowerUp;
bool isBearishPowerUp;
bool isBullishPowerIncreasing;
bool isBullishPowerDecreasing;
bool isBearishPowerIncreasing;
bool isBearishPowerDecreasing;
//
// Current ...
bool isCBullish;
bool isCBearish;
bool isCSwitchedToBullish;
bool isCSwitchedToBearish;
//
// Short ...
bool isSBullish;
bool isSBearish;
bool isSSwitchedToBullish;
bool isSSwitchedToBearish;
//
// Medium ...
bool isMBullish;
bool isMBearish;
bool isMSwitchedToBullish;
bool isMSwitchedToBearish;
//
// Long ...
bool isLBullish;
bool isLBearish;
bool isLSwitchedToBullish;
bool isLSwitchedToBearish;
//
// Hind ...
bool isHBullish;
bool isHBearish;
bool isHSwitchedToBullish;
bool isHSwitchedToBearish;
//
void Clean()
{
//
Clean(cTrend);
Clean(cState);
Clean(sTrend);
Clean(sState);
Clean(mTrend);
Clean(mState);
Clean(lTrend);
Clean(lState);
Clean(hTrend);
Clean(hState);
//
ArraySetAsSeries(cTrend, true);
ArraySetAsSeries(cState, true);
ArraySetAsSeries(sTrend, true);
ArraySetAsSeries(sState, true);
ArraySetAsSeries(mTrend, true);
ArraySetAsSeries(mState, true);
ArraySetAsSeries(lTrend, true);
ArraySetAsSeries(lState, true);
ArraySetAsSeries(hTrend, true);
ArraySetAsSeries(hState, true);
//
// Conditions ...
//
// Power ...
hasBullishPower = false;
hasBearishPower = false;
isBullishPowerUp = false;
isBearishPowerUp = false;
isBullishPowerIncreasing = false;
isBullishPowerDecreasing = false;
isBearishPowerIncreasing = false;
isBearishPowerDecreasing = false;
//
// Current ...
isCBullish = false;
isCBearish = false;
isCSwitchedToBullish = false;
isCSwitchedToBearish = false;
//
// Short ...
isSBullish = false;
isSBearish = false;
isSSwitchedToBullish = false;
isSSwitchedToBearish = false;
//
// Medium ...
isMBullish = false;
isMBearish = false;
isMSwitchedToBullish = false;
isMSwitchedToBearish = false;
//
// Long ...
isLBullish = false;
isLBearish = false;
isLSwitchedToBullish = false;
isLSwitchedToBearish = false;
//
// Hind ...
isHBullish = false;
isHBearish = false;
isHSwitchedToBullish = false;
isHSwitchedToBearish = false;
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
// Since We have to Use this
// Only for Filtering Signals ...
// We Can Ignore Scoring ...
// or Complete this later ...
//
// Conditions ...
//
// Power ...
if (hasBullishPower)
{
bullishScore++;
}
if (hasBearishPower)
{
bearishScore++;
}
if (isBullishPowerUp)
{
bullishScore++;
}
if (isBearishPowerUp)
{
bearishScore++;
}
if (isBullishPowerIncreasing)
{
bullishScore++;
}
if (isBullishPowerDecreasing)
{
bearishScore++;
}
if (isBearishPowerIncreasing)
{
bearishScore++;
}
if (isBearishPowerDecreasing)
{
bullishScore++;
}
//
// Current ...
if (isCBullish)
{
bullishScore++;
}
if (isCBearish)
{
bearishScore++;
}
if (isCSwitchedToBullish)
{
bullishScore++;
}
if (isCSwitchedToBearish)
{
bearishScore++;
}
//
// Short ...
if (isSBullish)
{
bullishScore++;
}
if (isSBearish)
{
bearishScore++;
}
if (isSSwitchedToBullish)
{
bullishScore++;
}
if (isSSwitchedToBearish)
{
bearishScore++;
}
//
// Medium ...
if (isMBullish)
{
bullishScore++;
}
if (isMBearish)
{
bearishScore++;
}
if (isMSwitchedToBullish)
{
bullishScore++;
}
if (isMSwitchedToBearish)
{
bearishScore++;
}
//
// Long ...
if (isLBullish)
{
bullishScore++;
}
if (isLBearish)
{
bearishScore++;
}
if (isLSwitchedToBullish)
{
bullishScore++;
}
if (isLSwitchedToBearish)
{
bearishScore++;
}
//
// Hind ...
if (isHBullish)
{
bullishScore++;
}
if (isHBearish)
{
bearishScore++;
}
if (isHSwitchedToBullish)
{
bullishScore++;
}
if (isHSwitchedToBearish)
{
bearishScore++;
}
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
// Power ...
ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) +
ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) +
ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) +
ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) +
ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) +
ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) +
ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) +
ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) +
//
// Current ...
ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) +
ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) +
ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) +
//
// Short ...
ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) +
ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) +
ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) +
//
// Medium ...
ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) +
ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) +
ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) +
//
// Long ...
ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) +
ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) +
ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) +
//
// Hind ...
ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) +
ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) +
ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) +
//
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XCHSTR";
}
};
//
// Class ...
class XSCXCHSTRHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCHSTRHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCHSTRHelper()
{
//
Clean(cTrendBuffer);
Clean(cStateBuffer);
Clean(sTrendBuffer);
Clean(sStateBuffer);
Clean(mTrendBuffer);
Clean(mStateBuffer);
Clean(lTrendBuffer);
Clean(lStateBuffer);
Clean(hTrendBuffer);
Clean(hStateBuffer);
}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCHSTRInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(cTrendBuffer, true);
ArraySetAsSeries(cStateBuffer, true);
ArraySetAsSeries(sTrendBuffer, true);
ArraySetAsSeries(sStateBuffer, true);
ArraySetAsSeries(mTrendBuffer, true);
ArraySetAsSeries(mStateBuffer, true);
ArraySetAsSeries(lTrendBuffer, true);
ArraySetAsSeries(lStateBuffer, true);
ArraySetAsSeries(hTrendBuffer, true);
ArraySetAsSeries(hStateBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xchstr",
//
// Inputs ...
//
// Market ...
"",
mInputs.length, // Length
mInputs.multiplier, // Multiplier
mInputs.appliedTo, // Applied To
//
// Cycles ...
"",
//
// Short ...
"",
mInputs.scMethod,
mInputs.scPeriod,
//
// Medium ...
"",
mInputs.mcMethod,
mInputs.mcPeriod,
//
// Long ...
"",
mInputs.lcMethod,
mInputs.lcPeriod,
//
// Hind ...
"",
mInputs.hcMethod,
mInputs.hcPeriod,
//
// Presentation ...
"",
mInputs.showCurrent,
mInputs.showShort,
mInputs.showMedium,
mInputs.showLong,
mInputs.showHind
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCHSTRInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCHSTRInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
// Current ...
//
// Trend ...
//
double GetCTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cTrendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCTrend(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
cTrendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XCHSTR_TREND_STATES GetCState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XCHSTR_TREND_STATES)((int)cStateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopyCState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
cStateBuffer,
buffer,
forceClean
//
);
}
//
// Short ...
//
// Trend ...
//
double GetSTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sTrendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySTrend(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
sTrendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XCHSTR_TREND_STATES GetSState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XCHSTR_TREND_STATES)((int)sStateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopySState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
sStateBuffer,
buffer,
forceClean
//
);
}
//
// Medium ...
//
// Trend ...
//
double GetMTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mTrendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMTrend(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
mTrendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XCHSTR_TREND_STATES GetMState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XCHSTR_TREND_STATES)((int)mStateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopyMState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
mStateBuffer,
buffer,
forceClean
//
);
}
//
// Long ...
//
// Trend ...
//
double GetLTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lTrendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLTrend(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
lTrendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XCHSTR_TREND_STATES GetLState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XCHSTR_TREND_STATES)((int)lStateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopyLState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
lStateBuffer,
buffer,
forceClean
//
);
}
//
// Hind ...
//
// Trend ...
//
double GetHTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hTrendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHTrend(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
hTrendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XCHSTR_TREND_STATES GetHState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XCHSTR_TREND_STATES)((int)hStateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopyHState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
hStateBuffer,
buffer,
forceClean
//
);
}
//
// Tools ...
//
ENUM_XCHSTR_TREND_STATES ToState(double state)
{
return (ENUM_XCHSTR_TREND_STATES)((int)state);
}
//
bool IsBullish(double state)
{
//
bool result = false;
//
result =
//
ToState(state) == X_STR_BULLISH;
//
;
//
return result;
}
//
bool IsBearish(double state)
{
//
bool result = false;
//
result =
//
ToState(state) == X_STR_BEARISH;
//
;
//
return result;
}
//
int GetTrends(
double &values[],
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
int result = 0;
//
Clean(values);
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
iValue = GetCTrend(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
iValue = GetSTrend(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
iValue = GetMTrend(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
iValue = GetLTrend(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
iValue = GetHTrend(barIndex);
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = ArraySize(values);
//
return result;
}
//
int GetBullishTrends(
double &values[],
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
int result = 0;
//
Clean(values);
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
if (IsBullish((double)GetCState(barIndex)))
{
iValue = GetCTrend(barIndex);
}
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
if (IsBullish((double)GetSState(barIndex)))
{
iValue = GetSTrend(barIndex);
}
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
if (IsBullish((double)GetMState(barIndex)))
{
iValue = GetMTrend(barIndex);
}
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
if (IsBullish((double)GetLState(barIndex)))
{
iValue = GetLTrend(barIndex);
}
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
if (IsBullish((double)GetHState(barIndex)))
{
iValue = GetHTrend(barIndex);
}
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = ArraySize(values);
//
return result;
}
//
int GetBearishTrends(
double &values[],
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
int result = 0;
//
Clean(values);
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
if (IsBearish((double)GetCState(barIndex)))
{
iValue = GetCTrend(barIndex);
}
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
if (IsBearish((double)GetSState(barIndex)))
{
iValue = GetSTrend(barIndex);
}
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
if (IsBearish((double)GetMState(barIndex)))
{
iValue = GetMTrend(barIndex);
}
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
if (IsBearish((double)GetLState(barIndex)))
{
iValue = GetLTrend(barIndex);
}
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
if (IsBearish((double)GetHState(barIndex)))
{
iValue = GetHTrend(barIndex);
}
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = ArraySize(values);
//
return result;
}
//
double GetMax(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
result = GetCyclesMax(
barIndex,
cycles //
);
//
return result;
}
//
double GetMin(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
result = GetCyclesMin(
barIndex,
cycles //
);
//
return result;
}
//
double GetMaxBullish(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
int valuesCount = GetBullishTrends(
values,
barIndex,
cycles //
);
if (!IsValidSize(valuesCount))
{
return result;
}
//
result = GetSpecifiedMax(values);
//
return result;
}
//
double GetMinBullish(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
int valuesCount = GetBullishTrends(
values,
barIndex,
cycles //
);
if (!IsValidSize(valuesCount))
{
return result;
}
//
result = GetSpecifiedMin(values);
//
return result;
}
//
double GetMaxBearish(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
int valuesCount = GetBearishTrends(
values,
barIndex,
cycles //
);
if (!IsValidSize(valuesCount))
{
return result;
}
//
result = GetSpecifiedMax(values);
//
return result;
}
//
double GetMinBearish(
int barIndex // Bar Index
)
{
//
double result = 0;
//
ENUM_X_MARKET_CYCLES cycles[];
int cyclesCount = GetAllMarketCycles(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
int valuesCount = GetBearishTrends(
values,
barIndex,
cycles //
);
if (!IsValidSize(valuesCount))
{
return result;
}
//
result = GetSpecifiedMin(values);
//
return result;
}
//
double GetCyclesMax(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMax(trends);
//
return result;
}
//
double GetCyclesMin(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMin(trends);
//
return result;
}
//
double GetCyclesMaxBullish(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetBullishTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMax(trends);
//
return result;
}
//
double GetCyclesMinBullish(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetBullishTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMin(trends);
//
return result;
}
//
double GetCyclesMaxBearish(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetBearishTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMax(trends);
//
return result;
}
//
double GetCyclesMinBearish(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
double trends[];
int trendsCount = GetBearishTrends(
trends,
barIndex,
cycles //
);
if (!IsValidSize(trendsCount))
{
return result;
}
//
result = GetSpecifiedMin(trends);
//
return result;
}
//
double GetBullishPower(
int barIndex // Bar Index
)
{
//
double result = 0;
//
double power = 0;
double state = -100;
//
// CURRENT ...
power = GetCTrend(barIndex);
state = (double)GetCState(barIndex);
if (IsBullish(state))
{
result += power;
}
//
// SHORT ...
power = GetSTrend(barIndex);
state = (double)GetSState(barIndex);
if (IsBullish(state))
{
result += power;
}
//
// MEDIUM ...
power = GetMTrend(barIndex);
state = (double)GetMState(barIndex);
if (IsBullish(state))
{
result += power;
}
//
// LONG ...
power = GetLTrend(barIndex);
state = (double)GetLState(barIndex);
if (IsBullish(state))
{
result += power;
}
//
// HIND ...
power = GetHTrend(barIndex);
state = (double)GetHState(barIndex);
if (IsBullish(state))
{
result += power;
}
//
return result;
}
//
double GetBearishPower(
int barIndex // Bar Index
)
{
//
double result = 0;
//
double power = 0;
double state = -100;
//
// CURRENT ...
power = GetCTrend(barIndex);
state = (double)GetCState(barIndex);
if (IsBearish(state))
{
result += power;
}
//
// SHORT ...
power = GetSTrend(barIndex);
state = (double)GetSState(barIndex);
if (IsBearish(state))
{
result += power;
}
//
// MEDIUM ...
power = GetMTrend(barIndex);
state = (double)GetMState(barIndex);
if (IsBearish(state))
{
result += power;
}
//
// LONG ...
power = GetLTrend(barIndex);
state = (double)GetLState(barIndex);
if (IsBearish(state))
{
result += power;
}
//
// HIND ...
power = GetHTrend(barIndex);
state = (double)GetHState(barIndex);
if (IsBearish(state))
{
result += power;
}
//
return result;
}
//
double GetCyclesBullishPower(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
for (int i = 0; i < cyclesCount; i++)
{
//
double power = 0;
double state = -100;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
power = GetCTrend(barIndex);
state = GetCState(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
power = GetSTrend(barIndex);
state = GetSState(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
power = GetMTrend(barIndex);
state = GetMState(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
power = GetLTrend(barIndex);
state = GetLState(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
power = GetHTrend(barIndex);
state = GetHState(barIndex);
break;
}
//
if (power > 0 && state != -100)
{
//
if (IsBullish(state))
{
result += power;
}
}
}
//
return result;
}
//
double GetCyclesBearishPower(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
for (int i = 0; i < cyclesCount; i++)
{
//
double power = 0;
double state = -100;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
power = GetCTrend(barIndex);
state = GetCState(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
power = GetSTrend(barIndex);
state = GetSState(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
power = GetMTrend(barIndex);
state = GetMState(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
power = GetLTrend(barIndex);
state = GetLState(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
power = GetHTrend(barIndex);
state = GetHState(barIndex);
break;
}
//
if (power > 0 && state != -100)
{
//
if (IsBearish(state))
{
result += power;
}
}
}
//
return result;
}
//
bool HasBullishPower(
int barIndex // Bar Index
)
{
//
bool result = false;
//
double bullishPower = GetBullishPower(barIndex);
double bearishPower = GetBearishPower(barIndex);
//
result =
//
bearishPower >= 0 &&
bullishPower > bearishPower
//
;
//
return result;
}
//
bool HasBearishPower(
int barIndex // Bar Index
)
{
//
bool result = false;
//
double bullishPower = GetBullishPower(barIndex);
double bearishPower = GetBearishPower(barIndex);
//
result =
//
bullishPower >= 0 &&
bearishPower > bullishPower
//
;
//
return result;
}
//
bool HasCyclesBullishPower(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
bool result = false;
//
double bullishPower = GetCyclesBullishPower(barIndex, cycles);
double bearishPower = GetCyclesBearishPower(barIndex, cycles);
//
result =
//
bearishPower >= 0 &&
bullishPower > bearishPower
//
;
//
return result;
}
//
bool HasCyclesBearishPower(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] //
)
{
//
bool result = false;
//
double bullishPower = GetCyclesBullishPower(barIndex, cycles);
double bearishPower = GetCyclesBearishPower(barIndex, cycles);
//
result =
//
bullishPower >= 0 &&
bearishPower > bullishPower
//
;
//
return result;
}
//
// Check Bullish Power Increasing ...
bool IsBullishPowerIncreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBullishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBullishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bullish Power Decreasing ...
bool IsBullishPowerDecreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBullishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBullishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Increasing ...
bool IsBearishPowerIncreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBearishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBearishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Decreasing ...
bool IsBearishPowerDecreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBearishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBearishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Check Bullish Power Increasing ...
bool IsCyclesBullishPowerIncreasing(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[], //
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetCyclesBullishPower(barIndex, cycles);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetCyclesBullishPower(i, cycles);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bullish Power Decreasing ...
bool IsCyclesBullishPowerDecreasing(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[], //
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetCyclesBullishPower(barIndex, cycles);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetCyclesBullishPower(i, cycles);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Increasing ...
bool IsCyclesBearishPowerIncreasing(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[], //
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetCyclesBearishPower(barIndex, cycles);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetCyclesBearishPower(i, cycles);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Decreasing ...
bool IsCyclesBearishPowerDecreasing(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[], //
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetCyclesBearishPower(barIndex, cycles);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetCyclesBearishPower(i, cycles);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Conditions ...
//
bool GetConditions(
XCHSTRConditions &conditions, //
int barIndex = 0, //
int loopback = 5 //
)
{
//
bool result = true;
//
if (loopback < 5)
{
loopback = 5;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
// Current ...
CopyCTrend(
zIndex,
loopback,
conditions.cTrend //
);
CopyCState(
zIndex,
loopback,
conditions.cState //
);
//
// Short ...
CopySTrend(
zIndex,
loopback,
conditions.sTrend //
);
CopySState(
zIndex,
loopback,
conditions.sState //
);
//
// Medium ...
CopyMTrend(
zIndex,
loopback,
conditions.mTrend //
);
CopyMState(
zIndex,
loopback,
conditions.mState //
);
//
// Long ...
CopyLTrend(
zIndex,
loopback,
conditions.lTrend //
);
CopyLState(
zIndex,
loopback,
conditions.lState //
);
//
// Hind ...
CopyHTrend(
zIndex,
loopback,
conditions.hTrend //
);
CopyHState(
zIndex,
loopback,
conditions.hState //
);
//
// Conditions ...
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
mSymbol,
mPeriod,
pIndex //
);
if (!result)
{
return result;
}
//
// Power ...
//
bool hasBullishPower = HasBullishPower(cIndex);
bool hasBullishPowerPrev = HasBullishPower(pIndex);
//
bool hasBearishPower = HasBearishPower(cIndex);
bool hasBearishPowerPrev = HasBearishPower(pIndex);
//
bool isBullishPowerUp = hasBullishPower &&
!hasBullishPowerPrev;
bool isBearishPowerUp = hasBearishPower &&
!hasBearishPowerPrev;
//
bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex);
bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex);
bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex);
bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex);
//
conditions.hasBullishPower = hasBullishPower;
conditions.hasBearishPower = hasBearishPower;
conditions.isBullishPowerUp = isBullishPowerUp;
conditions.isBearishPowerUp = isBearishPowerUp;
conditions.isBullishPowerIncreasing = isBullishPowerIncreasing;
conditions.isBullishPowerDecreasing = isBullishPowerDecreasing;
conditions.isBearishPowerIncreasing = isBearishPowerIncreasing;
conditions.isBearishPowerDecreasing = isBearishPowerDecreasing;
//
// Current ...
//
bool isCBullish = IsBullish(conditions.cState[cIndex]);
bool isCBullishPrev = IsBullish(conditions.cState[pIndex]);
//
bool isCBearish = IsBearish(conditions.cState[cIndex]);
bool isCBearishPrev = IsBearish(conditions.cState[pIndex]);
//
bool isCSwitchedToBullish = isCBullish &&
!isCBullishPrev;
bool isCSwitchedToBearish = isCBearish &&
!isCBearishPrev;
//
conditions.isCBullish = isCBullish;
conditions.isCBearish = isCBearish;
conditions.isCSwitchedToBullish = isCSwitchedToBullish;
conditions.isCSwitchedToBearish = isCSwitchedToBearish;
//
// Short ...
//
bool isSBullish = IsBullish(conditions.sState[cIndex]);
bool isSBullishPrev = IsBullish(conditions.sState[pIndex]);
//
bool isSBearish = IsBearish(conditions.sState[cIndex]);
bool isSBearishPrev = IsBearish(conditions.sState[pIndex]);
//
bool isSSwitchedToBullish = isSBullish &&
!isSBullishPrev;
bool isSSwitchedToBearish = isSBearish &&
!isSBearishPrev;
//
conditions.isSBullish = isSBullish;
conditions.isSBearish = isSBearish;
conditions.isSSwitchedToBullish = isSSwitchedToBullish;
conditions.isSSwitchedToBearish = isSSwitchedToBearish;
//
// Medium ...
//
bool isMBullish = IsBullish(conditions.mState[cIndex]);
bool isMBullishPrev = IsBullish(conditions.mState[pIndex]);
//
bool isMBearish = IsBearish(conditions.mState[cIndex]);
bool isMBearishPrev = IsBearish(conditions.mState[pIndex]);
//
bool isMSwitchedToBullish = isMBullish &&
!isMBullishPrev;
bool isMSwitchedToBearish = isMBearish &&
!isMBearishPrev;
//
conditions.isMBullish = isMBullish;
conditions.isMBearish = isMBearish;
conditions.isMSwitchedToBullish = isMSwitchedToBullish;
conditions.isMSwitchedToBearish = isMSwitchedToBearish;
//
// Long ...
//
bool isLBullish = IsBullish(conditions.lState[cIndex]);
bool isLBullishPrev = IsBullish(conditions.lState[pIndex]);
//
bool isLBearish = IsBearish(conditions.lState[cIndex]);
bool isLBearishPrev = IsBearish(conditions.lState[pIndex]);
//
bool isLSwitchedToBullish = isLBullish &&
!isLBullishPrev;
bool isLSwitchedToBearish = isLBearish &&
!isLBearishPrev;
//
conditions.isLBullish = isLBullish;
conditions.isLBearish = isLBearish;
conditions.isLSwitchedToBullish = isLSwitchedToBullish;
conditions.isLSwitchedToBearish = isLSwitchedToBearish;
//
// Hind ...
//
bool isHBullish = IsBullish(conditions.hState[cIndex]);
bool isHBullishPrev = IsBullish(conditions.hState[pIndex]);
//
bool isHBearish = IsBearish(conditions.hState[cIndex]);
bool isHBearishPrev = IsBearish(conditions.hState[pIndex]);
//
bool isHSwitchedToBullish = isHBullish &&
!isHBullishPrev;
bool isHSwitchedToBearish = isHBearish &&
!isHBearishPrev;
//
conditions.isHBullish = isHBullish;
conditions.isHBearish = isHBearish;
conditions.isHSwitchedToBullish = isHSwitchedToBullish;
conditions.isHSwitchedToBearish = isHSwitchedToBearish;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCHSTRInputs mInputs; // Inputs ...
//
// Buffers ...
//
// Current ...
double cTrendBuffer[];
double cStateBuffer[];
//
// Short ...
double sTrendBuffer[];
double sStateBuffer[];
//
// Medium ...
double mTrendBuffer[];
double mStateBuffer[];
//
// Long ...
double lTrendBuffer[];
double lStateBuffer[];
//
// Hind ...
double hTrendBuffer[];
double hStateBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Current ...
//
// Trend ...
CopyBuffer(
mHandler,
XCHSTR_C_LINE,
0,
totalBars,
cTrendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
XCHSTR_C_STATE_LINE,
0,
totalBars,
cStateBuffer
//
);
//
// Short ...
//
// Trend ...
CopyBuffer(
mHandler,
XCHSTR_S_LINE,
0,
totalBars,
sTrendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
XCHSTR_S_STATE_LINE,
0,
totalBars,
sStateBuffer
//
);
//
// Medium ...
//
// Trend ...
CopyBuffer(
mHandler,
XCHSTR_M_LINE,
0,
totalBars,
mTrendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
XCHSTR_M_STATE_LINE,
0,
totalBars,
mStateBuffer
//
);
//
// Long ...
//
// Trend ...
CopyBuffer(
mHandler,
XCHSTR_L_LINE,
0,
totalBars,
lTrendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
XCHSTR_L_STATE_LINE,
0,
totalBars,
lStateBuffer
//
);
//
// Hind ...
//
// Trend ...
CopyBuffer(
mHandler,
XCHSTR_H_LINE,
0,
totalBars,
hTrendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
XCHSTR_H_STATE_LINE,
0,
totalBars,
hStateBuffer
//
);
};
};
//