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

3789 lines
76 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"
//
// 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
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 showTrendBars; // Show Trend Bars
bool showSignalBars; // Show Signal Bars
bool showHKSignalBars; // Show Hiken Ashi Signal Bars
//
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
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 = NULL; // 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
showTrendBars = false; // Show Trend Bars
showSignalBars = false; // Show Signal Bars
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
//
startCalculationForLastBars = 0; // Calculate Last n Bars
//
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
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 = NULL; // Alert Prefix
logAlerts = true; // Log Alerts
pushAlerts = false; // Push Alerts
mailAlerts = false; // Mail Alerts
terminalAlerts = true; // 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
showTrendBars = false; // Show Trend Bars
showSignalBars = false; // Show Signal Bars
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
//
startCalculationForLastBars = 1500; // Calculate Last n Bars
}
//
// Hide all Visible Buffers ...
void Hide()
{
//
showPV = false;
showPVGolden = false;
showSar = false;
showTrend = false;
showATRBand = false;
showTrendBars = false;
showSignalBars = false;
showHKSignalBars = 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;
//
// 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[];
//
// Conditions ...
//
// Constructor ...
X121XCatbConditions()
{
Clean();
}
//
// Tools ...
/**
* Cleaning Up ...
*/
void Clean()
{
//
// Commons ...
symbol = NULL;
period = NULL;
time = NULL;
//
// Buffers ...
//
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(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);
//
// Conditions ...
//
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;
}
/**
* 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 =
//
""
//
;
//
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[];
//
// 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.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.showTrendBars,
mInputs.showSignalBars,
mInputs.showHKSignalBars,
mInputs.startCalculationForLastBars
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// 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 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();
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
result = zBar.Init(
mSymbol,
mPeriod,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
//
return result;
}
//
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 //
);
//
// Conditions ...
//
int zIDX = 0;
int cIDX = 1;
int pIDX = cIDX + 1;
int p2IDX = pIDX + 1;
int p3IDX = p2IDX + 1;
int p4IDX = p3IDX + 1;
//
// Calculate ...
//
// Attached ...
//
// Cleanup Resources ...
//
Cleanup();
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
//
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 //
);
}
//
};
//