3871 lines
84 KiB
Plaintext
3871 lines
84 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XCX121XCAHelper
|
|
// 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 ...
|
|
|
|
//
|
|
// Definitions ...
|
|
enum ENUM_X121_XCA_BUFFERS
|
|
{
|
|
//
|
|
X121_XCA_S_HH_LINE = 0,
|
|
X121_XCA_S_LL_LINE = 1,
|
|
X121_XCA_M_HH_LINE = 2,
|
|
X121_XCA_M_LL_LINE = 3,
|
|
X121_XCA_L_HH_LINE = 4,
|
|
X121_XCA_L_LL_LINE = 5,
|
|
X121_XCA_H_HH_LINE = 6,
|
|
X121_XCA_H_LL_LINE = 7,
|
|
X121_XCA_SUPPORT_LINE = 8,
|
|
X121_XCA_RESISTANCE_LINE = 9,
|
|
X121_XCA_PEAK_LINE = 10,
|
|
X121_XCA_PEAK_GOLDEN_LINE = 11,
|
|
X121_XCA_VALE_LINE = 12,
|
|
X121_XCA_VALE_GOLDEN_LINE = 13,
|
|
X121_XCA_FIBO_L1_LINE = 14,
|
|
X121_XCA_FIBO_L2_LINE = 15,
|
|
X121_XCA_FIBO_L3_LINE = 16,
|
|
X121_XCA_SAR_LINE = 17,
|
|
X121_XCA_TREND_LINE = 18,
|
|
X121_XCA_KI_LINE = 20,
|
|
X121_XCA_SWING_LOW_LINE = 22,
|
|
X121_XCA_SWING_HIGH_LINE = 23,
|
|
X121_XCA_TKI_LINE = 24,
|
|
X121_XCA_TREND_STATE_LINE = 26,
|
|
X121_XCA_KI_STATE_LINE = 27,
|
|
X121_XCA_TKI_STATE_LINE = 28,
|
|
};
|
|
|
|
//
|
|
// Input Models ...
|
|
struct X121XCAInputs
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Market ...
|
|
|
|
//
|
|
// Short ...
|
|
ENUM_X_PERIOD_METHOD scMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES scPeriod; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES mcPeriod; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES lcPeriod; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES hcPeriod; // Time Period
|
|
|
|
//
|
|
// Boundary Detection ...
|
|
ENUM_SERIESMODE hhMode; // Highest High Calculation Method
|
|
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
|
|
ENUM_X_FIBO_LEVELS goldenZoneLevel; // Golden Zone Detection
|
|
|
|
//
|
|
// Fibo Levels ...
|
|
ENUM_X_FIBO_LEVELS fiboLevel1; // Fibo Level 1
|
|
ENUM_X_FIBO_LEVELS fiboLevel2; // Fibo Level 2
|
|
ENUM_X_FIBO_LEVELS fiboLevel3; // Fibo Level 3
|
|
|
|
//
|
|
// Sar Detection ...
|
|
double sarStep; // Step
|
|
double sarMax; // Maximum
|
|
|
|
//
|
|
// KI ...
|
|
int kiLength; // KI Length
|
|
|
|
//
|
|
// Swing Detection ...
|
|
int swingLength; // Length
|
|
|
|
//
|
|
// Support and Resistance ...
|
|
int supResSmoothingLength; // Smoothing Length
|
|
ENUM_X_MA_METHOD supResSmoothingMode; // Smoothing Method
|
|
|
|
//
|
|
// Presentation ...
|
|
|
|
//
|
|
int startCalculationForLastBars; // Calculate Last n Bars
|
|
|
|
//
|
|
bool showSar; // Show Sar
|
|
bool showKI; // Show KI
|
|
bool showTKI; // Show TKI
|
|
bool showTrend; // Show Trend
|
|
bool showSwings; // Show Swings
|
|
bool showFiboLevel1; // Show Fibo Level 1
|
|
bool showFiboLevel2; // Show Fibo Level 2
|
|
bool showFiboLevel3; // Show Fibo Level 3
|
|
bool showPeaksAndVales; // Show Peaks And Vales
|
|
bool showPeakAndValeGolden; // Show Peak and Vale Golden
|
|
bool showSupportAndResistance; // Show Support and Resistance
|
|
bool showShortCycle; // Show Short Cycle
|
|
bool showMediumCycle; // Show Medium Cycle
|
|
bool showLongCycle; // Show Long Cycle
|
|
bool showHindCycle; // Show Hind Cycle
|
|
|
|
//
|
|
int sarArrowCode; // Parabolic Sar Arrow Code
|
|
int peakArrowCode; // Peaks Arrow Code
|
|
int valeArrowCode; // Vales Arrow Code
|
|
int swingLowArrowCode; // Swing Low Arrow Code
|
|
int swingHighArrowCode; // Swing High Arrow Code
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
X121XCAInputs()
|
|
{
|
|
//
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Clean ...
|
|
void Clean()
|
|
{
|
|
//
|
|
// Market ...
|
|
|
|
//
|
|
// Short ...
|
|
scMethod = X_PERIOD_AUTO; // How to Find Period
|
|
scPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
mcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
mcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
lcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
lcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
hcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
hcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Boundary Detection ...
|
|
hhMode = MODE_HIGH; // Highest High Calculation Method
|
|
llMode = MODE_LOW; // Lowest Low Calculation Method
|
|
|
|
//
|
|
// Fibo Levels ...
|
|
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
|
fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
|
|
fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
|
|
|
|
//
|
|
// Sar Detection ...
|
|
sarStep = 0; // Step
|
|
sarMax = 0; // Maximum
|
|
|
|
//
|
|
// KI ...
|
|
kiLength = 0; // KI Length
|
|
|
|
//
|
|
// Swing Detection ...
|
|
swingLength = 0; // Length
|
|
|
|
//
|
|
// Support and Resistance ...
|
|
supResSmoothingLength = 0; // Smoothing Length
|
|
supResSmoothingMode = X_MA_MODE_NONE; // Smoothing Method
|
|
|
|
//
|
|
// Presentation ...
|
|
|
|
//
|
|
startCalculationForLastBars = 0; // Calculate Last n Bars
|
|
|
|
//
|
|
showSar = true; // Show Sar
|
|
showKI = true; // Show KI
|
|
showTKI = true; // Show TKI
|
|
showTrend = true; // Show Trend
|
|
showSwings = true; // Show Swings
|
|
showFiboLevel1 = true; // Show Fibo Level 1
|
|
showFiboLevel2 = true; // Show Fibo Level 2
|
|
showFiboLevel3 = true; // Show Fibo Level 3
|
|
showPeaksAndVales = true; // Show Peaks And Vales
|
|
showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
|
showSupportAndResistance = true; // Show Support and Resistance
|
|
showShortCycle = true; // Show Short Cycle
|
|
showMediumCycle = true; // Show Medium Cycle
|
|
showLongCycle = true; // Show Long Cycle
|
|
showHindCycle = true; // Show Hind Cycle
|
|
|
|
//
|
|
sarArrowCode = 0; // Parabolic Sar Arrow Code
|
|
peakArrowCode = 0; // Peaks Arrow Code
|
|
valeArrowCode = 0; // Vales Arrow Code
|
|
swingLowArrowCode = 0; // Swing Low Arrow Code
|
|
swingHighArrowCode = 0; // Swing High Arrow Code
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
// Market ...
|
|
|
|
//
|
|
// Short ...
|
|
scMethod = X_PERIOD_AUTO; // How to Find Period
|
|
scPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
mcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
mcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
lcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
lcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
hcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
hcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Boundary Detection ...
|
|
hhMode = MODE_HIGH; // Highest High Calculation Method
|
|
llMode = MODE_LOW; // Lowest Low Calculation Method
|
|
|
|
//
|
|
// Fibo Levels ...
|
|
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
|
fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
|
|
fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
|
|
|
|
//
|
|
// Sar Detection ...
|
|
sarStep = 0.02; // Step
|
|
sarMax = 0.2; // Maximum
|
|
|
|
//
|
|
// KI ...
|
|
kiLength = 26; // KI Length
|
|
|
|
//
|
|
// Swing Detection ...
|
|
swingLength = 5; // Length
|
|
|
|
//
|
|
// Presentation ...
|
|
|
|
//
|
|
startCalculationForLastBars = 1000; // Calculate Last n Bars
|
|
|
|
//
|
|
showSar = true; // Show Sar
|
|
showKI = true; // Show KI
|
|
showTKI = true; // Show TKI
|
|
showTrend = true; // Show Trend
|
|
showSwings = true; // Show Swings
|
|
showFiboLevel1 = true; // Show Fibo Level 1
|
|
showFiboLevel2 = true; // Show Fibo Level 2
|
|
showFiboLevel3 = true; // Show Fibo Level 3
|
|
showPeaksAndVales = true; // Show Peaks And Vales
|
|
showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
|
showSupportAndResistance = true; // Show Support and Resistance
|
|
showShortCycle = true; // Show Short Cycle
|
|
showMediumCycle = true; // Show Medium Cycle
|
|
showLongCycle = true; // Show Long Cycle
|
|
showHindCycle = true; // Show Hind Cycle
|
|
|
|
//
|
|
sarArrowCode = 159; // Parabolic Sar Arrow Code
|
|
peakArrowCode = 159; // Peaks Arrow Code
|
|
valeArrowCode = 159; // Vales Arrow Code
|
|
swingLowArrowCode = 225; // Swing Low Arrow Code
|
|
swingHighArrowCode = 226; // Swing High Arrow Code
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
// SAR ...
|
|
sarMax > 0 &&
|
|
sarStep > 0 &&
|
|
kiLength > 0 &&
|
|
swingLength > 0 &&
|
|
sarMax > sarStep &&
|
|
//
|
|
// XCA ...
|
|
(IsValid(scMethod, scPeriod) &&
|
|
IsValid(mcMethod, mcPeriod) &&
|
|
IsValid(lcMethod, lcPeriod) &&
|
|
IsValid(hcMethod, hcPeriod))
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve MAx Length ...
|
|
int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
result = MathMax(kiLength, swingLength);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Conditions ...
|
|
struct X121XCAConditions
|
|
{
|
|
//
|
|
// Common ...
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
// Buffers ...
|
|
double kiBuffer[];
|
|
double tkiBuffer[];
|
|
double sHHBuffer[];
|
|
double sLLBuffer[];
|
|
double mHHBuffer[];
|
|
double mLLBuffer[];
|
|
double lHHBuffer[];
|
|
double lLLBuffer[];
|
|
double hHHBuffer[];
|
|
double hLLBuffer[];
|
|
double sarBuffer[];
|
|
double peakBuffer[];
|
|
double valeBuffer[];
|
|
double trendBuffer[];
|
|
double kiStateBuffer[];
|
|
double supportBuffer[];
|
|
double tkiStateBuffer[];
|
|
double swingLowBuffer[];
|
|
double swingHighBuffer[];
|
|
double resistanceBuffer[];
|
|
double peakGoldenBuffer[];
|
|
double valeGoldenBuffer[];
|
|
double fiboLevel1Buffer[];
|
|
double fiboLevel2Buffer[];
|
|
double fiboLevel3Buffer[];
|
|
double trendStateBuffer[];
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
bool isKIRejectUp;
|
|
bool isKIRejectDown;
|
|
|
|
//
|
|
bool isKIBullish;
|
|
bool isKIBearish;
|
|
|
|
//
|
|
bool isKISwitchedToBullish;
|
|
bool isKISwitchedToBearish;
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
bool isTKIRejectUp;
|
|
bool isTKIRejectDown;
|
|
|
|
//
|
|
bool isTKIBullish;
|
|
bool isTKIBearish;
|
|
|
|
//
|
|
bool isTKISwitchedToBullish;
|
|
bool isTKISwitchedToBearish;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
bool isSarBullish;
|
|
bool isSarBearish;
|
|
|
|
//
|
|
bool isSarSwitchedToBullish;
|
|
bool isSarSwitchedToBearish;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
bool isPeakSameLast;
|
|
bool isPeakOverLast;
|
|
bool isPeakUnderLast;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
bool isValeSameLast;
|
|
bool isValeOverLast;
|
|
bool isValeUnderLast;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
bool isTrendRejectUp;
|
|
bool isTrendRejectDown;
|
|
|
|
//
|
|
bool isTrendBullish;
|
|
bool isTrendBearish;
|
|
|
|
//
|
|
bool isTrendSwitchedToBullish;
|
|
bool isTrendSwitchedToBearish;
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
bool isSupportSameLast;
|
|
bool isSupportOverLast;
|
|
bool isSupportUnderLast;
|
|
|
|
//
|
|
bool isLastSupportBreaked;
|
|
bool isLastSupportRejected;
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
bool isResistanceSameLast;
|
|
bool isResistanceOverLast;
|
|
bool isResistanceUnderLast;
|
|
|
|
//
|
|
bool isLastResistanceBreaked;
|
|
bool isLastResistanceRejected;
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
bool isSwingLowSameLast;
|
|
bool isSwingLowOverLast;
|
|
bool isSwingLowUnderLast;
|
|
|
|
//
|
|
bool isLastSwingLowBreaked;
|
|
bool isLastSwingLowRejected;
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
bool isSwingHighSameLast;
|
|
bool isSwingHighOverLast;
|
|
bool isSwingHighUnderLast;
|
|
|
|
//
|
|
bool isLastSwingHighBreaked;
|
|
bool isLastSwingHighRejected;
|
|
|
|
//
|
|
// COMPLEX Conditions ...
|
|
|
|
//
|
|
bool isPeakIsPivot;
|
|
bool isValeIsPivot;
|
|
|
|
//
|
|
bool isSwingLowSameAsVale;
|
|
bool isSwingHighSameAsPeak;
|
|
|
|
//
|
|
bool isSupportSameAsVale;
|
|
bool isResistanceSameAsPeak;
|
|
|
|
//
|
|
bool isSupportSameAsSwingLow;
|
|
bool isResistanceSameAsSwingHigh;
|
|
|
|
//
|
|
// Constructor ...
|
|
X121XCAConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleaning Up ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
// Commons ...
|
|
symbol = NULL;
|
|
period = NULL;
|
|
time = NULL;
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
Clean(kiBuffer);
|
|
Clean(tkiBuffer);
|
|
Clean(sHHBuffer);
|
|
Clean(sLLBuffer);
|
|
Clean(mHHBuffer);
|
|
Clean(mLLBuffer);
|
|
Clean(lHHBuffer);
|
|
Clean(lLLBuffer);
|
|
Clean(hHHBuffer);
|
|
Clean(hLLBuffer);
|
|
Clean(sarBuffer);
|
|
Clean(peakBuffer);
|
|
Clean(valeBuffer);
|
|
Clean(trendBuffer);
|
|
Clean(kiStateBuffer);
|
|
Clean(supportBuffer);
|
|
Clean(tkiStateBuffer);
|
|
Clean(swingLowBuffer);
|
|
Clean(swingHighBuffer);
|
|
Clean(resistanceBuffer);
|
|
Clean(peakGoldenBuffer);
|
|
Clean(valeGoldenBuffer);
|
|
Clean(fiboLevel1Buffer);
|
|
Clean(fiboLevel2Buffer);
|
|
Clean(fiboLevel3Buffer);
|
|
Clean(trendStateBuffer);
|
|
|
|
//
|
|
ArraySetAsSeries(kiBuffer, true);
|
|
ArraySetAsSeries(tkiBuffer, 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(sarBuffer, true);
|
|
ArraySetAsSeries(peakBuffer, true);
|
|
ArraySetAsSeries(valeBuffer, true);
|
|
ArraySetAsSeries(trendBuffer, true);
|
|
ArraySetAsSeries(kiStateBuffer, true);
|
|
ArraySetAsSeries(supportBuffer, true);
|
|
ArraySetAsSeries(tkiStateBuffer, true);
|
|
ArraySetAsSeries(swingLowBuffer, true);
|
|
ArraySetAsSeries(swingHighBuffer, true);
|
|
ArraySetAsSeries(resistanceBuffer, true);
|
|
ArraySetAsSeries(peakGoldenBuffer, true);
|
|
ArraySetAsSeries(valeGoldenBuffer, true);
|
|
ArraySetAsSeries(fiboLevel1Buffer, true);
|
|
ArraySetAsSeries(fiboLevel2Buffer, true);
|
|
ArraySetAsSeries(fiboLevel3Buffer, true);
|
|
ArraySetAsSeries(trendStateBuffer, true);
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
isKIRejectUp = false;
|
|
isKIRejectDown = false;
|
|
|
|
//
|
|
isKIBullish = false;
|
|
isKIBearish = false;
|
|
|
|
//
|
|
isKISwitchedToBullish = false;
|
|
isKISwitchedToBearish = false;
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
isTKIRejectUp = false;
|
|
isTKIRejectDown = false;
|
|
|
|
//
|
|
isTKIBullish = false;
|
|
isTKIBearish = false;
|
|
|
|
//
|
|
isTKISwitchedToBullish = false;
|
|
isTKISwitchedToBearish = false;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
isSarBullish = false;
|
|
isSarBearish = false;
|
|
|
|
//
|
|
isSarSwitchedToBullish = false;
|
|
isSarSwitchedToBearish = false;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
isPeakSameLast = false;
|
|
isPeakOverLast = false;
|
|
isPeakUnderLast = false;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
isValeSameLast = false;
|
|
isValeOverLast = false;
|
|
isValeUnderLast = false;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
isTrendRejectUp = false;
|
|
isTrendRejectDown = false;
|
|
|
|
//
|
|
isTrendBullish = false;
|
|
isTrendBearish = false;
|
|
|
|
//
|
|
isTrendSwitchedToBullish = false;
|
|
isTrendSwitchedToBearish = false;
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
isSupportSameLast = false;
|
|
isSupportOverLast = false;
|
|
isSupportUnderLast = false;
|
|
|
|
//
|
|
isLastSupportBreaked = false;
|
|
isLastSupportRejected = false;
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
isResistanceSameLast = false;
|
|
isResistanceOverLast = false;
|
|
isResistanceUnderLast = false;
|
|
|
|
//
|
|
isLastResistanceBreaked = false;
|
|
isLastResistanceRejected = false;
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
isSwingLowSameLast = false;
|
|
isSwingLowOverLast = false;
|
|
isSwingLowUnderLast = false;
|
|
|
|
//
|
|
isLastSwingLowBreaked = false;
|
|
isLastSwingLowRejected = false;
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
isSwingHighSameLast = false;
|
|
isSwingHighOverLast = false;
|
|
isSwingHighUnderLast = false;
|
|
|
|
//
|
|
isLastSwingHighBreaked = false;
|
|
isLastSwingHighRejected = false;
|
|
|
|
//
|
|
// COMPLEX Conditions ...
|
|
|
|
//
|
|
isPeakIsPivot = false;
|
|
isValeIsPivot = false;
|
|
|
|
//
|
|
isSwingLowSameAsVale = false;
|
|
isSwingHighSameAsPeak = false;
|
|
|
|
//
|
|
isSupportSameAsVale = false;
|
|
isResistanceSameAsPeak = false;
|
|
|
|
//
|
|
isSupportSameAsSwingLow = false;
|
|
isResistanceSameAsSwingHigh = 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;
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
if (isKIBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isKIRejectUp)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isKISwitchedToBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isKIBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isKIRejectDown)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isKISwitchedToBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
if (isTKIBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isTKIRejectUp)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isTKISwitchedToBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isTKIBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isTKIRejectDown)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isTKISwitchedToBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
if (isSarBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isSarSwitchedToBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isSarBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isSarSwitchedToBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
if (isTrendBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isTrendRejectUp)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isTrendSwitchedToBullish)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isTrendBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isTrendRejectDown)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isTrendSwitchedToBearish)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
if (isSupportSameLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isSupportOverLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isLastSupportRejected)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isSupportUnderLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isLastSupportBreaked)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
if (isResistanceOverLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isLastResistanceBreaked)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isResistanceSameLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isResistanceUnderLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isLastResistanceRejected)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
if (isSwingLowSameLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isSwingLowOverLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isLastSwingLowRejected)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isSwingLowUnderLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isLastSwingLowBreaked)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
if (isSwingHighOverLast)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
if (isLastSwingHighBreaked)
|
|
{
|
|
bullishScore += minScore;
|
|
}
|
|
|
|
//
|
|
if (isSwingHighSameLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isSwingHighUnderLast)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
if (isLastSwingHighRejected)
|
|
{
|
|
bearishScore += minScore;
|
|
}
|
|
|
|
//
|
|
// COMPLEX Conditions ...
|
|
|
|
//
|
|
if (isValeIsPivot)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isSupportSameAsVale)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isSwingLowSameAsVale)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
if (isSupportSameAsSwingLow)
|
|
{
|
|
bullishScore += score;
|
|
}
|
|
|
|
//
|
|
if (isPeakIsPivot)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isSwingHighSameAsPeak)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isResistanceSameAsPeak)
|
|
{
|
|
bearishScore += score;
|
|
}
|
|
if (isResistanceSameAsSwingHigh)
|
|
{
|
|
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 +
|
|
"XCA: " + separator +
|
|
"-----------------------" + separator +
|
|
ToString("isKIRejectUp", isKIRejectUp, ignoreFalseConditions, separator) +
|
|
ToString("isKIRejectDown", isKIRejectDown, ignoreFalseConditions, separator) +
|
|
ToString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) +
|
|
ToString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) +
|
|
ToString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) +
|
|
ToString("isTKIRejectUp", isTKIRejectUp, ignoreFalseConditions, separator) +
|
|
ToString("isTKIRejectDown", isTKIRejectDown, ignoreFalseConditions, separator) +
|
|
ToString("isTKIBullish", isTKIBullish, ignoreFalseConditions, separator) +
|
|
ToString("isTKIBearish", isTKIBearish, ignoreFalseConditions, separator) +
|
|
ToString("isTKISwitchedToBullish", isTKISwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToString("isTKISwitchedToBearish", isTKISwitchedToBearish, ignoreFalseConditions, separator) +
|
|
ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) +
|
|
ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) +
|
|
ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isValeSameLast", isValeSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isValeOverLast", isValeOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isValeUnderLast", isValeUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isTrendRejectUp", isTrendRejectUp, ignoreFalseConditions, separator) +
|
|
ToString("isTrendRejectDown", isTrendRejectDown, ignoreFalseConditions, separator) +
|
|
ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) +
|
|
ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) +
|
|
ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) +
|
|
ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) +
|
|
ToString("isSupportSameLast", isSupportSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isSupportOverLast", isSupportOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isSupportUnderLast", isSupportUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isLastSupportBreaked", isLastSupportBreaked, ignoreFalseConditions, separator) +
|
|
ToString("isLastSupportRejected", isLastSupportRejected, ignoreFalseConditions, separator) +
|
|
ToString("isResistanceSameLast", isResistanceSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isResistanceOverLast", isResistanceOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isResistanceUnderLast", isResistanceUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isLastResistanceBreaked", isLastResistanceBreaked, ignoreFalseConditions, separator) +
|
|
ToString("isLastResistanceRejected", isLastResistanceRejected, ignoreFalseConditions, separator) +
|
|
ToString("isSwingLowSameLast", isSwingLowSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isSwingLowOverLast", isSwingLowOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isSwingLowUnderLast", isSwingLowUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isLastSwingLowBreaked", isLastSwingLowBreaked, ignoreFalseConditions, separator) +
|
|
ToString("isLastSwingLowRejected", isLastSwingLowRejected, ignoreFalseConditions, separator) +
|
|
ToString("isSwingHighSameLast", isSwingHighSameLast, ignoreFalseConditions, separator) +
|
|
ToString("isSwingHighOverLast", isSwingHighOverLast, ignoreFalseConditions, separator) +
|
|
ToString("isSwingHighUnderLast", isSwingHighUnderLast, ignoreFalseConditions, separator) +
|
|
ToString("isLastSwingHighBreaked", isLastSwingHighBreaked, ignoreFalseConditions, separator) +
|
|
ToString("isLastSwingHighRejected", isLastSwingHighRejected, ignoreFalseConditions, separator) +
|
|
ToString("isPeakIsPivot", isPeakIsPivot, ignoreFalseConditions, separator) +
|
|
ToString("isValeIsPivot", isValeIsPivot, ignoreFalseConditions, separator) +
|
|
ToString("isSwingLowSameAsVale", isSwingLowSameAsVale, ignoreFalseConditions, separator) +
|
|
ToString("isSwingHighSameAsPeak", isSwingHighSameAsPeak, ignoreFalseConditions, separator) +
|
|
ToString("isSupportSameAsVale", isSupportSameAsVale, ignoreFalseConditions, separator) +
|
|
ToString("isResistanceSameAsPeak", isResistanceSameAsPeak, ignoreFalseConditions, separator) +
|
|
ToString("isSupportSameAsSwingLow", isSupportSameAsSwingLow, ignoreFalseConditions, separator) +
|
|
ToString("isResistanceSameAsSwingHigh", isResistanceSameAsSwingHigh, 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 XCX121XCAHelper : public XCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Constructors ...
|
|
XCX121XCAHelper()
|
|
: XCBaseHelper(_Symbol, _Period)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XCX121XCAHelper()
|
|
{
|
|
//
|
|
mInputs.Clean();
|
|
|
|
//
|
|
Clean(kiBuffer);
|
|
Clean(tkiBuffer);
|
|
Clean(sHHBuffer);
|
|
Clean(sLLBuffer);
|
|
Clean(mHHBuffer);
|
|
Clean(mLLBuffer);
|
|
Clean(lHHBuffer);
|
|
Clean(lLLBuffer);
|
|
Clean(hHHBuffer);
|
|
Clean(hLLBuffer);
|
|
Clean(sarBuffer);
|
|
Clean(peakBuffer);
|
|
Clean(valeBuffer);
|
|
Clean(trendBuffer);
|
|
Clean(kiStateBuffer);
|
|
Clean(supportBuffer);
|
|
Clean(tkiStateBuffer);
|
|
Clean(swingLowBuffer);
|
|
Clean(swingHighBuffer);
|
|
Clean(resistanceBuffer);
|
|
Clean(peakGoldenBuffer);
|
|
Clean(valeGoldenBuffer);
|
|
Clean(fiboLevel1Buffer);
|
|
Clean(fiboLevel2Buffer);
|
|
Clean(fiboLevel3Buffer);
|
|
Clean(trendStateBuffer);
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
bool Init(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period, // Trading Period
|
|
X121XCAInputs &inputs // Inputs
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
ArraySetAsSeries(kiBuffer, true);
|
|
ArraySetAsSeries(tkiBuffer, 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(sarBuffer, true);
|
|
ArraySetAsSeries(peakBuffer, true);
|
|
ArraySetAsSeries(valeBuffer, true);
|
|
ArraySetAsSeries(trendBuffer, true);
|
|
ArraySetAsSeries(kiStateBuffer, true);
|
|
ArraySetAsSeries(supportBuffer, true);
|
|
ArraySetAsSeries(tkiStateBuffer, true);
|
|
ArraySetAsSeries(swingLowBuffer, true);
|
|
ArraySetAsSeries(swingHighBuffer, true);
|
|
ArraySetAsSeries(resistanceBuffer, true);
|
|
ArraySetAsSeries(peakGoldenBuffer, true);
|
|
ArraySetAsSeries(valeGoldenBuffer, true);
|
|
ArraySetAsSeries(fiboLevel1Buffer, true);
|
|
ArraySetAsSeries(fiboLevel2Buffer, true);
|
|
ArraySetAsSeries(fiboLevel3Buffer, true);
|
|
ArraySetAsSeries(trendStateBuffer, true);
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.x121.xca",
|
|
"", // Market ...
|
|
"", // Short ...
|
|
mInputs.scMethod,
|
|
mInputs.scPeriod,
|
|
"", // Medium ...
|
|
mInputs.mcMethod,
|
|
mInputs.mcPeriod,
|
|
"", // Long ...
|
|
mInputs.lcMethod,
|
|
mInputs.lcPeriod,
|
|
"", // Hind ...
|
|
mInputs.hcMethod,
|
|
mInputs.hcPeriod,
|
|
"", // Boundary Detection ...
|
|
mInputs.hhMode,
|
|
mInputs.llMode,
|
|
"", // Fibo Levels ...
|
|
mInputs.fiboLevel1,
|
|
mInputs.fiboLevel2,
|
|
mInputs.fiboLevel3,
|
|
"", // Sar Detection ...
|
|
mInputs.sarStep,
|
|
mInputs.sarMax,
|
|
"", // KI ...
|
|
mInputs.kiLength,
|
|
"", // Swing Detection ...
|
|
mInputs.swingLength,
|
|
"", // Support and Resistance ...
|
|
mInputs.supResSmoothingLength,
|
|
mInputs.supResSmoothingMode,
|
|
"", // Presentation ...
|
|
mInputs.startCalculationForLastBars,
|
|
mInputs.showSar,
|
|
mInputs.showKI,
|
|
mInputs.showTKI,
|
|
mInputs.showTrend,
|
|
mInputs.showSwings,
|
|
mInputs.showFiboLevel1,
|
|
mInputs.showFiboLevel2,
|
|
mInputs.showFiboLevel3,
|
|
mInputs.showPeaksAndVales,
|
|
mInputs.showPeakAndValeGolden,
|
|
mInputs.showSupportAndResistance,
|
|
mInputs.showShortCycle,
|
|
mInputs.showMediumCycle,
|
|
mInputs.showLongCycle,
|
|
mInputs.showHindCycle,
|
|
//
|
|
mInputs.sarArrowCode,
|
|
mInputs.peakArrowCode,
|
|
mInputs.valeArrowCode,
|
|
mInputs.swingLowArrowCode,
|
|
mInputs.swingHighArrowCode
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
|
|
//
|
|
X121XCAInputs GetInputs()
|
|
{
|
|
return mInputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
X121XCAInputs &inputs // Configs
|
|
)
|
|
{
|
|
//
|
|
return Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
inputs
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Readers ...
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
double GetKI(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(kiBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return kiBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyKI(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
kiBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// KI STATE ...
|
|
|
|
//
|
|
double GetKIState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(kiStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return kiStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyKIState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate(start);
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
0,
|
|
count,
|
|
kiStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
double GetTKI(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(tkiBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return tkiBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyTKI(
|
|
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,
|
|
tkiBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// TKI STATE ...
|
|
|
|
//
|
|
double GetTKIState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(tkiStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return tkiStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyTKIState(
|
|
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,
|
|
tkiStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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 ...
|
|
|
|
//
|
|
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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// 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 ...
|
|
|
|
//
|
|
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
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
double GetSupport(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(supportBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return supportBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySupport(
|
|
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,
|
|
supportBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
double GetResistance(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(resistanceBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return resistanceBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyResistance(
|
|
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,
|
|
resistanceBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
double GetSwingLow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(swingLowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return swingLowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySwingLow(
|
|
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,
|
|
swingLowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
double GetSwingHigh(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(swingHighBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return swingHighBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopySwingHigh(
|
|
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,
|
|
swingHighBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// FIBO Level 1 ...
|
|
|
|
//
|
|
double GetFiboLevel1(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(fiboLevel1Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fiboLevel1Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyFiboLevel1(
|
|
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,
|
|
fiboLevel1Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// FIBO Level 2 ...
|
|
|
|
//
|
|
double GetFiboLevel2(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(fiboLevel2Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fiboLevel2Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyFiboLevel2(
|
|
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,
|
|
fiboLevel2Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// FIBO Level 3 ...
|
|
|
|
//
|
|
double GetFiboLevel3(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate(barIndex);
|
|
|
|
//
|
|
int count = ArraySize(fiboLevel3Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fiboLevel3Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
int CopyFiboLevel3(
|
|
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,
|
|
fiboLevel3Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
void Free() override
|
|
{
|
|
Cleanup(10);
|
|
}
|
|
|
|
//
|
|
bool GetConditions(
|
|
X121XCAConditions &conditions, //
|
|
int barIndex = 0, //
|
|
int loopback = 5 //
|
|
)
|
|
{
|
|
//
|
|
bool result = true;
|
|
|
|
//
|
|
if (loopback < 5)
|
|
{
|
|
loopback = 5;
|
|
}
|
|
|
|
//
|
|
conditions.Clean();
|
|
|
|
//
|
|
conditions.symbol = mSymbol;
|
|
conditions.period = mPeriod;
|
|
conditions.time = TimeCurrent();
|
|
|
|
//
|
|
int zIndex = barIndex;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
XOHCL zBar;
|
|
result = zBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
zIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = cBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
cIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = pBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
pIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
CopyKI(
|
|
zIndex,
|
|
loopback,
|
|
conditions.kiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyKIState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.kiStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTKI(
|
|
zIndex,
|
|
loopback,
|
|
conditions.tkiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTKIState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.tkiStateBuffer //
|
|
);
|
|
|
|
//
|
|
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 //
|
|
);
|
|
|
|
//
|
|
CopySar(
|
|
zIndex,
|
|
loopback,
|
|
conditions.sarBuffer //
|
|
);
|
|
|
|
//
|
|
CopyPeak(
|
|
zIndex,
|
|
loopback,
|
|
conditions.peakBuffer //
|
|
);
|
|
|
|
//
|
|
CopyPeakGolden(
|
|
zIndex,
|
|
loopback,
|
|
conditions.peakGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyVale(
|
|
zIndex,
|
|
loopback,
|
|
conditions.valeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyValeGolden(
|
|
zIndex,
|
|
loopback,
|
|
conditions.valeGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTrend(
|
|
zIndex,
|
|
loopback,
|
|
conditions.trendBuffer //
|
|
);
|
|
|
|
//
|
|
CopyTrendState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.trendStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopySupport(
|
|
zIndex,
|
|
loopback,
|
|
conditions.supportBuffer //
|
|
);
|
|
|
|
//
|
|
CopyResistance(
|
|
zIndex,
|
|
loopback,
|
|
conditions.resistanceBuffer //
|
|
);
|
|
|
|
//
|
|
CopySwingLow(
|
|
zIndex,
|
|
loopback,
|
|
conditions.swingLowBuffer //
|
|
);
|
|
|
|
//
|
|
CopySwingHigh(
|
|
zIndex,
|
|
loopback,
|
|
conditions.swingHighBuffer //
|
|
);
|
|
|
|
//
|
|
CopyFiboLevel1(
|
|
zIndex,
|
|
loopback,
|
|
conditions.fiboLevel1Buffer //
|
|
);
|
|
|
|
//
|
|
CopyFiboLevel2(
|
|
zIndex,
|
|
loopback,
|
|
conditions.fiboLevel2Buffer //
|
|
);
|
|
|
|
//
|
|
CopyFiboLevel3(
|
|
zIndex,
|
|
loopback,
|
|
conditions.fiboLevel3Buffer //
|
|
);
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
int zIDX = 0;
|
|
int cIDX = 1;
|
|
int pIDX = cIDX + 1;
|
|
int p2IDX = pIDX + 1;
|
|
int p3IDX = p2IDX + 1;
|
|
int p4IDX = p3IDX + 1;
|
|
|
|
//
|
|
// Calculate ...
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
double cKI = conditions.kiBuffer[cIDX];
|
|
double pKI = conditions.kiBuffer[pIDX];
|
|
double p2KI = conditions.kiBuffer[p2IDX];
|
|
|
|
//
|
|
double cKIState = conditions.kiStateBuffer[cIDX];
|
|
double pKIState = conditions.kiStateBuffer[pIDX];
|
|
double p2KIState = conditions.kiStateBuffer[p2IDX];
|
|
|
|
//
|
|
bool isKIRejectUp = cBar.IsRejected(
|
|
cKI,
|
|
X_DIRECTION_BULLISH,
|
|
false,
|
|
false //
|
|
);
|
|
bool isKIRejectDown = cBar.IsRejected(
|
|
cKI,
|
|
X_DIRECTION_BEARISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
bool isKIBullish = cKIState > 0;
|
|
bool isKIBullishPrev = pKIState > 0;
|
|
|
|
//
|
|
bool isKIBearish = cKIState < 0;
|
|
bool isKIBearishPrev = pKIState < 0;
|
|
|
|
//
|
|
bool isKISwitchedToBullish = isKIBullish &&
|
|
!isKIBullishPrev;
|
|
bool isKISwitchedToBearish = isKIBearish &&
|
|
!isKIBearishPrev;
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
double cTKI = conditions.tkiBuffer[cIDX];
|
|
double pTKI = conditions.tkiBuffer[pIDX];
|
|
double p2TKI = conditions.tkiBuffer[p2IDX];
|
|
|
|
//
|
|
double cTKIState = conditions.tkiStateBuffer[cIDX];
|
|
double pTKIState = conditions.tkiStateBuffer[pIDX];
|
|
double p2TKIState = conditions.tkiStateBuffer[p2IDX];
|
|
|
|
//
|
|
bool isTKIRejectUp = cBar.IsRejected(
|
|
cTKI,
|
|
X_DIRECTION_BULLISH,
|
|
false,
|
|
false //
|
|
);
|
|
bool isTKIRejectDown = cBar.IsRejected(
|
|
cTKI,
|
|
X_DIRECTION_BEARISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
bool isTKIBullish = cTKIState > 0;
|
|
bool isTKIBullishPrev = pTKIState > 0;
|
|
|
|
//
|
|
bool isTKIBearish = cTKIState < 0;
|
|
bool isTKIBearishPrev = pTKIState < 0;
|
|
|
|
//
|
|
bool isTKISwitchedToBullish = isTKIBullish &&
|
|
!isTKIBullishPrev;
|
|
bool isTKISwitchedToBearish = isTKIBearish &&
|
|
!isTKIBearishPrev;
|
|
|
|
//
|
|
// SAR ...
|
|
|
|
//
|
|
double cSar = conditions.sarBuffer[cIDX];
|
|
double pSar = conditions.sarBuffer[pIDX];
|
|
|
|
//
|
|
bool isSarBullish = cBar.low > cSar;
|
|
bool isSarBullishPrev = pBar.low > pSar;
|
|
|
|
//
|
|
bool isSarBearish = cBar.high < cSar;
|
|
bool isSarBearishPrev = pBar.high < pSar;
|
|
|
|
//
|
|
bool isSarSwitchedToBullish = isSarBullish &&
|
|
!isSarBullishPrev;
|
|
bool isSarSwitchedToBearish = isSarBearish &&
|
|
!isSarBearishPrev;
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
double cPeak = conditions.peakBuffer[cIDX];
|
|
double pPeak = conditions.peakBuffer[pIDX];
|
|
|
|
//
|
|
bool isPeakSameLast = cPeak == pPeak;
|
|
bool isPeakOverLast = cPeak > pPeak;
|
|
bool isPeakUnderLast = cPeak < pPeak;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
double cVale = conditions.valeBuffer[cIDX];
|
|
double pVale = conditions.valeBuffer[pIDX];
|
|
|
|
//
|
|
bool isValeSameLast = cVale == pVale;
|
|
bool isValeOverLast = cVale > pVale;
|
|
bool isValeUnderLast = cVale < pVale;
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
double cTrend = conditions.trendBuffer[cIDX];
|
|
double pTrend = conditions.trendBuffer[pIDX];
|
|
|
|
//
|
|
double cTrendState = conditions.trendStateBuffer[cIDX];
|
|
double pTrendState = conditions.trendStateBuffer[pIDX];
|
|
|
|
//
|
|
bool isTrendRejectUp = cBar.IsRejected(
|
|
cTrend,
|
|
X_DIRECTION_BULLISH,
|
|
false,
|
|
false //
|
|
);
|
|
bool isTrendRejectDown = cBar.IsRejected(
|
|
cTrend,
|
|
X_DIRECTION_BEARISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
bool isTrendBullish = cTrendState > 0;
|
|
bool isTrendBullishPrev = pTrendState > 0;
|
|
|
|
//
|
|
bool isTrendBearish = cTrendState < 0;
|
|
bool isTrendBearishPrev = pTrendState < 0;
|
|
|
|
//
|
|
bool isTrendSwitchedToBullish = isTrendBullish &&
|
|
!isTrendBullishPrev;
|
|
bool isTrendSwitchedToBearish = isTrendBearish &&
|
|
!isTrendBearishPrev;
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
double cSupport = conditions.supportBuffer[cIDX];
|
|
double pSupport = conditions.supportBuffer[pIDX];
|
|
|
|
//
|
|
bool isSupportSameLast = cSupport == pSupport;
|
|
bool isSupportOverLast = cSupport > pSupport;
|
|
bool isSupportUnderLast = cSupport < pSupport;
|
|
|
|
//
|
|
bool isLastSupportBreaked = cBar.IsBreaked(
|
|
pSupport,
|
|
X_DIRECTION_BEARISH //
|
|
);
|
|
bool isLastSupportRejected = cBar.IsRejected(
|
|
pSupport,
|
|
X_DIRECTION_BULLISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
double cResistance = conditions.resistanceBuffer[cIDX];
|
|
double pResistance = conditions.resistanceBuffer[pIDX];
|
|
|
|
//
|
|
bool isResistanceSameLast = cResistance == pResistance;
|
|
bool isResistanceOverLast = cResistance > pResistance;
|
|
bool isResistanceUnderLast = cResistance < pResistance;
|
|
|
|
//
|
|
bool isLastResistanceBreaked = cBar.IsBreaked(
|
|
pResistance,
|
|
X_DIRECTION_BULLISH //
|
|
);
|
|
bool isLastResistanceRejected = cBar.IsRejected(
|
|
pResistance,
|
|
X_DIRECTION_BEARISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
double cSwingLow = conditions.swingLowBuffer[cIDX];
|
|
double pSwingLow = conditions.swingLowBuffer[pIDX];
|
|
|
|
//
|
|
bool isSwingLowSameLast = cSwingLow == pSwingLow;
|
|
bool isSwingLowOverLast = cSwingLow > pSwingLow;
|
|
bool isSwingLowUnderLast = cSwingLow < pSwingLow;
|
|
|
|
//
|
|
bool isLastSwingLowBreaked = cBar.IsBreaked(
|
|
pSwingLow,
|
|
X_DIRECTION_BEARISH //
|
|
);
|
|
bool isLastSwingLowRejected = cBar.IsRejected(
|
|
pSwingLow,
|
|
X_DIRECTION_BULLISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
double cSwingHigh = conditions.swingHighBuffer[cIDX];
|
|
double pSwingHigh = conditions.swingHighBuffer[pIDX];
|
|
|
|
//
|
|
bool isSwingHighSameLast = cSwingHigh == pSwingHigh;
|
|
bool isSwingHighOverLast = cSwingHigh > pSwingHigh;
|
|
bool isSwingHighUnderLast = cSwingHigh < pSwingHigh;
|
|
|
|
//
|
|
bool isLastSwingHighBreaked = cBar.IsBreaked(
|
|
pSwingHigh,
|
|
X_DIRECTION_BULLISH //
|
|
);
|
|
bool isLastSwingHighRejected = cBar.IsRejected(
|
|
pSwingHigh,
|
|
X_DIRECTION_BEARISH,
|
|
false,
|
|
false //
|
|
);
|
|
|
|
//
|
|
// COMPLEX Conditions ...
|
|
|
|
//
|
|
bool isSwingLowSameAsVale = cSwingLow == cVale;
|
|
bool isSwingHighSameAsPeak = cSwingHigh == cPeak;
|
|
|
|
//
|
|
bool isSupportSameAsVale = cSupport == cVale;
|
|
bool isResistanceSameAsPeak = cResistance == cPeak;
|
|
|
|
//
|
|
bool isSupportSameAsSwingLow = cSupport == cSwingLow;
|
|
bool isResistanceSameAsSwingHigh = cResistance == cSwingHigh;
|
|
|
|
//
|
|
bool isPeakIsPivot = isSwingHighSameAsPeak &&
|
|
isResistanceSameAsPeak &&
|
|
isResistanceSameAsSwingHigh;
|
|
bool isValeIsPivot = isSwingLowSameAsVale &&
|
|
isSupportSameAsVale &&
|
|
isSupportSameAsSwingLow;
|
|
|
|
//
|
|
// Attached ...
|
|
|
|
//
|
|
conditions.isKIBullish = isKIBullish;
|
|
conditions.isKIBearish = isKIBearish;
|
|
conditions.isKIRejectUp = isKIRejectUp;
|
|
conditions.isTKIBullish = isTKIBullish;
|
|
conditions.isTKIBearish = isTKIBearish;
|
|
conditions.isSarBullish = isSarBullish;
|
|
conditions.isSarBearish = isSarBearish;
|
|
conditions.isTKIRejectUp = isTKIRejectUp;
|
|
conditions.isPeakIsPivot = isPeakIsPivot;
|
|
conditions.isValeIsPivot = isValeIsPivot;
|
|
conditions.isKIRejectDown = isKIRejectDown;
|
|
conditions.isPeakSameLast = isPeakSameLast;
|
|
conditions.isPeakOverLast = isPeakOverLast;
|
|
conditions.isValeSameLast = isValeSameLast;
|
|
conditions.isValeOverLast = isValeOverLast;
|
|
conditions.isTrendBullish = isTrendBullish;
|
|
conditions.isTrendBearish = isTrendBearish;
|
|
conditions.isTKIRejectDown = isTKIRejectDown;
|
|
conditions.isPeakUnderLast = isPeakUnderLast;
|
|
conditions.isValeUnderLast = isValeUnderLast;
|
|
conditions.isTrendRejectUp = isTrendRejectUp;
|
|
conditions.isTrendRejectDown = isTrendRejectDown;
|
|
conditions.isSupportSameLast = isSupportSameLast;
|
|
conditions.isSupportOverLast = isSupportOverLast;
|
|
conditions.isSupportUnderLast = isSupportUnderLast;
|
|
conditions.isSwingLowSameLast = isSwingLowSameLast;
|
|
conditions.isSwingLowOverLast = isSwingLowOverLast;
|
|
conditions.isSwingLowUnderLast = isSwingLowUnderLast;
|
|
conditions.isSwingHighSameLast = isSwingHighSameLast;
|
|
conditions.isSwingHighOverLast = isSwingHighOverLast;
|
|
conditions.isSupportSameAsVale = isSupportSameAsVale;
|
|
conditions.isLastSupportBreaked = isLastSupportBreaked;
|
|
conditions.isResistanceSameLast = isResistanceSameLast;
|
|
conditions.isResistanceOverLast = isResistanceOverLast;
|
|
conditions.isSwingHighUnderLast = isSwingHighUnderLast;
|
|
conditions.isSwingLowSameAsVale = isSwingLowSameAsVale;
|
|
conditions.isLastSupportRejected = isLastSupportRejected;
|
|
conditions.isResistanceUnderLast = isResistanceUnderLast;
|
|
conditions.isKISwitchedToBullish = isKISwitchedToBullish;
|
|
conditions.isKISwitchedToBearish = isKISwitchedToBearish;
|
|
conditions.isLastSwingLowBreaked = isLastSwingLowBreaked;
|
|
conditions.isSwingHighSameAsPeak = isSwingHighSameAsPeak;
|
|
conditions.isTKISwitchedToBullish = isTKISwitchedToBullish;
|
|
conditions.isTKISwitchedToBearish = isTKISwitchedToBearish;
|
|
conditions.isLastSwingLowRejected = isLastSwingLowRejected;
|
|
conditions.isSarSwitchedToBullish = isSarSwitchedToBullish;
|
|
conditions.isSarSwitchedToBearish = isSarSwitchedToBearish;
|
|
conditions.isLastSwingHighBreaked = isLastSwingHighBreaked;
|
|
conditions.isResistanceSameAsPeak = isResistanceSameAsPeak;
|
|
conditions.isLastSwingHighRejected = isLastSwingHighRejected;
|
|
conditions.isLastResistanceBreaked = isLastResistanceBreaked;
|
|
conditions.isSupportSameAsSwingLow = isSupportSameAsSwingLow;
|
|
conditions.isLastResistanceRejected = isLastResistanceRejected;
|
|
conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish;
|
|
conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish;
|
|
conditions.isResistanceSameAsSwingHigh = isResistanceSameAsSwingHigh;
|
|
|
|
//
|
|
Cleanup();
|
|
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
X121XCAInputs mInputs; // Inputs ...
|
|
|
|
//
|
|
// Buffers ...
|
|
double kiBuffer[];
|
|
double tkiBuffer[];
|
|
double sHHBuffer[];
|
|
double sLLBuffer[];
|
|
double mHHBuffer[];
|
|
double mLLBuffer[];
|
|
double lHHBuffer[];
|
|
double lLLBuffer[];
|
|
double hHHBuffer[];
|
|
double hLLBuffer[];
|
|
double sarBuffer[];
|
|
double peakBuffer[];
|
|
double valeBuffer[];
|
|
double trendBuffer[];
|
|
double kiStateBuffer[];
|
|
double supportBuffer[];
|
|
double tkiStateBuffer[];
|
|
double swingLowBuffer[];
|
|
double swingHighBuffer[];
|
|
double resistanceBuffer[];
|
|
double peakGoldenBuffer[];
|
|
double valeGoldenBuffer[];
|
|
double fiboLevel1Buffer[];
|
|
double fiboLevel2Buffer[];
|
|
double fiboLevel3Buffer[];
|
|
double trendStateBuffer[];
|
|
|
|
//
|
|
void Calculate(
|
|
int barIndex = 0,
|
|
int maxRequiredBars = 100 //
|
|
)
|
|
{
|
|
//
|
|
// Buffers ...
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_KI_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
kiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_TKI_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
tkiBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_S_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_S_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_M_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
mHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_M_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
mLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_L_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
lHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_L_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
lLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_H_HH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hHHBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_H_LL_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
hLLBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_SAR_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
sarBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_PEAK_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
peakBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_VALE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
valeBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_TREND_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
trendBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_KI_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
kiStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_TKI_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
tkiStateBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_SUPPORT_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
supportBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_SWING_LOW_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
swingLowBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_SWING_HIGH_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
swingHighBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_RESISTANCE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
resistanceBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_PEAK_GOLDEN_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
peakGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_VALE_GOLDEN_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
valeGoldenBuffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_FIBO_L1_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
fiboLevel1Buffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_FIBO_L2_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
fiboLevel2Buffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_FIBO_L3_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
fiboLevel3Buffer //
|
|
);
|
|
|
|
//
|
|
CopyBuffer(
|
|
mHandler,
|
|
X121_XCA_TREND_STATE_LINE,
|
|
barIndex,
|
|
maxRequiredBars,
|
|
trendStateBuffer //
|
|
);
|
|
}
|
|
|
|
//
|
|
void Cleanup(
|
|
int maxAllowed = 100 //
|
|
)
|
|
{
|
|
//
|
|
CleanupArray(
|
|
kiBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
tkiBuffer,
|
|
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(
|
|
sarBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
peakBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
valeBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
trendBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
kiStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
tkiStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
supportBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
swingLowBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
swingHighBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
resistanceBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
peakGoldenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
valeGoldenBuffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
fiboLevel1Buffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
fiboLevel2Buffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
fiboLevel3Buffer,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
CleanupArray(
|
|
trendStateBuffer,
|
|
maxAllowed //
|
|
);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Tools ... |