Files
MQL5Data/Documents/Helpers/x-saherelm.x121.xcatb.helper.mq5
T

5548 lines
127 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_STATE_LINE = 28,
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_STATE_LINE = 29,
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_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_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_RSI_LINE = 30,
X121_XCATB_ADX_LINE = 31,
X121_XCATB_ADXP_LINE = 32,
X121_XCATB_ADXN_LINE = 33,
X121_XCATB_DELTA_LINE = 34,
X121_XCATB_DELTA_SIGNAL_LINE = 35,
X121_XCATB_VOLUME_BULLISH_LINE = 36,
X121_XCATB_VOLUME_BEARISH_LINE = 37,
X121_XCATB_VOLUME_VOLUME_BULLISH_SIGNAL_LINE = 38,
X121_XCATB_VOLUME_VOLUME_BEARISH_SIGNAL_LINE = 39,
X121_XCATB_ATR_LINE = 40,
X121_XCATB_ATR_BAND_RAW_UPPER_LINE = 41,
X121_XCATB_ATR_BAND_RAW_LOWER_LINE = 42,
X121_XCATB_HK_BAR_O_LINE = 43,
X121_XCATB_HK_BAR_H_LINE = 44,
X121_XCATB_HK_BAR_L_LINE = 45,
X121_XCATB_HK_BAR_C_LINE = 46,
};
//
// 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
//
// Signal ...
int signalR2R; // Risk Reward Ratio
bool drawSignals; // Draw Signal
bool drawTriggerBlock; // Draw Trigger Block
double slAtrMultiplier; // ATR Multiplier for SL
//
// Validating ...
bool forceHasSwing; // Force Blocks to Have Swing
bool forceOBBarType; // Force Block Has Reversal Bar
bool forceOBFVGBarType; // Force FVG Has Same Bars
bool forceHasFLiquidity; // Force Blocks to Have Following Liquidity
bool forceHasRLiquidity; // Force Blocks to Have Reversal Liquidity
bool validateGapSequence; // Validate Block's Gap Sequence
bool validateBlockEdgeBreakout; // Validate Block's Edge Breakout
//
// Filtering ...
bool filterBasedOnPV; // Filter Based on Peak and Vale
bool filterBasedOnSar; // Filter Based on Sar
bool filterBasedOnRSI; // Filter Based on RSI
bool filterBasedOnADX; // Filter Based on ADX
bool filterBasedOnATR; // Filter Based on ATR
bool filterBasedOnTrend; // Filter Based on Trend
bool filterBasedOnDelta; // Filter Based on Delta
bool filterBasedOnVolume; // Filter Based on Volume
bool filterBasedOnSignalBar; // Filter Based on Signal Bar
bool filterBasedOnHKSignalBar; // Filter Based on Hiken Ashi Signal Bar
//
// Alert ...
string alertPrefix; // Alert Prefix
bool logAlerts; // Log Alerts
bool pushAlerts; // Push Alerts
bool mailAlerts; // Mail Alerts
bool terminalAlerts; // Terminal Alerts
//
// Presentation ...
bool showBars; // Show Bars
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
//
// Signal ...
signalR2R = 0; // Risk Reward Ratio
drawSignals = false; // Draw Signal
drawTriggerBlock = false; // Draw Trigger Block
slAtrMultiplier = 0; // ATR Multiplier for SL
//
// Validating ...
forceHasSwing = false; // Force Blocks to Have Swing
forceOBBarType = false; // Force Block Has Reversal Bar
forceOBFVGBarType = false; // Force FVG Has Same Bars
forceHasFLiquidity = false; // Force Blocks to Have Following Liquidity
forceHasRLiquidity = false; // Force Blocks to Have Reversal Liquidity
validateGapSequence = false; // Validate Block's Gap Sequence
validateBlockEdgeBreakout = false; // Validate Block's Edge Breakout
//
// Filtering ...
filterBasedOnPV = false; // Filter Based on Peak and Vale
filterBasedOnSar = false; // Filter Based on Sar
filterBasedOnRSI = false; // Filter Based on RSI
filterBasedOnADX = false; // Filter Based on ADX
filterBasedOnATR = false; // Filter Based on ATR
filterBasedOnTrend = false; // Filter Based on Trend
filterBasedOnDelta = false; // Filter Based on Delta
filterBasedOnVolume = false; // Filter Based on Volume
filterBasedOnSignalBar = false; // Filter Based on Signal Bar
filterBasedOnHKSignalBar = false; // Filter Based on Hiken Ashi Signal Bar
//
// Alert ...
alertPrefix = ""; // Alert Prefix
logAlerts = false; // Log Alerts
pushAlerts = false; // Push Alerts
mailAlerts = false; // Mail Alerts
terminalAlerts = false; // Terminal Alerts
//
// Presentation ...
showBars = false; // Show Bars
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
//
// Signal ...
signalR2R = 4; // Risk Reward Ratio
drawSignals = false; // Draw Signal
drawTriggerBlock = false; // Draw Trigger Block
slAtrMultiplier = 1.0; // ATR Multiplier for SL
//
// Validating ...
forceHasSwing = false; // Force Blocks to Have Swing
forceOBBarType = false; // Force Block Has Reversal Bar
forceOBFVGBarType = false; // Force FVG Has Same Bars
forceHasFLiquidity = false; // Force Blocks to Have Following Liquidity
forceHasRLiquidity = false; // Force Blocks to Have Reversal Liquidity
validateGapSequence = false; // Validate Block's Gap Sequence
validateBlockEdgeBreakout = false; // Validate Block's Edge Breakout
//
// Filtering ...
filterBasedOnPV = false; // Filter Based on Peak and Vale
filterBasedOnSar = false; // Filter Based on Sar
filterBasedOnRSI = false; // Filter Based on RSI
filterBasedOnADX = false; // Filter Based on ADX
filterBasedOnATR = false; // Filter Based on ATR
filterBasedOnTrend = false; // Filter Based on Trend
filterBasedOnDelta = false; // Filter Based on Delta
filterBasedOnVolume = false; // Filter Based on Volume
filterBasedOnSignalBar = false; // Filter Based on Signal Bar
filterBasedOnHKSignalBar = false; // Filter Based on Hiken Ashi Signal Bar
//
// Alert ...
alertPrefix = ""; // Alert Prefix
logAlerts = false; // Log Alerts
pushAlerts = false; // Push Alerts
mailAlerts = false; // Mail Alerts
terminalAlerts = false; // Terminal Alerts
//
// Presentation ...
showBars = true; // Show Bars
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()
{
//
showPV = false;
showPVGolden = false;
showSar = false;
showTrend = false;
showATRBand = false;
showSignalBars = false;
showHKSignalBars = false;
//
drawSignals = false;
drawTriggerBlock = false;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(appliedCycle) &&
//
// CYCLES ...
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(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 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 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;
//
// 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 ...
//
Clean(bars);
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);
//
ArraySetAsSeries(bars, 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(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;
//
// 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;
}
//
// 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: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
"-----------------------" + separator +
"XCATB: " + separator +
"-----------------------" + separator +
"" + separator +
//
"-----------------------" + separator +
"ATR Band: " + separator +
"-----------------------" + separator +
ToString("isATRUp", isATRUp, ignoreFalseConditions, separator) +
ToString("isATRDown", isATRDown, ignoreFalseConditions, separator) +
ToString("isClosedOverATRUpper", isClosedOverATRUpper, ignoreFalseConditions, separator) +
ToString("isClosedUnderATRLower", isClosedUnderATRLower, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"SAR: " + separator +
"-----------------------" + separator +
ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) +
ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) +
ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"ADX: " + separator +
"-----------------------" + separator +
ToString("isADXBiggerLast", isADXBiggerLast, ignoreFalseConditions, separator) +
ToString("isADXLesserLast", isADXLesserLast, ignoreFalseConditions, separator) +
ToString("isADXOverThreshold", isADXOverThreshold, ignoreFalseConditions, separator) +
ToString("isADXUnderThreshold", isADXUnderThreshold, ignoreFalseConditions, separator) +
ToString("isDXPBiggerThanDXN", isDXPBiggerThanDXN, ignoreFalseConditions, separator) +
ToString("isDXNBiggerThanDXP", isDXNBiggerThanDXP, ignoreFalseConditions, separator) +
ToString("isADXBullish", isADXBullish, ignoreFalseConditions, separator) +
ToString("isADXBearish", isADXBearish, ignoreFalseConditions, separator) +
ToString("isADXSwitchedToBullish", isADXSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isADXSwitchedToBearish", isADXSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"RSI: " + separator +
"-----------------------" + separator +
ToString("isRSIBullish", isRSIBullish, ignoreFalseConditions, separator) +
ToString("isRSIBearish", isRSIBearish, ignoreFalseConditions, separator) +
ToString("isRSISwitchedToBullish", isRSISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isRSISwitchedToBearish", isRSISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isRSIOB", isRSIOB, ignoreFalseConditions, separator) +
ToString("isRSIOS", isRSIOS, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOB", isRSICrossedOverOB, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOS", isRSICrossedOverOS, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOB", isRSICrossedUnderOB, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOS", isRSICrossedUnderOS, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"DELTA: " + separator +
"-----------------------" + separator +
ToString("isDeltaUp", isDeltaUp, ignoreFalseConditions, separator) +
ToString("isDeltaDown", isDeltaDown, ignoreFalseConditions, separator) +
ToString("isDeltaBullish", isDeltaBullish, ignoreFalseConditions, separator) +
ToString("isDeltaBearish", isDeltaBearish, ignoreFalseConditions, separator) +
ToString("isDeltaSwitchedToBullish", isDeltaSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isDeltaSwitchedToBearish", isDeltaSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"VOLUME: " + separator +
"-----------------------" + separator +
ToString("isVolumeBullish", isVolumeBullish, ignoreFalseConditions, separator) +
ToString("isVolumeBearish", isVolumeBearish, ignoreFalseConditions, separator) +
ToString("isVolumeSwitchedToBullish", isVolumeSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isVolumeSwitchedToBearish", isVolumeSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"SIGNAL Bar: " + separator +
"-----------------------" + separator +
ToString("isSBarBullish", isSBarBullish, ignoreFalseConditions, separator) +
ToString("isSBarBearish", isSBarBearish, ignoreFalseConditions, separator) +
ToString("isSBarSwitchedToBullish", isSBarSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSBarSwitchedToBearish", isSBarSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"XHK Signal Bar: " + separator +
"-----------------------" + separator +
ToString("isHKSBarBullish", isHKSBarBullish, ignoreFalseConditions, separator) +
ToString("isHKSBarBearish", isHKSBarBearish, ignoreFalseConditions, separator) +
ToString("isHKSBarSwitchedToBullish", isHKSBarSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isHKSBarSwitchedToBearish", isHKSBarSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"Trend: " + separator +
"-----------------------" + separator +
ToString("isTrendUp", isTrendUp, ignoreFalseConditions, separator) +
ToString("isTrendDown", isTrendDown, ignoreFalseConditions, separator) +
ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) +
ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) +
ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"Peak: " + separator +
"-----------------------" + separator +
ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) +
ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) +
ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) +
//
"-----------------------" + separator +
"Vale: " + separator +
"-----------------------" + separator +
ToString("isValeSameLast", isValeSameLast, ignoreFalseConditions, separator) +
ToString("isValeOverLast", isValeOverLast, ignoreFalseConditions, separator) +
ToString("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 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 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(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(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,
"", // Signal ...
mInputs.signalR2R,
mInputs.drawSignals,
mInputs.drawTriggerBlock,
mInputs.slAtrMultiplier,
"", // Validating ...
mInputs.forceHasSwing,
mInputs.forceOBBarType,
mInputs.forceOBFVGBarType,
mInputs.forceHasFLiquidity,
mInputs.forceHasRLiquidity,
mInputs.validateGapSequence,
mInputs.validateBlockEdgeBreakout,
"", // Filtering ...
mInputs.filterBasedOnPV,
mInputs.filterBasedOnSar,
mInputs.filterBasedOnRSI,
mInputs.filterBasedOnADX,
mInputs.filterBasedOnATR,
mInputs.filterBasedOnTrend,
mInputs.filterBasedOnDelta,
mInputs.filterBasedOnVolume,
mInputs.filterBasedOnSignalBar,
mInputs.filterBasedOnHKSignalBar,
"", // Alerts ...
mInputs.alertPrefix,
mInputs.logAlerts,
mInputs.pushAlerts,
mInputs.mailAlerts,
mInputs.terminalAlerts,
"", // Presentation ...
mInputs.showBars,
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 ...
//
// 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 ...
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];
//
// 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;
//
// 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.isATRUp = isATRUp;
conditions.isRSIOB = isRSIOB;
conditions.isRSIOS = isRSIOS;
conditions.isDeltaUp = isDeltaUp;
conditions.isATRDown = isATRDown;
conditions.isTrendUp = isTrendUp;
conditions.rsiOBLevel = _rsiOBLevel;
conditions.rsiOSLevel = _rsiOSLevel;
conditions.isDeltaDown = isDeltaDown;
conditions.isTrendDown = isTrendDown;
conditions.adxThreshold = _adxThreshold;
conditions.isSarBullish = isSarBullish;
conditions.isSarBearish = isSarBearish;
conditions.isADXBullish = isADXBullish;
conditions.isADXBearish = isADXBearish;
conditions.isRSIBullish = isRSIBullish;
conditions.isRSIBearish = isRSIBearish;
conditions.isSBarBullish = isSBarBullish;
conditions.isSBarBearish = isSBarBearish;
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.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_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(
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 //
);
}
//
};
//