6693 lines
150 KiB
Plaintext
6693 lines
150 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XCX121XCatbHelper
|
|
// 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.x-helper.class.mq5"
|
|
#include "../Libraries/x-saherelm.x-poi.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Buffers ...
|
|
enum ENUM_X121_XCATB_BUFFERS
|
|
{
|
|
X121_XCATB_SAR_LINE = 0,
|
|
X121_XCATB_SAR_COLOR_LINE = 1,
|
|
X121_XCATB_PEAK_LINE = 2,
|
|
X121_XCATB_VALE_LINE = 3,
|
|
X121_XCATB_PEAK_GOLDEN_LINE = 4,
|
|
X121_XCATB_VALE_GOLDEN_LINE = 5,
|
|
X121_XCATB_ATR_BAND_UPPER_LINE = 6,
|
|
X121_XCATB_ATR_BAND_LOWER_LINE = 7,
|
|
X121_XCATB_TREND_LINE = 8,
|
|
X121_XCATB_TREND_COLOR_LINE = 9,
|
|
X121_XCATB_SBAR_O_LINE = 10,
|
|
X121_XCATB_SBAR_H_LINE = 11,
|
|
X121_XCATB_SBAR_L_LINE = 12,
|
|
X121_XCATB_SBAR_C_LINE = 13,
|
|
X121_XCATB_SBAR_COLOR_LINE = 14,
|
|
X121_XCATB_HK_SBAR_O_LINE = 15,
|
|
X121_XCATB_HK_SBAR_H_LINE = 16,
|
|
X121_XCATB_HK_SBAR_L_LINE = 17,
|
|
X121_XCATB_HK_SBAR_C_LINE = 18,
|
|
X121_XCATB_HK_SBAR_COLOR_LINE = 19,
|
|
X121_XCATB_S_HH_LINE = 20,
|
|
X121_XCATB_S_LL_LINE = 21,
|
|
X121_XCATB_M_HH_LINE = 22,
|
|
X121_XCATB_M_LL_LINE = 23,
|
|
X121_XCATB_L_HH_LINE = 24,
|
|
X121_XCATB_L_LL_LINE = 25,
|
|
X121_XCATB_H_HH_LINE = 26,
|
|
X121_XCATB_H_LL_LINE = 27,
|
|
X121_XCATB_KI_LINE = 28,
|
|
X121_XCATB_KI_COLOR_LINE = 29,
|
|
X121_XCATB_SAR_STATE_LINE = 30,
|
|
X121_XCATB_TREND_STATE_LINE = 31,
|
|
X121_XCATB_RSI_LINE = 32,
|
|
X121_XCATB_ADX_LINE = 33,
|
|
X121_XCATB_ADXP_LINE = 34,
|
|
X121_XCATB_ADXN_LINE = 35,
|
|
X121_XCATB_DELTA_LINE = 36,
|
|
X121_XCATB_DELTA_SIGNAL_LINE = 37,
|
|
X121_XCATB_VOLUME_BULLISH_LINE = 38,
|
|
X121_XCATB_VOLUME_BEARISH_LINE = 39,
|
|
X121_XCATB_VOLUME_VOLUME_BULLISH_SIGNAL_LINE = 40,
|
|
X121_XCATB_VOLUME_VOLUME_BEARISH_SIGNAL_LINE = 41,
|
|
X121_XCATB_ATR_LINE = 42,
|
|
X121_XCATB_ATR_BAND_RAW_UPPER_LINE = 43,
|
|
X121_XCATB_ATR_BAND_RAW_LOWER_LINE = 44,
|
|
X121_XCATB_HK_BAR_O_LINE = 45,
|
|
X121_XCATB_HK_BAR_H_LINE = 46,
|
|
X121_XCATB_HK_BAR_L_LINE = 47,
|
|
X121_XCATB_HK_BAR_C_LINE = 48,
|
|
X121_XCATB_KI_STATE_LINE = 49,
|
|
};
|
|
|
|
//
|
|
// Input Models ...
|
|
struct X121XCatbInputs
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Market ...
|
|
ENUM_X_PERIOD_METHOD scMethod; // How to Find Short Period
|
|
ENUM_TIMEFRAMES scPeriod; // Short Period
|
|
ENUM_X_PERIOD_METHOD mcMethod; // How to Find Medium Period
|
|
ENUM_TIMEFRAMES mcPeriod; // Medium Period
|
|
ENUM_X_PERIOD_METHOD lcMethod; // How to Find Long Period
|
|
ENUM_TIMEFRAMES lcPeriod; // Long Period
|
|
ENUM_X_PERIOD_METHOD hcMethod; // How to Find Hind Period
|
|
ENUM_TIMEFRAMES hcPeriod; // Hind Period
|
|
ENUM_X_MARKET_CYCLES appliedCycle; // Applied Cycle
|
|
|
|
//
|
|
// Presentation ...
|
|
bool showBars; // Show Bars
|
|
bool showKI; // Show KI
|
|
bool showPV; // Show PV
|
|
bool showPVGolden; // Show PV Golden
|
|
bool showSar; // Show Sar
|
|
bool showTrend; // Show Trend
|
|
bool showATRBand; // Show ATR Band
|
|
bool showSignalBars; // Show Signal Bars
|
|
bool showHKSignalBars; // Show Hiken Ashi Signal Bars
|
|
|
|
//
|
|
double rsiOBLevel; // RSI OB Level
|
|
double rsiOSLevel; // RSI OS Level
|
|
double adxThreshold; // ADX Threshold
|
|
|
|
//
|
|
int startCalculationForLastBars; // Calculate Last n Bars
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
X121XCatbInputs()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Clean ...
|
|
void Clean()
|
|
{
|
|
//
|
|
// Market ...
|
|
scMethod = X_PERIOD_AUTO; // How to Find Short Period
|
|
scPeriod = NULL; // Short Period
|
|
mcMethod = X_PERIOD_AUTO; // How to Find Medium Period
|
|
mcPeriod = NULL; // Medium Period
|
|
lcMethod = X_PERIOD_AUTO; // How to Find Long Period
|
|
lcPeriod = NULL; // Long Period
|
|
hcMethod = X_PERIOD_AUTO; // How to Find Hind Period
|
|
hcPeriod = NULL; // Hind Period
|
|
appliedCycle = X_MARKET_CYCLE_HIND; // Applied Cycle
|
|
|
|
//
|
|
// Presentation ...
|
|
showBars = false; // Show Bars
|
|
showKI = false; // Show KI
|
|
showPV = false; // Show PV
|
|
showPVGolden = false; // Show PV Golden
|
|
showSar = false; // Show Sar
|
|
showTrend = false; // Show Trend
|
|
showATRBand = false; // Show ATR Band
|
|
showSignalBars = false; // Show Signal Bars
|
|
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
|
|
|
//
|
|
startCalculationForLastBars = 0; // Calculate Last n Bars
|
|
|
|
//
|
|
rsiOBLevel = 70.0; // RSI OB Level
|
|
rsiOSLevel = 30.0; // RSI OS Level
|
|
adxThreshold = 25.0; // ADX Threshold
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
// Market ...
|
|
scMethod = X_PERIOD_AUTO; // How to Find Short Period
|
|
scPeriod = NULL; // Short Period
|
|
mcMethod = X_PERIOD_AUTO; // How to Find Medium Period
|
|
mcPeriod = NULL; // Medium Period
|
|
lcMethod = X_PERIOD_AUTO; // How to Find Long Period
|
|
lcPeriod = NULL; // Long Period
|
|
hcMethod = X_PERIOD_AUTO; // How to Find Hind Period
|
|
hcPeriod = NULL; // Hind Period
|
|
appliedCycle = X_MARKET_CYCLE_HIND; // Applied Cycle
|
|
|
|
//
|
|
// Presentation ...
|
|
showBars = true; // Show Bars
|
|
showKI = false; // Show KI
|
|
showPV = false; // Show PV
|
|
showPVGolden = false; // Show PV Golden
|
|
showSar = false; // Show Sar
|
|
showTrend = false; // Show Trend
|
|
showATRBand = false; // Show ATR Band
|
|
showSignalBars = false; // Show Signal Bars
|
|
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
|
|
|
//
|
|
startCalculationForLastBars = 1500; // Calculate Last n Bars
|
|
|
|
//
|
|
rsiOBLevel = 70.0; // RSI OB Level
|
|
rsiOSLevel = 30.0; // RSI OS Level
|
|
adxThreshold = 25.0; // ADX Threshold
|
|
}
|
|
|
|
//
|
|
// Hide all Visible Buffers ...
|
|
void Hide()
|
|
{
|
|
//
|
|
showKI = false;
|
|
showPV = false;
|
|
showSar = false;
|
|
showTrend = false;
|
|
showATRBand = false;
|
|
showPVGolden = false;
|
|
showSignalBars = false;
|
|
showHKSignalBars = false;
|
|
|
|
//
|
|
// drawSignals = false;
|
|
// drawTriggerBlock = false;
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsSpecifiedValid(appliedCycle) &&
|
|
//
|
|
// CYCLES ...
|
|
(IsSpecifiedValid(scMethod, scPeriod) &&
|
|
IsSpecifiedValid(mcMethod, mcPeriod) &&
|
|
IsSpecifiedValid(lcMethod, lcPeriod) &&
|
|
IsSpecifiedValid(hcMethod, hcPeriod))
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve MAx Length ...
|
|
int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Conditions ...
|
|
struct X121XCatbConditions
|
|
{
|
|
//
|
|
// Common ...
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
datetime to;
|
|
datetime from;
|
|
XOHCL bars[];
|
|
|
|
//
|
|
// Buffers ...
|
|
double kiBuffer[];
|
|
double sarBuffer[];
|
|
double atrBuffer[];
|
|
double rsiBuffer[];
|
|
double adxBuffer[];
|
|
double sHHBuffer[];
|
|
double sLLBuffer[];
|
|
double mHHBuffer[];
|
|
double mLLBuffer[];
|
|
double lHHBuffer[];
|
|
double lLLBuffer[];
|
|
double hHHBuffer[];
|
|
double hLLBuffer[];
|
|
double adxpBuffer[];
|
|
double adxnBuffer[];
|
|
double peakBuffer[];
|
|
double valeBuffer[];
|
|
double deltaBuffer[];
|
|
double trendBuffer[];
|
|
double hkLowBuffer[];
|
|
double hkOpenBuffer[];
|
|
double hkHighBuffer[];
|
|
double hkCloseBuffer[];
|
|
double kiStateBuffer[];
|
|
double sarStateBuffer[];
|
|
double atrUpperBuffer[];
|
|
double atrLowerBuffer[];
|
|
double sBarOpenBuffer[];
|
|
double sBarCloseBuffer[];
|
|
double trendStateBuffer[];
|
|
double hkSBarOpenBuffer[];
|
|
double peakGoldenBuffer[];
|
|
double valeGoldenBuffer[];
|
|
double hkSBarCloseBuffer[];
|
|
double deltaSignalBuffer[];
|
|
double bullishVolumeBuffer[];
|
|
double bearishVolumeBuffer[];
|
|
double bullishVolumeSignalBuffer[];
|
|
double bearishVolumeSignalBuffer[];
|
|
|
|
//
|
|
double rsiOBLevel; // Over Bought Level
|
|
double rsiOSLevel; // Over Sold Level
|
|
double adxThreshold; // Big Movement Threshold
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// ATR Band ...
|
|
|
|
//
|
|
bool isATRUp;
|
|
bool isATRDown;
|
|
|
|
//
|
|
bool isClosedOverATRUpper;
|
|
bool isClosedUnderATRLower;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
bool isSarBullish;
|
|
bool isSarBearish;
|
|
|
|
//
|
|
bool isSarSwitchedToBullish;
|
|
bool isSarSwitchedToBearish;
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
bool isKIUp;
|
|
bool isKIDown;
|
|
|
|
//
|
|
bool isKIBullish;
|
|
bool isKIBearish;
|
|
|
|
//
|
|
bool isKISameAsLast;
|
|
|
|
//
|
|
bool isKISwitchedToBullish;
|
|
bool isKISwitchedToBearish;
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
bool isADXBiggerLast;
|
|
bool isADXLesserLast;
|
|
|
|
//
|
|
bool isADXOverThreshold;
|
|
bool isADXUnderThreshold;
|
|
|
|
//
|
|
bool isDXPBiggerThanDXN;
|
|
bool isDXNBiggerThanDXP;
|
|
|
|
//
|
|
bool isADXBullish;
|
|
bool isADXBearish;
|
|
|
|
//
|
|
bool isADXSwitchedToBullish;
|
|
bool isADXSwitchedToBearish;
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
bool isRSIBullish;
|
|
bool isRSIBearish;
|
|
|
|
//
|
|
bool isRSISwitchedToBullish;
|
|
bool isRSISwitchedToBearish;
|
|
|
|
//
|
|
bool isRSIOB;
|
|
bool isRSIOS;
|
|
|
|
//
|
|
bool isRSICrossedOverOB;
|
|
bool isRSICrossedOverOS;
|
|
|
|
//
|
|
bool isRSICrossedUnderOB;
|
|
bool isRSICrossedUnderOS;
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
bool isDeltaUp;
|
|
bool isDeltaDown;
|
|
|
|
//
|
|
bool isDeltaBullish;
|
|
bool isDeltaBearish;
|
|
|
|
//
|
|
bool isDeltaSwitchedToBullish;
|
|
bool isDeltaSwitchedToBearish;
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
bool isVolumeBullish;
|
|
bool isVolumeBearish;
|
|
|
|
//
|
|
bool isVolumeSwitchedToBullish;
|
|
bool isVolumeSwitchedToBearish;
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
bool isSBarBullish;
|
|
bool isSBarBearish;
|
|
|
|
//
|
|
bool isSBarSwitchedToBullish;
|
|
bool isSBarSwitchedToBearish;
|
|
|
|
//
|
|
// XHK Signal Bar ...
|
|
|
|
//
|
|
bool isHKSBarBullish;
|
|
bool isHKSBarBearish;
|
|
|
|
//
|
|
bool isHKSBarSwitchedToBullish;
|
|
bool isHKSBarSwitchedToBearish;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
bool isTrendUp;
|
|
bool isTrendDown;
|
|
|
|
//
|
|
bool isTrendBullish;
|
|
bool isTrendBearish;
|
|
|
|
//
|
|
bool isTrendSwitchedToBullish;
|
|
bool isTrendSwitchedToBearish;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
bool isPeakSameLast;
|
|
bool isPeakOverLast;
|
|
bool isPeakUnderLast;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
bool isValeSameLast;
|
|
bool isValeOverLast;
|
|
bool isValeUnderLast;
|
|
|
|
//
|
|
// Constructor ...
|
|
X121XCatbConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleaning Up ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
// Commons ...
|
|
to = NULL;
|
|
from = NULL;
|
|
time = NULL;
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
SpecifiedClean(bars);
|
|
SpecifiedClean(kiBuffer);
|
|
SpecifiedClean(sarBuffer);
|
|
SpecifiedClean(atrBuffer);
|
|
SpecifiedClean(rsiBuffer);
|
|
SpecifiedClean(adxBuffer);
|
|
SpecifiedClean(sHHBuffer);
|
|
SpecifiedClean(sLLBuffer);
|
|
SpecifiedClean(mHHBuffer);
|
|
SpecifiedClean(mLLBuffer);
|
|
SpecifiedClean(lHHBuffer);
|
|
SpecifiedClean(lLLBuffer);
|
|
SpecifiedClean(hHHBuffer);
|
|
SpecifiedClean(hLLBuffer);
|
|
SpecifiedClean(adxpBuffer);
|
|
SpecifiedClean(adxnBuffer);
|
|
SpecifiedClean(peakBuffer);
|
|
SpecifiedClean(valeBuffer);
|
|
SpecifiedClean(deltaBuffer);
|
|
SpecifiedClean(trendBuffer);
|
|
SpecifiedClean(hkLowBuffer);
|
|
SpecifiedClean(hkOpenBuffer);
|
|
SpecifiedClean(hkHighBuffer);
|
|
SpecifiedClean(hkCloseBuffer);
|
|
SpecifiedClean(kiStateBuffer);
|
|
SpecifiedClean(sarStateBuffer);
|
|
SpecifiedClean(atrUpperBuffer);
|
|
SpecifiedClean(atrLowerBuffer);
|
|
SpecifiedClean(sBarOpenBuffer);
|
|
SpecifiedClean(sBarCloseBuffer);
|
|
SpecifiedClean(trendStateBuffer);
|
|
SpecifiedClean(hkSBarOpenBuffer);
|
|
SpecifiedClean(peakGoldenBuffer);
|
|
SpecifiedClean(valeGoldenBuffer);
|
|
SpecifiedClean(hkSBarCloseBuffer);
|
|
SpecifiedClean(deltaSignalBuffer);
|
|
SpecifiedClean(bullishVolumeBuffer);
|
|
SpecifiedClean(bearishVolumeBuffer);
|
|
SpecifiedClean(bullishVolumeSignalBuffer);
|
|
SpecifiedClean(bearishVolumeSignalBuffer);
|
|
|
|
//
|
|
ArraySetAsSeries(bars, true);
|
|
ArraySetAsSeries(kiBuffer, true);
|
|
ArraySetAsSeries(sarBuffer, true);
|
|
ArraySetAsSeries(atrBuffer, true);
|
|
ArraySetAsSeries(rsiBuffer, true);
|
|
ArraySetAsSeries(adxBuffer, true);
|
|
ArraySetAsSeries(sHHBuffer, true);
|
|
ArraySetAsSeries(sLLBuffer, true);
|
|
ArraySetAsSeries(mHHBuffer, true);
|
|
ArraySetAsSeries(mLLBuffer, true);
|
|
ArraySetAsSeries(lHHBuffer, true);
|
|
ArraySetAsSeries(lLLBuffer, true);
|
|
ArraySetAsSeries(hHHBuffer, true);
|
|
ArraySetAsSeries(hLLBuffer, true);
|
|
ArraySetAsSeries(adxpBuffer, true);
|
|
ArraySetAsSeries(adxnBuffer, true);
|
|
ArraySetAsSeries(peakBuffer, true);
|
|
ArraySetAsSeries(valeBuffer, true);
|
|
ArraySetAsSeries(deltaBuffer, true);
|
|
ArraySetAsSeries(trendBuffer, true);
|
|
ArraySetAsSeries(hkLowBuffer, true);
|
|
ArraySetAsSeries(hkOpenBuffer, true);
|
|
ArraySetAsSeries(hkHighBuffer, true);
|
|
ArraySetAsSeries(hkCloseBuffer, true);
|
|
ArraySetAsSeries(kiStateBuffer, true);
|
|
ArraySetAsSeries(sarStateBuffer, true);
|
|
ArraySetAsSeries(atrUpperBuffer, true);
|
|
ArraySetAsSeries(atrLowerBuffer, true);
|
|
ArraySetAsSeries(sBarOpenBuffer, true);
|
|
ArraySetAsSeries(sBarCloseBuffer, true);
|
|
ArraySetAsSeries(trendStateBuffer, true);
|
|
ArraySetAsSeries(hkSBarOpenBuffer, true);
|
|
ArraySetAsSeries(peakGoldenBuffer, true);
|
|
ArraySetAsSeries(valeGoldenBuffer, true);
|
|
ArraySetAsSeries(hkSBarCloseBuffer, true);
|
|
ArraySetAsSeries(deltaSignalBuffer, true);
|
|
ArraySetAsSeries(bullishVolumeBuffer, true);
|
|
ArraySetAsSeries(bearishVolumeBuffer, true);
|
|
ArraySetAsSeries(bullishVolumeSignalBuffer, true);
|
|
ArraySetAsSeries(bearishVolumeSignalBuffer, true);
|
|
|
|
//
|
|
rsiOBLevel = 0; // Over Bought Level
|
|
rsiOSLevel = 0; // Over Sold Level
|
|
adxThreshold = 0; // Big Movement Threshold
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// ATR Band ...
|
|
|
|
//
|
|
isATRUp = false;
|
|
isATRDown = false;
|
|
|
|
//
|
|
isClosedOverATRUpper = false;
|
|
isClosedUnderATRLower = false;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
isSarBullish = false;
|
|
isSarBearish = false;
|
|
|
|
//
|
|
isSarSwitchedToBullish = false;
|
|
isSarSwitchedToBearish = false;
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
isKIUp = false;
|
|
isKIDown = false;
|
|
|
|
//
|
|
isKIBullish = false;
|
|
isKIBearish = false;
|
|
|
|
//
|
|
isKISameAsLast = false;
|
|
|
|
//
|
|
isKISwitchedToBullish = false;
|
|
isKISwitchedToBearish = false;
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
isADXBiggerLast = false;
|
|
isADXLesserLast = false;
|
|
|
|
//
|
|
isADXOverThreshold = false;
|
|
isADXUnderThreshold = false;
|
|
|
|
//
|
|
isDXPBiggerThanDXN = false;
|
|
isDXNBiggerThanDXP = false;
|
|
|
|
//
|
|
isADXBullish = false;
|
|
isADXBearish = false;
|
|
|
|
//
|
|
isADXSwitchedToBullish = false;
|
|
isADXSwitchedToBearish = false;
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
isRSIBullish = false;
|
|
isRSIBearish = false;
|
|
|
|
//
|
|
isRSISwitchedToBullish = false;
|
|
isRSISwitchedToBearish = false;
|
|
|
|
//
|
|
isRSIOB = false;
|
|
isRSIOS = false;
|
|
|
|
//
|
|
isRSICrossedOverOB = false;
|
|
isRSICrossedOverOS = false;
|
|
|
|
//
|
|
isRSICrossedUnderOB = false;
|
|
isRSICrossedUnderOS = false;
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
isDeltaUp = false;
|
|
isDeltaDown = false;
|
|
|
|
//
|
|
isDeltaBullish = false;
|
|
isDeltaBearish = false;
|
|
|
|
//
|
|
isDeltaSwitchedToBullish = false;
|
|
isDeltaSwitchedToBearish = false;
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
isVolumeBullish = false;
|
|
isVolumeBearish = false;
|
|
|
|
//
|
|
isVolumeSwitchedToBullish = false;
|
|
isVolumeSwitchedToBearish = false;
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
isSBarBullish = false;
|
|
isSBarBearish = false;
|
|
|
|
//
|
|
isSBarSwitchedToBullish = false;
|
|
isSBarSwitchedToBearish = false;
|
|
|
|
//
|
|
// XHK Signal Bar ...
|
|
|
|
//
|
|
isHKSBarBullish = false;
|
|
isHKSBarBearish = false;
|
|
|
|
//
|
|
isHKSBarSwitchedToBullish = false;
|
|
isHKSBarSwitchedToBearish = false;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
isTrendUp = false;
|
|
isTrendDown = false;
|
|
|
|
//
|
|
isTrendBullish = false;
|
|
isTrendBearish = false;
|
|
|
|
//
|
|
isTrendSwitchedToBullish = false;
|
|
isTrendSwitchedToBearish = false;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
isPeakSameLast = false;
|
|
isPeakOverLast = false;
|
|
isPeakUnderLast = false;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
isValeSameLast = false;
|
|
isValeOverLast = false;
|
|
isValeUnderLast = false;
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
/**
|
|
* Generate Conditions Scores ...
|
|
*
|
|
* @param bullishScore: Double, Directional Scores Reference ...
|
|
* @param bearishScore: Double, Directional Scores Reference ...
|
|
*/
|
|
void GenerateScore(
|
|
double &bullishScore,
|
|
double &bearishScore //
|
|
)
|
|
{
|
|
//
|
|
bullishScore = 0;
|
|
bearishScore = 0;
|
|
|
|
//
|
|
double score = 1;
|
|
double minScore = 0.5;
|
|
double highScore = 1.5;
|
|
|
|
//
|
|
// ATR Band ...
|
|
|
|
//
|
|
if (isATRUp)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isClosedOverATRUpper)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isATRDown)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isClosedUnderATRLower)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
if (isSarBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isSarSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isSarBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isSarSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
if (isKIUp)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isKIBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isKISwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isKIDown)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isKIBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isKISwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
if (isADXBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isADXBiggerLast)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isDXPBiggerThanDXN)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isADXOverThreshold)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isADXSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isADXBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isADXLesserLast)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isDXNBiggerThanDXP)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isADXUnderThreshold)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isADXSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
if (isRSIOS)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isRSIBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isRSICrossedOverOS)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isRSICrossedOverOB)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isRSISwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isRSIOB)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isRSIBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isRSICrossedUnderOB)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isRSICrossedUnderOS)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isRSISwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
if (isDeltaUp)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isDeltaBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isDeltaSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isDeltaDown)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isDeltaBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isDeltaSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
if (isVolumeBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isVolumeSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isVolumeBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isVolumeSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
if (isSBarBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isSBarSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isSBarBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isSBarSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// XHK Signal Bar ...
|
|
|
|
//
|
|
if (isHKSBarBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isHKSBarSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isHKSBarBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isHKSBarSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
if (isTrendUp)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isTrendBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isTrendSwitchedToBullish)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isTrendDown)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isTrendBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isTrendSwitchedToBearish)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
|
|
//
|
|
// PEAK and VALE ...
|
|
|
|
//
|
|
if (isValeSameLast)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isValeOverLast)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isPeakOverLast)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isPeakSameLast)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isPeakUnderLast)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isValeUnderLast)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Generate Summary String for Represent Conditions State ...
|
|
*
|
|
* @param onlyCommons: Boolean, Just Generate Only Commons Conditions ...
|
|
* @param onlyConditions: Boolean, Just Generate Only Conditions ...
|
|
* @param includeScores: Boolean, Attach Scores Representations on Result ...
|
|
* @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ...
|
|
* @param separator: String, Separate Lines ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
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: " + ToXString(bullishScore) + separator +
|
|
"Bearish: " + ToXString(bearishScore) + separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
string commonStr = GenerateSpecifiedCommonSummary(
|
|
this,
|
|
separator,
|
|
includeScores //
|
|
);
|
|
|
|
//
|
|
string conditionsStr =
|
|
//
|
|
"-----------------------" + separator +
|
|
"XCATB: " + separator +
|
|
"-----------------------" + separator +
|
|
"" + separator +
|
|
//
|
|
"-----------------------" + separator +
|
|
"ATR Band: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isATRUp", isATRUp, ignoreFalseConditions, separator) +
|
|
ToXString("isATRDown", isATRDown, ignoreFalseConditions, separator) +
|
|
ToXString("isClosedOverATRUpper", isClosedOverATRUpper, ignoreFalseConditions, separator) +
|
|
ToXString("isClosedUnderATRLower", isClosedUnderATRLower, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"KI: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isKIUp", isKIUp, ignoreFalseConditions, separator) +
|
|
ToXString("isKIDown", isKIDown, ignoreFalseConditions, separator) +
|
|
ToXString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isKISameAsLast", isKISameAsLast, ignoreFalseConditions, separator) +
|
|
ToXString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"SAR: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"ADX: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isADXBiggerLast", isADXBiggerLast, ignoreFalseConditions, separator) +
|
|
ToXString("isADXLesserLast", isADXLesserLast, ignoreFalseConditions, separator) +
|
|
ToXString("isADXOverThreshold", isADXOverThreshold, ignoreFalseConditions, separator) +
|
|
ToXString("isADXUnderThreshold", isADXUnderThreshold, ignoreFalseConditions, separator) +
|
|
ToXString("isDXPBiggerThanDXN", isDXPBiggerThanDXN, ignoreFalseConditions, separator) +
|
|
ToXString("isDXNBiggerThanDXP", isDXNBiggerThanDXP, ignoreFalseConditions, separator) +
|
|
ToXString("isADXBullish", isADXBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isADXBearish", isADXBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isADXSwitchedToBullish", isADXSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isADXSwitchedToBearish", isADXSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"RSI: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isRSIBullish", isRSIBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isRSIBearish", isRSIBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isRSISwitchedToBullish", isRSISwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isRSISwitchedToBearish", isRSISwitchedToBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isRSIOB", isRSIOB, ignoreFalseConditions, separator) +
|
|
ToXString("isRSIOS", isRSIOS, ignoreFalseConditions, separator) +
|
|
ToXString("isRSICrossedOverOB", isRSICrossedOverOB, ignoreFalseConditions, separator) +
|
|
ToXString("isRSICrossedOverOS", isRSICrossedOverOS, ignoreFalseConditions, separator) +
|
|
ToXString("isRSICrossedUnderOB", isRSICrossedUnderOB, ignoreFalseConditions, separator) +
|
|
ToXString("isRSICrossedUnderOS", isRSICrossedUnderOS, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"DELTA: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isDeltaUp", isDeltaUp, ignoreFalseConditions, separator) +
|
|
ToXString("isDeltaDown", isDeltaDown, ignoreFalseConditions, separator) +
|
|
ToXString("isDeltaBullish", isDeltaBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isDeltaBearish", isDeltaBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isDeltaSwitchedToBullish", isDeltaSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isDeltaSwitchedToBearish", isDeltaSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"VOLUME: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isVolumeBullish", isVolumeBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isVolumeBearish", isVolumeBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isVolumeSwitchedToBullish", isVolumeSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isVolumeSwitchedToBearish", isVolumeSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"SIGNAL Bar: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isSBarBullish", isSBarBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isSBarBearish", isSBarBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isSBarSwitchedToBullish", isSBarSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isSBarSwitchedToBearish", isSBarSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"XHK Signal Bar: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isHKSBarBullish", isHKSBarBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isHKSBarBearish", isHKSBarBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isHKSBarSwitchedToBullish", isHKSBarSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isHKSBarSwitchedToBearish", isHKSBarSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"Trend: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isTrendUp", isTrendUp, ignoreFalseConditions, separator) +
|
|
ToXString("isTrendDown", isTrendDown, ignoreFalseConditions, separator) +
|
|
ToXString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) +
|
|
ToXString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToXString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"Peak: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) +
|
|
ToXString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) +
|
|
ToXString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) +
|
|
//
|
|
"-----------------------" + separator +
|
|
"Vale: " + separator +
|
|
"-----------------------" + separator +
|
|
ToXString("isValeSameLast", isValeSameLast, ignoreFalseConditions, separator) +
|
|
ToXString("isValeOverLast", isValeOverLast, ignoreFalseConditions, separator) +
|
|
ToXString("isValeUnderLast", isValeUnderLast, ignoreFalseConditions, separator) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetTag() + "]" + separator +
|
|
(onlyConditions
|
|
? ""
|
|
: commonStr) +
|
|
(!includeScores
|
|
? ""
|
|
: scoresStr) +
|
|
" " + separator +
|
|
(onlyCommons
|
|
? ""
|
|
: conditionsStr) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve nique Tag Identifier ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetTag()
|
|
{
|
|
return GetTypeName(this);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XCX121XCatbHelper : public XCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Buffers ...
|
|
double kiBuffer[];
|
|
double sarBuffer[];
|
|
double atrBuffer[];
|
|
double rsiBuffer[];
|
|
double adxBuffer[];
|
|
double sHHBuffer[];
|
|
double sLLBuffer[];
|
|
double mHHBuffer[];
|
|
double mLLBuffer[];
|
|
double lHHBuffer[];
|
|
double lLLBuffer[];
|
|
double hHHBuffer[];
|
|
double hLLBuffer[];
|
|
double adxpBuffer[];
|
|
double adxnBuffer[];
|
|
double peakBuffer[];
|
|
double valeBuffer[];
|
|
double deltaBuffer[];
|
|
double trendBuffer[];
|
|
double hkLowBuffer[];
|
|
double hkOpenBuffer[];
|
|
double hkHighBuffer[];
|
|
double hkCloseBuffer[];
|
|
double kiStateBuffer[];
|
|
double sarStateBuffer[];
|
|
double atrUpperBuffer[];
|
|
double atrLowerBuffer[];
|
|
double sBarOpenBuffer[];
|
|
double sBarCloseBuffer[];
|
|
double trendStateBuffer[];
|
|
double hkSBarOpenBuffer[];
|
|
double peakGoldenBuffer[];
|
|
double valeGoldenBuffer[];
|
|
double hkSBarCloseBuffer[];
|
|
double deltaSignalBuffer[];
|
|
double bullishVolumeBuffer[];
|
|
double bearishVolumeBuffer[];
|
|
double bullishVolumeSignalBuffer[];
|
|
double bearishVolumeSignalBuffer[];
|
|
|
|
//
|
|
// Market Shift ...
|
|
|
|
//
|
|
// SAR ...
|
|
XDirectionShift lastSarBullish;
|
|
XDirectionShift lastSarBearish;
|
|
|
|
//
|
|
// TREND ...
|
|
XDirectionShift lastTrendBullish;
|
|
XDirectionShift lastTrendBearish;
|
|
|
|
//
|
|
// DELTA ...
|
|
XDirectionShift lastDeltaBullish;
|
|
XDirectionShift lastDeltaBearish;
|
|
|
|
//
|
|
// VOLUME ...
|
|
XDirectionShift lastVolumeBullish;
|
|
XDirectionShift lastVolumeBearish;
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
XDirectionShift lastSignalBarBullish;
|
|
XDirectionShift lastSignalBarBearish;
|
|
|
|
//
|
|
// XHK SIGNAL Bar ...
|
|
XDirectionShift lastHKSignalBarBullish;
|
|
XDirectionShift lastHKSignalBarBearish;
|
|
|
|
//
|
|
// Constructors ...
|
|
XCX121XCatbHelper()
|
|
: XCBaseHelper(_Symbol, _Period)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XCX121XCatbHelper()
|
|
{
|
|
//
|
|
mInputs.Clean();
|
|
|
|
//
|
|
Clean(sarBuffer);
|
|
Clean(atrBuffer);
|
|
Clean(rsiBuffer);
|
|
Clean(adxBuffer);
|
|
Clean(sHHBuffer);
|
|
Clean(sLLBuffer);
|
|
Clean(mHHBuffer);
|
|
Clean(mLLBuffer);
|
|
Clean(lHHBuffer);
|
|
Clean(lLLBuffer);
|
|
Clean(hHHBuffer);
|
|
Clean(hLLBuffer);
|
|
Clean(adxpBuffer);
|
|
Clean(adxnBuffer);
|
|
Clean(peakBuffer);
|
|
Clean(valeBuffer);
|
|
Clean(deltaBuffer);
|
|
Clean(trendBuffer);
|
|
Clean(hkLowBuffer);
|
|
Clean(hkOpenBuffer);
|
|
Clean(hkHighBuffer);
|
|
Clean(hkCloseBuffer);
|
|
Clean(sarStateBuffer);
|
|
Clean(atrUpperBuffer);
|
|
Clean(atrLowerBuffer);
|
|
Clean(sBarOpenBuffer);
|
|
Clean(sBarCloseBuffer);
|
|
Clean(trendStateBuffer);
|
|
Clean(hkSBarOpenBuffer);
|
|
Clean(peakGoldenBuffer);
|
|
Clean(valeGoldenBuffer);
|
|
Clean(hkSBarCloseBuffer);
|
|
Clean(deltaSignalBuffer);
|
|
Clean(bullishVolumeBuffer);
|
|
Clean(bearishVolumeBuffer);
|
|
Clean(bullishVolumeSignalBuffer);
|
|
Clean(bearishVolumeSignalBuffer);
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
bool Init(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period, // Trading Period
|
|
X121XCatbInputs &inputs // Inputs
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
ArraySetAsSeries(kiBuffer, true);
|
|
ArraySetAsSeries(sarBuffer, true);
|
|
ArraySetAsSeries(atrBuffer, true);
|
|
ArraySetAsSeries(rsiBuffer, true);
|
|
ArraySetAsSeries(adxBuffer, true);
|
|
ArraySetAsSeries(sHHBuffer, true);
|
|
ArraySetAsSeries(sLLBuffer, true);
|
|
ArraySetAsSeries(mHHBuffer, true);
|
|
ArraySetAsSeries(mLLBuffer, true);
|
|
ArraySetAsSeries(lHHBuffer, true);
|
|
ArraySetAsSeries(lLLBuffer, true);
|
|
ArraySetAsSeries(hHHBuffer, true);
|
|
ArraySetAsSeries(hLLBuffer, true);
|
|
ArraySetAsSeries(adxpBuffer, true);
|
|
ArraySetAsSeries(adxnBuffer, true);
|
|
ArraySetAsSeries(peakBuffer, true);
|
|
ArraySetAsSeries(valeBuffer, true);
|
|
ArraySetAsSeries(deltaBuffer, true);
|
|
ArraySetAsSeries(trendBuffer, true);
|
|
ArraySetAsSeries(hkLowBuffer, true);
|
|
ArraySetAsSeries(hkOpenBuffer, true);
|
|
ArraySetAsSeries(hkHighBuffer, true);
|
|
ArraySetAsSeries(hkCloseBuffer, true);
|
|
ArraySetAsSeries(kiStateBuffer, true);
|
|
ArraySetAsSeries(sarStateBuffer, true);
|
|
ArraySetAsSeries(atrUpperBuffer, true);
|
|
ArraySetAsSeries(atrLowerBuffer, true);
|
|
ArraySetAsSeries(sBarOpenBuffer, true);
|
|
ArraySetAsSeries(sBarCloseBuffer, true);
|
|
ArraySetAsSeries(trendStateBuffer, true);
|
|
ArraySetAsSeries(hkSBarOpenBuffer, true);
|
|
ArraySetAsSeries(peakGoldenBuffer, true);
|
|
ArraySetAsSeries(valeGoldenBuffer, true);
|
|
ArraySetAsSeries(hkSBarCloseBuffer, true);
|
|
ArraySetAsSeries(deltaSignalBuffer, true);
|
|
ArraySetAsSeries(bullishVolumeBuffer, true);
|
|
ArraySetAsSeries(bearishVolumeBuffer, true);
|
|
ArraySetAsSeries(bullishVolumeSignalBuffer, true);
|
|
ArraySetAsSeries(bearishVolumeSignalBuffer, true);
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.x121.xcatb",
|
|
"", // Market ...
|
|
mInputs.scMethod,
|
|
mInputs.scPeriod,
|
|
mInputs.mcMethod,
|
|
mInputs.mcPeriod,
|
|
mInputs.lcMethod,
|
|
mInputs.lcPeriod,
|
|
mInputs.hcMethod,
|
|
mInputs.hcPeriod,
|
|
mInputs.appliedCycle,
|
|
"", // Presentation ...
|
|
mInputs.showBars,
|
|
mInputs.showKI,
|
|
mInputs.showPV,
|
|
mInputs.showPVGolden,
|
|
mInputs.showSar,
|
|
mInputs.showTrend,
|
|
mInputs.showATRBand,
|
|
mInputs.showSignalBars,
|
|
mInputs.showHKSignalBars,
|
|
mInputs.startCalculationForLastBars
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void Check(int barIndex = 0)
|
|
{
|
|
//
|
|
bool has = false;
|
|
|
|
//
|
|
bool isBullish = false;
|
|
bool isBearish = false;
|
|
|
|
//
|
|
barIndex = NormalizeInt(barIndex, 0);
|
|
|
|
//
|
|
X121XCatbConditions conditions;
|
|
has = GetConditions(
|
|
conditions,
|
|
barIndex,
|
|
4 //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
conditions.Clean();
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Checking Shifts ...
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
isBullish = conditions.isSarSwitchedToBullish;
|
|
isBearish = conditions.isSarSwitchedToBearish;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastSarBullish.IsValid()
|
|
? true
|
|
: lastSarBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastSarBullish.Clean();
|
|
|
|
//
|
|
lastSarBullish.type = "SAR";
|
|
lastSarBullish.symbol = conditions.symbol;
|
|
lastSarBullish.period = conditions.period;
|
|
lastSarBullish.at = conditions.bars[1].time;
|
|
lastSarBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastSarBullish.after = conditions.sarBuffer[1];
|
|
lastSarBullish.before = conditions.sarBuffer[2];
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastSarBearish.IsValid()
|
|
? true
|
|
: lastSarBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastSarBearish.Clean();
|
|
|
|
//
|
|
lastSarBearish.type = "SAR";
|
|
lastSarBearish.symbol = conditions.symbol;
|
|
lastSarBearish.period = conditions.period;
|
|
lastSarBearish.at = conditions.bars[1].time;
|
|
lastSarBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastSarBearish.after = conditions.sarBuffer[1];
|
|
lastSarBearish.before = conditions.sarBuffer[2];
|
|
}
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
isBullish = conditions.isTrendSwitchedToBullish;
|
|
isBearish = conditions.isTrendSwitchedToBearish;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastTrendBullish.IsValid()
|
|
? true
|
|
: lastTrendBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastTrendBullish.Clean();
|
|
|
|
//
|
|
lastTrendBullish.type = "TREND";
|
|
lastTrendBullish.symbol = conditions.symbol;
|
|
lastTrendBullish.period = conditions.period;
|
|
lastTrendBullish.at = conditions.bars[1].time;
|
|
lastTrendBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastTrendBullish.after = conditions.trendBuffer[1];
|
|
lastTrendBullish.before = conditions.trendBuffer[2];
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastTrendBearish.IsValid()
|
|
? true
|
|
: lastTrendBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastTrendBearish.Clean();
|
|
|
|
//
|
|
lastTrendBearish.type = "TREND";
|
|
lastTrendBearish.symbol = conditions.symbol;
|
|
lastTrendBearish.period = conditions.period;
|
|
lastTrendBearish.at = conditions.bars[1].time;
|
|
lastTrendBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastTrendBearish.after = conditions.trendBuffer[1];
|
|
lastTrendBearish.before = conditions.trendBuffer[2];
|
|
}
|
|
}
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Delta is Up ...
|
|
conditions.deltaBuffer[1] > conditions.deltaBuffer[2] &&
|
|
//
|
|
// Delta Signal is Up ...
|
|
conditions.deltaSignalBuffer[1] > conditions.deltaSignalBuffer[2] &&
|
|
//
|
|
// Delta Crossed Over Delta ...
|
|
conditions.deltaBuffer[1] > conditions.deltaSignalBuffer[1] &&
|
|
conditions.deltaBuffer[2] <= conditions.deltaSignalBuffer[2]
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Delta is Down ...
|
|
conditions.deltaBuffer[1] < conditions.deltaBuffer[2] &&
|
|
//
|
|
// Delta Signal is Down ...
|
|
conditions.deltaSignalBuffer[1] < conditions.deltaSignalBuffer[2] &&
|
|
//
|
|
// Delta Crossed Under Delta Signal ...
|
|
conditions.deltaBuffer[1] < conditions.deltaSignalBuffer[1] &&
|
|
conditions.deltaBuffer[2] >= conditions.deltaSignalBuffer[2]
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastDeltaBullish.IsValid()
|
|
? true
|
|
: lastDeltaBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastDeltaBullish.Clean();
|
|
|
|
//
|
|
lastDeltaBullish.type = "DELTA";
|
|
lastDeltaBullish.symbol = conditions.symbol;
|
|
lastDeltaBullish.period = conditions.period;
|
|
lastDeltaBullish.at = conditions.bars[1].time;
|
|
lastDeltaBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastDeltaBullish.after = conditions.bars[1].close;
|
|
lastDeltaBullish.before = conditions.bars[2].close;
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastDeltaBearish.IsValid()
|
|
? true
|
|
: lastDeltaBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastDeltaBearish.Clean();
|
|
|
|
//
|
|
lastDeltaBearish.type = "DELTA";
|
|
lastDeltaBearish.symbol = conditions.symbol;
|
|
lastDeltaBearish.period = conditions.period;
|
|
lastDeltaBearish.at = conditions.bars[1].time;
|
|
lastDeltaBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastDeltaBearish.after = conditions.bars[1].close;
|
|
lastDeltaBearish.before = conditions.bars[2].close;
|
|
}
|
|
}
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Volume is Up ...
|
|
conditions.bullishVolumeBuffer[1] > conditions.bullishVolumeBuffer[2] &&
|
|
//
|
|
// Volume Signal is Up ...
|
|
conditions.bullishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[2] &&
|
|
//
|
|
// Volume Signals Crossed Over ...
|
|
conditions.bullishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[1] &&
|
|
conditions.bullishVolumeSignalBuffer[2] <= conditions.bearishVolumeSignalBuffer[2]
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Volume is Up ...
|
|
conditions.bearishVolumeBuffer[1] > conditions.bearishVolumeBuffer[2] &&
|
|
//
|
|
// Volume Signal is Up ...
|
|
conditions.bearishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[2] &&
|
|
//
|
|
// Volume Signals Crossed Over ...
|
|
conditions.bearishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[1] &&
|
|
conditions.bearishVolumeSignalBuffer[2] <= conditions.bullishVolumeSignalBuffer[2]
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastVolumeBullish.IsValid()
|
|
? true
|
|
: lastVolumeBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastVolumeBullish.Clean();
|
|
|
|
//
|
|
lastVolumeBullish.type = "VOLUME";
|
|
lastVolumeBullish.symbol = conditions.symbol;
|
|
lastVolumeBullish.period = conditions.period;
|
|
lastVolumeBullish.at = conditions.bars[1].time;
|
|
lastVolumeBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastVolumeBullish.after = conditions.bars[1].close;
|
|
lastVolumeBullish.before = conditions.bars[2].close;
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastVolumeBearish.IsValid()
|
|
? true
|
|
: lastVolumeBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastVolumeBearish.Clean();
|
|
|
|
//
|
|
lastVolumeBearish.type = "VOLUME";
|
|
lastVolumeBearish.symbol = conditions.symbol;
|
|
lastVolumeBearish.period = conditions.period;
|
|
lastVolumeBearish.at = conditions.bars[1].time;
|
|
lastVolumeBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastVolumeBearish.after = conditions.bars[1].close;
|
|
lastVolumeBearish.before = conditions.bars[2].close;
|
|
}
|
|
}
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
isBullish = conditions.isSBarSwitchedToBullish;
|
|
isBearish = conditions.isSBarSwitchedToBearish;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastSignalBarBullish.IsValid()
|
|
? true
|
|
: lastSignalBarBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastSignalBarBullish.Clean();
|
|
|
|
//
|
|
lastSignalBarBullish.type = "SIGNALBAR";
|
|
lastSignalBarBullish.symbol = conditions.symbol;
|
|
lastSignalBarBullish.period = conditions.period;
|
|
lastSignalBarBullish.at = conditions.bars[1].time;
|
|
lastSignalBarBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastSignalBarBullish.after = conditions.sBarCloseBuffer[1];
|
|
lastSignalBarBullish.before = conditions.sBarCloseBuffer[2];
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastSignalBarBearish.IsValid()
|
|
? true
|
|
: lastSignalBarBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastSignalBarBearish.Clean();
|
|
|
|
//
|
|
lastSignalBarBearish.type = "SIGNALBAR";
|
|
lastSignalBarBearish.symbol = conditions.symbol;
|
|
lastSignalBarBearish.period = conditions.period;
|
|
lastSignalBarBearish.at = conditions.bars[1].time;
|
|
lastSignalBarBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastSignalBarBearish.after = conditions.sBarCloseBuffer[1];
|
|
lastSignalBarBearish.before = conditions.sBarCloseBuffer[2];
|
|
}
|
|
}
|
|
|
|
//
|
|
// HKSIGNAL Bar ...
|
|
|
|
//
|
|
isBullish = conditions.isHKSBarSwitchedToBullish;
|
|
isBearish = conditions.isHKSBarSwitchedToBearish;
|
|
|
|
//
|
|
has = isBullish ||
|
|
isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
// Bullish ...
|
|
has =
|
|
isBullish &&
|
|
(!lastHKSignalBarBullish.IsValid()
|
|
? true
|
|
: lastHKSignalBarBullish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastHKSignalBarBullish.Clean();
|
|
|
|
//
|
|
lastHKSignalBarBullish.type = "HKSIGNALBAR";
|
|
lastHKSignalBarBullish.symbol = conditions.symbol;
|
|
lastHKSignalBarBullish.period = conditions.period;
|
|
lastHKSignalBarBullish.at = conditions.bars[1].time;
|
|
lastHKSignalBarBullish.shiftTo = X_DIRECTION_BULLISH;
|
|
lastHKSignalBarBullish.after = conditions.hkSBarCloseBuffer[1];
|
|
lastHKSignalBarBullish.before = conditions.hkSBarCloseBuffer[2];
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
has =
|
|
isBearish &&
|
|
(!lastHKSignalBarBearish.IsValid()
|
|
? true
|
|
: lastHKSignalBarBearish.at < conditions.bars[1].time);
|
|
if (has)
|
|
{
|
|
//
|
|
lastHKSignalBarBearish.Clean();
|
|
|
|
//
|
|
lastHKSignalBarBearish.type = "HKSIGNALBAR";
|
|
lastHKSignalBarBearish.symbol = conditions.symbol;
|
|
lastHKSignalBarBearish.period = conditions.period;
|
|
lastHKSignalBarBearish.at = conditions.bars[1].time;
|
|
lastHKSignalBarBearish.shiftTo = X_DIRECTION_BEARISH;
|
|
lastHKSignalBarBearish.after = conditions.hkSBarCloseBuffer[1];
|
|
lastHKSignalBarBearish.before = conditions.hkSBarCloseBuffer[2];
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
conditions.Clean();
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
|
|
//
|
|
X121XCatbInputs GetInputs()
|
|
{
|
|
return mInputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
X121XCatbInputs &inputs // Configs
|
|
)
|
|
{
|
|
//
|
|
return Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
inputs
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Readers ...
|
|
|
|
//
|
|
// Readers ...
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
double GetKI(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(kiBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return kiBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyKI(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
kiBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// KI State ...
|
|
|
|
//
|
|
double GetKIState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(kiStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return kiStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyKIState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
kiStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
double GetSar(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sarBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sarBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySar(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sarBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SAR State ...
|
|
|
|
//
|
|
double GetSarState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sarStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sarStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySarState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sarStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
double GetPeak(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(peakBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return peakBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyPeak(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
peakBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
double GetVale(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(valeBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return valeBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyVale(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
valeBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// PEAK Golden ...
|
|
|
|
//
|
|
double GetPeakGolden(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(peakGoldenBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return peakGoldenBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyPeakGolden(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
peakGoldenBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// VALE Golden ...
|
|
|
|
//
|
|
double GetValeGolden(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(valeGoldenBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return valeGoldenBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyValeGolden(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
valeGoldenBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ATR ...
|
|
|
|
//
|
|
double GetATR(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(atrBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return atrBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyATR(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
atrBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ATR Band Upper ...
|
|
|
|
//
|
|
double GetATRUpper(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(atrUpperBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return atrUpperBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyATRUpper(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
atrUpperBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ATR Band Lower ...
|
|
|
|
//
|
|
double GetATRLower(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(atrLowerBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return atrLowerBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyATRLower(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
atrLowerBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
double GetTrend(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(trendBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return trendBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyTrend(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
trendBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// TREND State ...
|
|
|
|
//
|
|
double GetTrendState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(trendStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return trendStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyTrendState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
trendStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
// OPEN ...
|
|
|
|
//
|
|
double GetSBarOpen(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sBarOpenBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sBarOpenBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySBarOpen(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sBarOpenBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// CLOSE ...
|
|
|
|
//
|
|
double GetSBarClose(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sBarCloseBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sBarCloseBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySBarClose(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sBarCloseBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// XHK SIGNAL Bar ...
|
|
|
|
//
|
|
// OPEN ...
|
|
|
|
//
|
|
double GetHKSBarOpen(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkSBarOpenBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkSBarOpenBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKSBarOpen(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkSBarOpenBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// CLOSE ...
|
|
|
|
//
|
|
double GetHKSBarClose(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkSBarCloseBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkSBarCloseBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKSBarClose(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkSBarCloseBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// CYCLES Range ...
|
|
|
|
//
|
|
// SHORT ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetSHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetSLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(sLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return sLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
sLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// MEDIUM ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetMHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(mHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return mHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyMHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
mHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetMLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(mLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return mLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyMLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
mLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// LONG ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetLHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(lHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return lHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyLHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
lHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetLLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(lLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return lLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyLLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
lLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// HIND ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetHHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetHLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
double GetADX(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(adxBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return adxBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyADX(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
adxBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ADXP ...
|
|
|
|
//
|
|
double GetADXP(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(adxpBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return adxpBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyADXP(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
adxpBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// ADXN ...
|
|
|
|
//
|
|
double GetADXN(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(adxnBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return adxnBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyADXN(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
adxnBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
double GetDelta(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(deltaBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return deltaBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyDelta(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
deltaBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// DELTA Signal ...
|
|
|
|
//
|
|
double GetDeltaSignal(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(deltaSignalBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return deltaSignalBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyDeltaSignal(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
deltaSignalBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
// Bullish ...
|
|
|
|
//
|
|
double GetBullishVolume(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(bullishVolumeBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return bullishVolumeBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyBullishVolume(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
bullishVolumeBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
|
|
//
|
|
double GetBearishVolume(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(bearishVolumeBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return bearishVolumeBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyBearishVolume(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
bearishVolumeBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// VOLUME Signal ...
|
|
|
|
//
|
|
// Bullish ...
|
|
|
|
//
|
|
double GetBullishVolumeSignal(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(bullishVolumeSignalBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return bullishVolumeSignalBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyBullishVolumeSignal(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
bullishVolumeSignalBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bearish ...
|
|
|
|
//
|
|
double GetBearishVolumeSignal(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(bearishVolumeSignalBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return bearishVolumeSignalBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyBearishVolumeSignal(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
bearishVolumeSignalBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// XHK ...
|
|
|
|
//
|
|
// Open ...
|
|
|
|
//
|
|
double GetHKOpen(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkOpenBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkOpenBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKOpen(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkOpenBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// High ...
|
|
|
|
//
|
|
double GetHKHigh(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkHighBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkHighBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKHigh(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkHighBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Low ...
|
|
|
|
//
|
|
double GetHKLow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkLowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkLowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKLow(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkLowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Close ...
|
|
|
|
//
|
|
double GetHKClose(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(hkCloseBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hkCloseBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyHKClose(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
hkCloseBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
double GetRSI(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(rsiBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return rsiBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyRSI(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
rsiBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
void Update(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
Calculate(barIndex);
|
|
}
|
|
|
|
//
|
|
void Free() override
|
|
{
|
|
Cleanup(10);
|
|
}
|
|
|
|
//
|
|
bool GetConditions(
|
|
X121XCatbConditions &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();
|
|
|
|
//
|
|
// Filling Bars ...
|
|
int barsCount = GetBars(
|
|
conditions.bars,
|
|
mSymbol,
|
|
mPeriod,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
result = barsCount == loopback;
|
|
if (!result)
|
|
{
|
|
//
|
|
conditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int zIDX = 0;
|
|
int cIDX = 1;
|
|
int pIDX = cIDX + 1;
|
|
int p2IDX = pIDX + 1;
|
|
int p3IDX = p2IDX + 1;
|
|
int p4IDX = p3IDX + 1;
|
|
|
|
//
|
|
conditions.to = conditions.bars[0].time;
|
|
conditions.from = conditions.bars[ArraySize(conditions.bars) - 1].time;
|
|
|
|
//
|
|
int zIndex = barIndex;
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
CopyKI(
|
|
zIndex,
|
|
loopback,
|
|
conditions.kiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyKIState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.kiStateBuffer //
|
|
);
|
|
|
|
CopySar(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sarBuffer //
|
|
);
|
|
|
|
//
|
|
CopySarState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sarStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyPeak(
|
|
zIndex,
|
|
loopback,
|
|
conditions.peakBuffer //
|
|
);
|
|
|
|
//
|
|
CopyVale(
|
|
zIndex,
|
|
loopback,
|
|
conditions.valeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyPeakGolden(
|
|
zIndex,
|
|
loopback,
|
|
conditions.peakGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyValeGolden(
|
|
zIndex,
|
|
loopback,
|
|
conditions.valeGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyATR(
|
|
zIndex,
|
|
loopback,
|
|
conditions.atrBuffer //
|
|
);
|
|
|
|
//
|
|
CopyATRUpper(
|
|
zIndex,
|
|
loopback,
|
|
conditions.atrUpperBuffer //
|
|
);
|
|
|
|
//
|
|
CopyATRLower(
|
|
zIndex,
|
|
loopback,
|
|
conditions.atrLowerBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTrend(
|
|
zIndex,
|
|
loopback,
|
|
conditions.trendBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTrendState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.trendStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopySBarOpen(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sBarOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopySBarClose(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sBarCloseBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKSBarOpen(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkSBarOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKSBarClose(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkSBarCloseBuffer //
|
|
);
|
|
|
|
//
|
|
CopySHH(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopySLL(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyMHH(
|
|
zIndex,
|
|
loopback,
|
|
conditions.mHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyMLL(
|
|
zIndex,
|
|
loopback,
|
|
conditions.mLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyLHH(
|
|
zIndex,
|
|
loopback,
|
|
conditions.lHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyLLL(
|
|
zIndex,
|
|
loopback,
|
|
conditions.lLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHHH(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHLL(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyADX(
|
|
zIndex,
|
|
loopback,
|
|
conditions.adxBuffer //
|
|
);
|
|
|
|
//
|
|
CopyADXP(
|
|
zIndex,
|
|
loopback,
|
|
conditions.adxpBuffer //
|
|
);
|
|
|
|
//
|
|
CopyADXN(
|
|
zIndex,
|
|
loopback,
|
|
conditions.adxnBuffer //
|
|
);
|
|
|
|
//
|
|
CopyDelta(
|
|
zIndex,
|
|
loopback,
|
|
conditions.deltaBuffer //
|
|
);
|
|
|
|
//
|
|
CopyDeltaSignal(
|
|
zIndex,
|
|
loopback,
|
|
conditions.deltaSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBullishVolume(
|
|
zIndex,
|
|
loopback,
|
|
conditions.bullishVolumeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBearishVolume(
|
|
zIndex,
|
|
loopback,
|
|
conditions.bearishVolumeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBullishVolumeSignal(
|
|
zIndex,
|
|
loopback,
|
|
conditions.bullishVolumeSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBearishVolumeSignal(
|
|
zIndex,
|
|
loopback,
|
|
conditions.bearishVolumeSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKOpen(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKHigh(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkHighBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKLow(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkLowBuffer //
|
|
);
|
|
|
|
//
|
|
CopyHKClose(
|
|
zIndex,
|
|
loopback,
|
|
conditions.hkCloseBuffer //
|
|
);
|
|
|
|
//
|
|
CopyRSI(
|
|
zIndex,
|
|
loopback,
|
|
conditions.rsiBuffer //
|
|
);
|
|
|
|
//
|
|
// Calculate ...
|
|
|
|
//
|
|
double _rsiOBLevel = mInputs.rsiOBLevel; // Over Bought Level
|
|
double _rsiOSLevel = mInputs.rsiOSLevel; // Over Sold Level
|
|
double _adxThreshold = mInputs.adxThreshold; // Big Movement Threshold
|
|
|
|
//
|
|
// Reading Values ...
|
|
|
|
//
|
|
// ATR Upper ...
|
|
double zATRUpper = conditions.atrUpperBuffer[zIDX];
|
|
double cATRUpper = conditions.atrUpperBuffer[cIDX];
|
|
double pATRUpper = conditions.atrUpperBuffer[pIDX];
|
|
double p2ATRUpper = conditions.atrUpperBuffer[p2IDX];
|
|
double p3ATRUpper = conditions.atrUpperBuffer[p3IDX];
|
|
|
|
//
|
|
// ATR Lower ...
|
|
double zATRLower = conditions.atrLowerBuffer[zIDX];
|
|
double cATRLower = conditions.atrLowerBuffer[cIDX];
|
|
double pATRLower = conditions.atrLowerBuffer[pIDX];
|
|
double p2ATRLower = conditions.atrLowerBuffer[p2IDX];
|
|
double p3ATRLower = conditions.atrLowerBuffer[p3IDX];
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
double zKI = conditions.kiBuffer[zIDX];
|
|
double cKI = conditions.kiBuffer[cIDX];
|
|
double pKI = conditions.kiBuffer[pIDX];
|
|
double p2KI = conditions.kiBuffer[p2IDX];
|
|
double p3KI = conditions.kiBuffer[p3IDX];
|
|
|
|
//
|
|
double zKIState = conditions.kiStateBuffer[zIDX];
|
|
double cKIState = conditions.kiStateBuffer[cIDX];
|
|
double pKIState = conditions.kiStateBuffer[pIDX];
|
|
double p2KIState = conditions.kiStateBuffer[p2IDX];
|
|
double p3KIState = conditions.kiStateBuffer[p3IDX];
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
double zSAR = conditions.sarBuffer[zIDX];
|
|
double cSar = conditions.sarBuffer[cIDX];
|
|
double pSAR = conditions.sarBuffer[pIDX];
|
|
double p2SAR = conditions.sarBuffer[p2IDX];
|
|
double p3SAR = conditions.sarBuffer[p3IDX];
|
|
|
|
//
|
|
double zSarState = conditions.sarStateBuffer[zIDX];
|
|
double cSarState = conditions.sarStateBuffer[cIDX];
|
|
double pSarState = conditions.sarStateBuffer[pIDX];
|
|
double p2SarState = conditions.sarStateBuffer[p2IDX];
|
|
double p3SarState = conditions.sarStateBuffer[p3IDX];
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
double zADX = conditions.adxBuffer[zIDX];
|
|
double cADX = conditions.adxBuffer[cIDX];
|
|
double pADX = conditions.adxBuffer[pIDX];
|
|
double p2ADX = conditions.adxBuffer[p2IDX];
|
|
double p3ADX = conditions.adxBuffer[p3IDX];
|
|
|
|
//
|
|
// ADX P ...
|
|
|
|
//
|
|
double zADXP = conditions.adxpBuffer[zIDX];
|
|
double cADXP = conditions.adxpBuffer[cIDX];
|
|
double pADXP = conditions.adxpBuffer[pIDX];
|
|
double p2ADXP = conditions.adxpBuffer[p2IDX];
|
|
double p3ADXP = conditions.adxpBuffer[p3IDX];
|
|
|
|
//
|
|
// ADX N ...
|
|
|
|
//
|
|
double zADXN = conditions.adxnBuffer[zIDX];
|
|
double cADXN = conditions.adxnBuffer[cIDX];
|
|
double pADXN = conditions.adxnBuffer[pIDX];
|
|
double p2ADXN = conditions.adxnBuffer[p2IDX];
|
|
double p3ADXN = conditions.adxnBuffer[p3IDX];
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
double zRSI = conditions.rsiBuffer[zIDX];
|
|
double cRSI = conditions.rsiBuffer[cIDX];
|
|
double pRSI = conditions.rsiBuffer[pIDX];
|
|
double p2RSI = conditions.rsiBuffer[p2IDX];
|
|
double p3RSI = conditions.rsiBuffer[p3IDX];
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
double zSBarO = conditions.sBarOpenBuffer[zIDX];
|
|
double cSBarO = conditions.sBarOpenBuffer[cIDX];
|
|
double pSBarO = conditions.sBarOpenBuffer[pIDX];
|
|
double p2SBarO = conditions.sBarOpenBuffer[p2IDX];
|
|
double p3SBarO = conditions.sBarOpenBuffer[p3IDX];
|
|
|
|
//
|
|
double zSBarC = conditions.sBarCloseBuffer[zIDX];
|
|
double cSBarC = conditions.sBarCloseBuffer[cIDX];
|
|
double pSBarC = conditions.sBarCloseBuffer[pIDX];
|
|
double p2SBarC = conditions.sBarCloseBuffer[p2IDX];
|
|
double p3SBarC = conditions.sBarCloseBuffer[p3IDX];
|
|
|
|
//
|
|
// XHK SIGNAL Bar ...
|
|
|
|
//
|
|
double zHKSBarO = conditions.hkSBarOpenBuffer[zIDX];
|
|
double cHKSBarO = conditions.hkSBarOpenBuffer[cIDX];
|
|
double pHKSBarO = conditions.hkSBarOpenBuffer[pIDX];
|
|
double p2HKSBarO = conditions.hkSBarOpenBuffer[p2IDX];
|
|
double p3HKSBarO = conditions.hkSBarOpenBuffer[p3IDX];
|
|
|
|
//
|
|
double zHKSBarC = conditions.hkSBarCloseBuffer[zIDX];
|
|
double cHKSBarC = conditions.hkSBarCloseBuffer[cIDX];
|
|
double pHKSBarC = conditions.hkSBarCloseBuffer[pIDX];
|
|
double p2HKSBarC = conditions.hkSBarCloseBuffer[p2IDX];
|
|
double p3HKSBarC = conditions.hkSBarCloseBuffer[p3IDX];
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
double zTrend = conditions.trendBuffer[zIDX];
|
|
double cTrend = conditions.trendBuffer[cIDX];
|
|
double pTrend = conditions.trendBuffer[pIDX];
|
|
double p2Trend = conditions.trendBuffer[p2IDX];
|
|
double p3Trend = conditions.trendBuffer[p3IDX];
|
|
|
|
//
|
|
double zTrendState = conditions.trendStateBuffer[zIDX];
|
|
double cTrendState = conditions.trendStateBuffer[cIDX];
|
|
double pTrendState = conditions.trendStateBuffer[pIDX];
|
|
double p2TrendState = conditions.trendStateBuffer[p2IDX];
|
|
double p3TrendState = conditions.trendStateBuffer[p3IDX];
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
double zPEAK = conditions.peakBuffer[zIDX];
|
|
double cPEAK = conditions.peakBuffer[cIDX];
|
|
double pPEAK = conditions.peakBuffer[pIDX];
|
|
double p2PEAK = conditions.peakBuffer[p2IDX];
|
|
double p3PEAK = conditions.peakBuffer[p3IDX];
|
|
|
|
//
|
|
double zVALE = conditions.valeBuffer[zIDX];
|
|
double cVALE = conditions.valeBuffer[cIDX];
|
|
double pVALE = conditions.valeBuffer[pIDX];
|
|
double p2VALE = conditions.valeBuffer[p2IDX];
|
|
double p3VALE = conditions.valeBuffer[p3IDX];
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
double zDelta = conditions.deltaBuffer[zIDX];
|
|
double cDelta = conditions.deltaBuffer[cIDX];
|
|
double pDelta = conditions.deltaBuffer[pIDX];
|
|
double p2Delta = conditions.deltaBuffer[p2IDX];
|
|
double p3Delta = conditions.deltaBuffer[p3IDX];
|
|
|
|
//
|
|
double zDeltaSignal = conditions.deltaSignalBuffer[zIDX];
|
|
double cDeltaSignal = conditions.deltaSignalBuffer[cIDX];
|
|
double pDeltaSignal = conditions.deltaSignalBuffer[pIDX];
|
|
double p2DeltaSignal = conditions.deltaSignalBuffer[p2IDX];
|
|
double p3DeltaSignal = conditions.deltaSignalBuffer[p3IDX];
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
double zBullishVolume = conditions.bullishVolumeBuffer[zIDX];
|
|
double cBullishVolume = conditions.bullishVolumeBuffer[cIDX];
|
|
double pBullishVolume = conditions.bullishVolumeBuffer[pIDX];
|
|
double p2BullishVolume = conditions.bullishVolumeBuffer[p2IDX];
|
|
double p3BullishVolume = conditions.bullishVolumeBuffer[p3IDX];
|
|
|
|
//
|
|
double zBearishVolume = conditions.bearishVolumeBuffer[zIDX];
|
|
double cBearishVolume = conditions.bearishVolumeBuffer[cIDX];
|
|
double pBearishVolume = conditions.bearishVolumeBuffer[pIDX];
|
|
double p2BearishVolume = conditions.bearishVolumeBuffer[p2IDX];
|
|
double p3BearishVolume = conditions.bearishVolumeBuffer[p3IDX];
|
|
|
|
//
|
|
double zBullishVolumeSignal = conditions.bullishVolumeSignalBuffer[zIDX];
|
|
double cBullishVolumeSignal = conditions.bullishVolumeSignalBuffer[cIDX];
|
|
double pBullishVolumeSignal = conditions.bullishVolumeSignalBuffer[pIDX];
|
|
double p2BullishVolumeSignal = conditions.bullishVolumeSignalBuffer[p2IDX];
|
|
double p3BullishVolumeSignal = conditions.bullishVolumeSignalBuffer[p3IDX];
|
|
|
|
//
|
|
double zBearishVolumeSignal = conditions.bearishVolumeSignalBuffer[zIDX];
|
|
double cBearishVolumeSignal = conditions.bearishVolumeSignalBuffer[cIDX];
|
|
double pBearishVolumeSignal = conditions.bearishVolumeSignalBuffer[pIDX];
|
|
double p2BearishVolumeSignal = conditions.bearishVolumeSignalBuffer[p2IDX];
|
|
double p3BearishVolumeSignal = conditions.bearishVolumeSignalBuffer[p3IDX];
|
|
|
|
//
|
|
// ATR Band ...
|
|
|
|
//
|
|
bool isATRUp =
|
|
cATRUpper > pATRUpper &&
|
|
cATRLower > pATRLower;
|
|
bool isATRDown =
|
|
cATRUpper < pATRUpper &&
|
|
cATRLower < pATRLower;
|
|
|
|
//
|
|
bool isClosedOverATRUpper =
|
|
conditions.bars[cIDX].close > cATRUpper;
|
|
bool isClosedUnderATRLower =
|
|
conditions.bars[cIDX].close < cATRLower;
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
bool isKIUp = cKI > pKI;
|
|
bool isKIDown = cKI < pKI;
|
|
|
|
//
|
|
bool isKIBullish = cKIState > 0;
|
|
bool isKIBearish = cKIState < 0;
|
|
|
|
//
|
|
bool isKISameAsLast = cKI == pKI;
|
|
|
|
//
|
|
bool isKISwitchedToBullish =
|
|
cKIState > 0 &&
|
|
pKIState <= 0;
|
|
|
|
//
|
|
bool isKISwitchedToBearish =
|
|
cKIState < 0 &&
|
|
pKIState >= 0;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
bool isSarBullish = cSarState > 0;
|
|
bool isSarBearish = cSarState < 0;
|
|
|
|
//
|
|
bool isSarSwitchedToBullish =
|
|
cSarState > 0 &&
|
|
pSarState <= 0;
|
|
bool isSarSwitchedToBearish =
|
|
cSarState < 0 &&
|
|
pSarState >= 0;
|
|
|
|
//
|
|
// ADX ...
|
|
|
|
//
|
|
bool isADXBiggerLast =
|
|
cADX > pADX;
|
|
bool isADXLesserLast =
|
|
cADX < pADX;
|
|
|
|
//
|
|
bool isPADXBiggerLast =
|
|
pADX > p2ADX;
|
|
bool isPADXLesserLast =
|
|
pADX < p2ADX;
|
|
|
|
//
|
|
bool isADXOverThreshold =
|
|
cADX > _adxThreshold;
|
|
bool isADXUnderThreshold =
|
|
cADX < _adxThreshold;
|
|
|
|
//
|
|
bool isPADXOverThreshold =
|
|
pADX > _adxThreshold;
|
|
bool isPADXUnderThreshold =
|
|
pADX < _adxThreshold;
|
|
|
|
//
|
|
bool isDXPBiggerThanDXN =
|
|
cADXP > cADXN;
|
|
bool isDXNBiggerThanDXP =
|
|
cADXN > cADXP;
|
|
|
|
//
|
|
bool isPDXPBiggerThanDXN =
|
|
pADXP > pADXN;
|
|
bool isPDXNBiggerThanDXP =
|
|
pADXN > pADXP;
|
|
|
|
//
|
|
bool isADXBullish =
|
|
isADXBiggerLast &&
|
|
isADXOverThreshold;
|
|
bool isADXBearish =
|
|
isADXLesserLast &&
|
|
isADXUnderThreshold;
|
|
|
|
//
|
|
bool isPADXBullish =
|
|
isPADXBiggerLast &&
|
|
isPADXOverThreshold;
|
|
bool isPADXBearish =
|
|
isPADXLesserLast &&
|
|
isPADXUnderThreshold;
|
|
|
|
//
|
|
bool isADXSwitchedToBullish =
|
|
isADXBullish &&
|
|
!isPADXBullish;
|
|
bool isADXSwitchedToBearish =
|
|
isADXBearish &&
|
|
!isPADXBearish;
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
bool isRSIBullish =
|
|
cRSI > pRSI;
|
|
bool isRSIBearish =
|
|
cRSI < pRSI;
|
|
|
|
//
|
|
bool isRSISwitchedToBullish =
|
|
cRSI > pRSI &&
|
|
pRSI <= cRSI;
|
|
bool isRSISwitchedToBearish =
|
|
cRSI < pRSI &&
|
|
pRSI >= cRSI;
|
|
|
|
//
|
|
bool isRSIOB =
|
|
cRSI > _rsiOBLevel;
|
|
bool isRSIOS =
|
|
cRSI < _rsiOSLevel;
|
|
|
|
//
|
|
bool isRSICrossedOverOB =
|
|
cRSI > _rsiOBLevel &&
|
|
pRSI <= _rsiOBLevel;
|
|
bool isRSICrossedOverOS =
|
|
cRSI > _rsiOSLevel &&
|
|
pRSI <= _rsiOSLevel;
|
|
|
|
//
|
|
bool isRSICrossedUnderOB =
|
|
cRSI < _rsiOBLevel &&
|
|
pRSI >= _rsiOBLevel;
|
|
bool isRSICrossedUnderOS =
|
|
cRSI < _rsiOSLevel &&
|
|
pRSI >= _rsiOSLevel;
|
|
|
|
//
|
|
// DELTA ...
|
|
|
|
//
|
|
bool isDeltaUp =
|
|
cDelta > pDelta;
|
|
bool isDeltaDown =
|
|
cDelta < pDelta;
|
|
|
|
//
|
|
bool isDeltaBullish =
|
|
cDelta > pDelta &&
|
|
cDeltaSignal > cDelta &&
|
|
cDeltaSignal > pDeltaSignal;
|
|
bool isPDeltaBullish =
|
|
pDelta > p2Delta &&
|
|
pDeltaSignal > pDelta &&
|
|
pDeltaSignal > p2DeltaSignal;
|
|
|
|
//
|
|
bool isDeltaBearish =
|
|
cDelta < pDelta &&
|
|
cDeltaSignal < cDelta &&
|
|
cDeltaSignal < pDeltaSignal;
|
|
bool isPDeltaBearish =
|
|
pDelta < p2Delta &&
|
|
pDeltaSignal < pDelta &&
|
|
pDeltaSignal < p2DeltaSignal;
|
|
|
|
//
|
|
bool isDeltaSwitchedToBullish =
|
|
isDeltaBullish &&
|
|
!isPDeltaBullish;
|
|
bool isDeltaSwitchedToBearish =
|
|
isDeltaBearish &&
|
|
!isPDeltaBearish;
|
|
|
|
//
|
|
// VOLUME ...
|
|
|
|
//
|
|
bool isVolumeBullish =
|
|
cBullishVolume > pBullishVolume &&
|
|
cBullishVolume > cBearishVolume;
|
|
bool isVolumeBearish =
|
|
cBearishVolume > pBearishVolume &&
|
|
cBearishVolume > cBullishVolume;
|
|
|
|
//
|
|
bool isVolumeSwitchedToBullish =
|
|
isVolumeBullish &&
|
|
cBullishVolumeSignal > cBearishVolumeSignal &&
|
|
pBullishVolumeSignal <= pBearishVolumeSignal;
|
|
bool isVolumeSwitchedToBearish =
|
|
isVolumeBearish &&
|
|
cBearishVolumeSignal > cBullishVolumeSignal &&
|
|
pBearishVolumeSignal <= pBullishVolumeSignal;
|
|
|
|
//
|
|
// SIGNAL Bar ...
|
|
|
|
//
|
|
bool isSBarBullish =
|
|
cSBarO < cSBarC;
|
|
bool isSBarBearish =
|
|
cSBarO > cSBarC;
|
|
|
|
//
|
|
bool isSBarSwitchedToBullish =
|
|
cSBarO < cSBarC &&
|
|
pSBarO >= pSBarC;
|
|
bool isSBarSwitchedToBearish =
|
|
cSBarO > cSBarC &&
|
|
pSBarO <= pSBarC;
|
|
|
|
//
|
|
// XHK Signal Bar ...
|
|
|
|
//
|
|
bool isHKSBarBullish =
|
|
cHKSBarO < cHKSBarC;
|
|
bool isHKSBarBearish =
|
|
cHKSBarO > cHKSBarC;
|
|
|
|
//
|
|
bool isHKSBarSwitchedToBullish =
|
|
cHKSBarO < cHKSBarC &&
|
|
pHKSBarO >= pHKSBarC;
|
|
bool isHKSBarSwitchedToBearish =
|
|
cHKSBarO > cHKSBarC &&
|
|
pHKSBarO <= pHKSBarC;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
bool isTrendUp =
|
|
cTrend > pTrend;
|
|
bool isTrendDown =
|
|
cTrend < pTrend;
|
|
|
|
//
|
|
bool isTrendBullish =
|
|
cTrendState > 0;
|
|
bool isTrendBearish =
|
|
cTrendState < 0;
|
|
|
|
//
|
|
bool isTrendSwitchedToBullish =
|
|
isTrendUp &&
|
|
cTrendState > 0 &&
|
|
pTrendState <= 0;
|
|
bool isTrendSwitchedToBearish =
|
|
isTrendDown &&
|
|
cTrendState < 0 &&
|
|
pTrendState >= 0;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
bool isPeakSameLast =
|
|
cPEAK > 0 &&
|
|
cPEAK == pPEAK;
|
|
bool isPeakOverLast =
|
|
pPEAK > 0 &&
|
|
cPEAK > pPEAK;
|
|
bool isPeakUnderLast =
|
|
cPEAK > 0 &&
|
|
cPEAK < pPEAK;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
bool isValeSameLast =
|
|
cVALE > 0 &&
|
|
cVALE == pVALE;
|
|
bool isValeOverLast =
|
|
pVALE > 0 &&
|
|
cVALE > pVALE;
|
|
bool isValeUnderLast =
|
|
cVALE > 0 &&
|
|
cVALE < pVALE;
|
|
|
|
//
|
|
// Attached ...
|
|
|
|
//
|
|
conditions.isKIUp = isKIUp;
|
|
conditions.isATRUp = isATRUp;
|
|
conditions.isRSIOB = isRSIOB;
|
|
conditions.isRSIOS = isRSIOS;
|
|
conditions.isKIDown = isKIDown;
|
|
conditions.isDeltaUp = isDeltaUp;
|
|
conditions.isATRDown = isATRDown;
|
|
conditions.isTrendUp = isTrendUp;
|
|
conditions.rsiOBLevel = _rsiOBLevel;
|
|
conditions.rsiOSLevel = _rsiOSLevel;
|
|
conditions.isDeltaDown = isDeltaDown;
|
|
conditions.isTrendDown = isTrendDown;
|
|
conditions.isKIBullish = isKIBullish;
|
|
conditions.isKIBearish = isKIBearish;
|
|
conditions.isSarBullish = isSarBullish;
|
|
conditions.isSarBearish = isSarBearish;
|
|
conditions.isADXBullish = isADXBullish;
|
|
conditions.isADXBearish = isADXBearish;
|
|
conditions.isRSIBullish = isRSIBullish;
|
|
conditions.isRSIBearish = isRSIBearish;
|
|
conditions.adxThreshold = _adxThreshold;
|
|
conditions.isSBarBullish = isSBarBullish;
|
|
conditions.isSBarBearish = isSBarBearish;
|
|
conditions.isKISameAsLast = isKISameAsLast;
|
|
conditions.isDeltaBullish = isDeltaBullish;
|
|
conditions.isDeltaBearish = isDeltaBearish;
|
|
conditions.isTrendBullish = isTrendBullish;
|
|
conditions.isTrendBearish = isTrendBearish;
|
|
conditions.isPeakSameLast = isPeakSameLast;
|
|
conditions.isPeakOverLast = isPeakOverLast;
|
|
conditions.isValeSameLast = isValeSameLast;
|
|
conditions.isValeOverLast = isValeOverLast;
|
|
conditions.isVolumeBullish = isVolumeBullish;
|
|
conditions.isVolumeBearish = isVolumeBearish;
|
|
conditions.isADXBiggerLast = isADXBiggerLast;
|
|
conditions.isADXLesserLast = isADXLesserLast;
|
|
conditions.isHKSBarBullish = isHKSBarBullish;
|
|
conditions.isHKSBarBearish = isHKSBarBearish;
|
|
conditions.isPeakUnderLast = isPeakUnderLast;
|
|
conditions.isValeUnderLast = isValeUnderLast;
|
|
conditions.isRSICrossedOverOB = isRSICrossedOverOB;
|
|
conditions.isRSICrossedOverOS = isRSICrossedOverOS;
|
|
conditions.isADXOverThreshold = isADXOverThreshold;
|
|
conditions.isDXPBiggerThanDXN = isDXPBiggerThanDXN;
|
|
conditions.isDXNBiggerThanDXP = isDXNBiggerThanDXP;
|
|
conditions.isRSICrossedUnderOB = isRSICrossedUnderOB;
|
|
conditions.isRSICrossedUnderOS = isRSICrossedUnderOS;
|
|
conditions.isADXUnderThreshold = isADXUnderThreshold;
|
|
conditions.isClosedOverATRUpper = isClosedOverATRUpper;
|
|
conditions.isKISwitchedToBullish = isKISwitchedToBullish;
|
|
conditions.isKISwitchedToBearish = isKISwitchedToBearish;
|
|
conditions.isClosedUnderATRLower = isClosedUnderATRLower;
|
|
conditions.isSarSwitchedToBullish = isSarSwitchedToBullish;
|
|
conditions.isSarSwitchedToBearish = isSarSwitchedToBearish;
|
|
conditions.isADXSwitchedToBullish = isADXSwitchedToBullish;
|
|
conditions.isADXSwitchedToBearish = isADXSwitchedToBearish;
|
|
conditions.isRSISwitchedToBullish = isRSISwitchedToBullish;
|
|
conditions.isRSISwitchedToBearish = isRSISwitchedToBearish;
|
|
conditions.isSBarSwitchedToBullish = isSBarSwitchedToBullish;
|
|
conditions.isSBarSwitchedToBearish = isSBarSwitchedToBearish;
|
|
conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish;
|
|
conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish;
|
|
conditions.isDeltaSwitchedToBullish = isDeltaSwitchedToBullish;
|
|
conditions.isDeltaSwitchedToBearish = isDeltaSwitchedToBearish;
|
|
conditions.isVolumeSwitchedToBullish = isVolumeSwitchedToBullish;
|
|
conditions.isVolumeSwitchedToBearish = isVolumeSwitchedToBearish;
|
|
conditions.isHKSBarSwitchedToBullish = isHKSBarSwitchedToBullish;
|
|
conditions.isHKSBarSwitchedToBearish = isHKSBarSwitchedToBearish;
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
Cleanup();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
X121XCatbInputs mInputs; // Inputs ...
|
|
|
|
//
|
|
// Buffers ...
|
|
// Define in Public ...
|
|
|
|
//
|
|
void Calculate(
|
|
int barIndex = 0,
|
|
int maxRequiredBars = 100 //
|
|
)
|
|
{
|
|
//
|
|
// Buffers ...
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_KI_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
kiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_KI_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
kiStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_SAR_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sarBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_SAR_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sarStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_PEAK_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
peakBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VALE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
valeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_PEAK_GOLDEN_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
peakGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VALE_GOLDEN_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
valeGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ATR_BAND_UPPER_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
atrUpperBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ATR_BAND_LOWER_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
atrLowerBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_TREND_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
trendBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_TREND_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
trendStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_SBAR_O_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sBarOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_SBAR_C_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sBarCloseBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_SBAR_O_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkSBarOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_SBAR_C_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkSBarCloseBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_S_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_S_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_M_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
mHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_M_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
mLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_L_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
lHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_L_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
lLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_H_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_H_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_RSI_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
rsiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ADX_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
adxBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ADXP_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
adxpBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ADXN_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
adxnBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_DELTA_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
deltaBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_DELTA_SIGNAL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
deltaSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VOLUME_BULLISH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
bullishVolumeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VOLUME_BEARISH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
bearishVolumeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VOLUME_VOLUME_BULLISH_SIGNAL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
bullishVolumeSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_VOLUME_VOLUME_BEARISH_SIGNAL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
bearishVolumeSignalBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_ATR_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
atrBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_BAR_O_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkOpenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_BAR_H_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkHighBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_BAR_L_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkLowBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCATB_HK_BAR_C_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hkCloseBuffer //
|
|
);
|
|
}
|
|
|
|
//
|
|
void Cleanup(
|
|
int maxAllowed = 100 //
|
|
)
|
|
{
|
|
//
|
|
CleanupArray(
|
|
kiBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
kiStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sarBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sarStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
peakBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
valeBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
peakGoldenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
valeGoldenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
atrUpperBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
atrLowerBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
trendBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
trendStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sBarOpenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sBarCloseBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkSBarOpenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkSBarCloseBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sHHBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
sLLBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
mHHBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
mLLBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
lHHBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
lLLBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hHHBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hLLBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
rsiBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
adxBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
adxpBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
adxnBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
deltaBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
deltaSignalBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
bullishVolumeBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
bearishVolumeBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
bullishVolumeSignalBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
bearishVolumeSignalBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
atrBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkOpenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkHighBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkLowBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
hkCloseBuffer,
|
|
maxAllowed //
|
|
);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Extensions ...
|
|
|
|
//
|
|
enum ENUM_XCATB_DIRECTION_SHIFT_TYPES
|
|
{
|
|
XCATB_DIRECTION_SHIFT_TYPE_NONE, // None
|
|
XCATB_DIRECTION_SHIFT_TYPE_SAR, // XSARB
|
|
XCATB_DIRECTION_SHIFT_TYPE_TREND, // XTRNDB
|
|
XCATB_DIRECTION_SHIFT_TYPE_DELTA, // XDELTAB
|
|
XCATB_DIRECTION_SHIFT_TYPE_VOLUME, // XVLMB
|
|
XCATB_DIRECTION_SHIFT_TYPE_SIGNAL_BAR, // XSBARB
|
|
XCATB_DIRECTION_SHIFT_TYPE_HK_SIGNAL_BAR, // XHKSBARB
|
|
};
|
|
|
|
//
|
|
bool IsValid(ENUM_XCATB_DIRECTION_SHIFT_TYPES value)
|
|
{
|
|
return value != XCATB_DIRECTION_SHIFT_TYPE_NONE;
|
|
}
|
|
|
|
//
|
|
string ToXString(ENUM_XCATB_DIRECTION_SHIFT_TYPES value)
|
|
{
|
|
return EnumToString(value);
|
|
}
|
|
|
|
//
|
|
ENUM_XCATB_DIRECTION_SHIFT_TYPES GetDirectionShiftType(XBoxZone &box)
|
|
{
|
|
//
|
|
ENUM_XCATB_DIRECTION_SHIFT_TYPES result = XCATB_DIRECTION_SHIFT_TYPE_NONE;
|
|
|
|
//
|
|
if (!box.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
ENUM_XCATB_DIRECTION_SHIFT_TYPES all[] = {
|
|
XCATB_DIRECTION_SHIFT_TYPE_SAR,
|
|
XCATB_DIRECTION_SHIFT_TYPE_TREND,
|
|
XCATB_DIRECTION_SHIFT_TYPE_DELTA,
|
|
XCATB_DIRECTION_SHIFT_TYPE_VOLUME,
|
|
XCATB_DIRECTION_SHIFT_TYPE_SIGNAL_BAR,
|
|
XCATB_DIRECTION_SHIFT_TYPE_HK_SIGNAL_BAR,
|
|
};
|
|
|
|
//
|
|
int count = ArraySize(all);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
if (box.type == ToXString(all[i]))
|
|
{
|
|
//
|
|
result = all[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsDirectionShift(XBoxZone &box)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsValid(GetDirectionShiftType(box));
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Sar Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateSarDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Current SAR is Directional ...
|
|
conditions.isSarBullish &&
|
|
//
|
|
// Previous InDirectional Sar Exists ...
|
|
helper.lastSarBearish.IsValid() &&
|
|
//
|
|
// Current Close is Over previous Sar ...
|
|
conditions.bars[cIDX].close > helper.lastSarBearish.after &&
|
|
//
|
|
// Before Close is not Over previous Sar ...
|
|
conditions.bars[pIDX].close <= helper.lastSarBearish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Current SAR is Directional ...
|
|
conditions.isSarBearish &&
|
|
//
|
|
// Previous InDirectional Sar Exists ...
|
|
helper.lastSarBullish.IsValid() &&
|
|
//
|
|
// Current Close is Under previous ...
|
|
conditions.bars[cIDX].close < helper.lastSarBullish.after &&
|
|
//
|
|
// Before Close is not Under previous ...
|
|
conditions.bars[pIDX].close >= helper.lastSarBullish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastSarBullish;
|
|
XDirectionShift lastBearish = helper.lastSarBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XSARB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Trend Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateTrendDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Current Trend is Directional ...
|
|
conditions.isTrendBullish &&
|
|
//
|
|
// Previous InDirectiona; Trend Exists ...
|
|
helper.lastTrendBearish.IsValid() &&
|
|
//
|
|
// Current Close is Over previous ...
|
|
conditions.bars[cIDX].close > helper.lastTrendBearish.after &&
|
|
//
|
|
// Before close is not Over previous ...
|
|
conditions.bars[pIDX].close <= helper.lastTrendBearish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Current Trend is Directional ...
|
|
conditions.isTrendBearish &&
|
|
//
|
|
// Previous InDirectiona; Trend Exists ...
|
|
helper.lastTrendBullish.IsValid() &&
|
|
//
|
|
// Current Close is Under previous ...
|
|
conditions.bars[cIDX].close < helper.lastTrendBullish.after &&
|
|
//
|
|
// Before close is not Under previous ...
|
|
conditions.bars[pIDX].close >= helper.lastTrendBullish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastTrendBullish;
|
|
XDirectionShift lastBearish = helper.lastTrendBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XTRNDB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Delta Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateDeltaDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
// Check State ...
|
|
(
|
|
//
|
|
// Delta is Up ...
|
|
conditions.deltaBuffer[cIDX] > conditions.deltaBuffer[pIDX] &&
|
|
//
|
|
// Delta Signal is Up ...
|
|
conditions.deltaSignalBuffer[cIDX] > conditions.deltaSignalBuffer[pIDX] &&
|
|
//
|
|
// Delta Crossed Over Delta Signal ...
|
|
conditions.deltaBuffer[cIDX] > conditions.deltaSignalBuffer[cIDX]
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
// Check Last InDirectional Exists ...
|
|
helper.lastDeltaBearish.IsValid() &&
|
|
//
|
|
// Current Close is Over last ...
|
|
conditions.bars[cIDX].close > helper.lastDeltaBearish.after &&
|
|
//
|
|
// Before Close is not Over last ...
|
|
conditions.bars[pIDX].close <= helper.lastDeltaBearish.after
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
// Check State ...
|
|
(
|
|
//
|
|
// Delta is Down ...
|
|
conditions.deltaBuffer[cIDX] < conditions.deltaBuffer[pIDX] &&
|
|
//
|
|
// Delta Signal is Down ...
|
|
conditions.deltaSignalBuffer[cIDX] < conditions.deltaSignalBuffer[pIDX] &&
|
|
//
|
|
// Delta Crossed Under Delta Signal ...
|
|
conditions.deltaBuffer[cIDX] < conditions.deltaSignalBuffer[cIDX]
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
// Check Last InDirectional Exists ...
|
|
helper.lastDeltaBullish.IsValid() &&
|
|
//
|
|
// Current Close is Under last ...
|
|
conditions.bars[cIDX].close < helper.lastDeltaBullish.after &&
|
|
//
|
|
// Before Close is not Under last ...
|
|
conditions.bars[pIDX].close >= helper.lastDeltaBullish.after
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastDeltaBullish;
|
|
XDirectionShift lastBearish = helper.lastDeltaBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XDELTAB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Volume Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateVolumeDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
(
|
|
//
|
|
//
|
|
// Volume is Up ...
|
|
conditions.bullishVolumeBuffer[1] > conditions.bullishVolumeBuffer[2] &&
|
|
//
|
|
// Volume Signal is Up ...
|
|
conditions.bullishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[2] &&
|
|
//
|
|
// Volume Signals Crossed Over ...
|
|
conditions.bullishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[1]
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
// Check Last InDirectional Exists ...
|
|
helper.lastVolumeBearish.IsValid() &&
|
|
//
|
|
// Current Close is Over last ...
|
|
conditions.bars[cIDX].close > helper.lastVolumeBearish.after &&
|
|
//
|
|
// Before Close is not Over last ...
|
|
conditions.bars[pIDX].close <= helper.lastVolumeBearish.after
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
//
|
|
// Volume is Up ...
|
|
conditions.bearishVolumeBuffer[1] > conditions.bearishVolumeBuffer[2] &&
|
|
//
|
|
// Volume Signal is Up ...
|
|
conditions.bearishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[2] &&
|
|
//
|
|
// Volume Signals Crossed Over ...
|
|
conditions.bearishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[1]
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
// Check Last InDirectional Exists ...
|
|
helper.lastVolumeBullish.IsValid() &&
|
|
//
|
|
// Current Close is Over last ...
|
|
conditions.bars[cIDX].close < helper.lastVolumeBullish.after &&
|
|
//
|
|
// Before Close is not Over last ...
|
|
conditions.bars[pIDX].close >= helper.lastVolumeBullish.after
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastVolumeBullish;
|
|
XDirectionShift lastBearish = helper.lastVolumeBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XVLMB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Signal Bar Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateSignalBarDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Check Direction ...
|
|
conditions.isSBarBullish &&
|
|
//
|
|
// Previous InDirectional Exists ...
|
|
helper.lastSignalBarBearish.IsValid() &&
|
|
//
|
|
// Current Signal Bar close over prev ...
|
|
conditions.sBarCloseBuffer[cIDX] > helper.lastSignalBarBearish.after &&
|
|
//
|
|
// Prev Signal Bar not close over prev ...
|
|
conditions.sBarCloseBuffer[pIDX] <= helper.lastSignalBarBearish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Check Direction ...
|
|
conditions.isSBarBearish &&
|
|
//
|
|
// Previous InDirectional Exists ...
|
|
helper.lastSignalBarBullish.IsValid() &&
|
|
//
|
|
// Current Signal Bar close over prev ...
|
|
conditions.sBarCloseBuffer[cIDX] < helper.lastSignalBarBullish.after &&
|
|
//
|
|
// Prev Signal Bar not close over prev ...
|
|
conditions.sBarCloseBuffer[pIDX] >= helper.lastSignalBarBullish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastSignalBarBullish;
|
|
XDirectionShift lastBearish = helper.lastSignalBarBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XSBARB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate HK Signal Bar Direction Shift Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference, Holds Generated Box ...
|
|
* @param helper: XCX121XCatbHelper instance pointer ...
|
|
* @param conditions: X121XCatbConditions instance reference, Specified Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GenerateHKSignalBarDirectionShiftBox(
|
|
XBoxZone &box,
|
|
XCX121XCatbHelper *helper,
|
|
X121XCatbConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
box.Clean();
|
|
|
|
//
|
|
// Validate Args ...
|
|
result =
|
|
helper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Requirements ...
|
|
|
|
//
|
|
int idx = -1;
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
|
|
//
|
|
// Check Sar Direction Changed Happens or not ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
(
|
|
//
|
|
// Check Direction ...
|
|
conditions.isHKSBarBullish &&
|
|
//
|
|
// Previous InDirectional Exists ...
|
|
helper.lastHKSignalBarBearish.IsValid() &&
|
|
//
|
|
// Current Signal Bar close over prev ...
|
|
conditions.hkSBarCloseBuffer[cIDX] > helper.lastHKSignalBarBearish.after &&
|
|
//
|
|
// Prev Signal Bar not close over prev ...
|
|
conditions.hkSBarCloseBuffer[pIDX] <= helper.lastHKSignalBarBearish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Check Direction ...
|
|
conditions.isHKSBarBearish &&
|
|
//
|
|
// Previous InDirectional Exists ...
|
|
helper.lastHKSignalBarBullish.IsValid() &&
|
|
//
|
|
// Current Signal Bar close over prev ...
|
|
conditions.hkSBarCloseBuffer[cIDX] < helper.lastHKSignalBarBullish.after &&
|
|
//
|
|
// Prev Signal Bar not close over prev ...
|
|
conditions.hkSBarCloseBuffer[pIDX] >= helper.lastHKSignalBarBullish.after
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Assign Last Direction Shift ...
|
|
XDirectionShift lastBullish = helper.lastHKSignalBarBullish;
|
|
XDirectionShift lastBearish = helper.lastHKSignalBarBearish;
|
|
XDirectionShift selected = isBullish
|
|
? lastBearish
|
|
: lastBullish;
|
|
|
|
//
|
|
// Convert to Box ...
|
|
box.type = "XHKSBARB";
|
|
box.from = selected.at;
|
|
box.symbol = selected.symbol;
|
|
box.period = selected.period;
|
|
box.dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
box.to = conditions.bars[zIDX].time;
|
|
|
|
//
|
|
// Detect Boundary ...
|
|
idx = selected.Index();
|
|
result = IsValidIndex(idx);
|
|
if (result)
|
|
{
|
|
//
|
|
box.lower = conditions.bars[zIDX].FindLowest(idx, MODE_CLOSE);
|
|
box.upper = conditions.bars[zIDX].FindHighest(idx, MODE_CLOSE);
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
result = box.IsValid();
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
selected.Clean();
|
|
lastBullish.Clean();
|
|
lastBearish.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// |