add POI Detector and Drawer for XCATB classes ...
This commit is contained in:
@@ -80,6 +80,7 @@ input ENUM_X_MARKET_CYCLES appliedCycle = X_MARKET_CYCLE_HIND; // Applied Cycle
|
||||
// Presentation ...
|
||||
input group "Presentation";
|
||||
input bool showBars = true; // Show Bars
|
||||
input bool showKI = false; // Show KI
|
||||
input bool showPV = false; // Show PV
|
||||
input bool showPVGolden = false; // Show PV Golden
|
||||
input bool showSar = false; // Show Sar
|
||||
@@ -98,6 +99,7 @@ double sarMax = 0.2; // Maximum
|
||||
double rsiOBLevel = 70.0; // RSI OB Level
|
||||
double rsiOSLevel = 30.0; // RSI OS Level
|
||||
double adxThreshold = 25.0; // ADX Threshold
|
||||
int kiLength = 144; // KI Length
|
||||
int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||
int peakArrowCode = 159; // Peaks Arrow Code
|
||||
int valeArrowCode = 159; // Vales Arrow Code
|
||||
@@ -144,8 +146,8 @@ ENUM_X_MA_METHOD volumeSignalMethod = X_MA_MODE_EMA; // Volume Signalling Method
|
||||
// Color: 4
|
||||
// Bar: 8
|
||||
// Data Buffer: 19
|
||||
#property indicator_buffers 49
|
||||
#property indicator_plots 18
|
||||
#property indicator_buffers 52
|
||||
#property indicator_plots 19
|
||||
|
||||
//
|
||||
// Plot Buffers ...
|
||||
@@ -447,11 +449,30 @@ double hLLBuffer[];
|
||||
#property indicator_style18 STYLE_DOT
|
||||
#property indicator_width18 1
|
||||
|
||||
//
|
||||
// KI ...
|
||||
|
||||
//
|
||||
#define kiBufferIndex 28
|
||||
#define kiBufferPlotIndex 18
|
||||
double kiBuffer[];
|
||||
|
||||
//
|
||||
#define kiColorBufferIndex 29
|
||||
double kiColorBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label19 "KI"
|
||||
#property indicator_type19 DRAW_COLOR_LINE
|
||||
#property indicator_color19 CLR_NONE, clrGreen, clrRed, clrGray
|
||||
#property indicator_style19 STYLE_DASHDOTDOT
|
||||
#property indicator_width19 2
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
#define mLastBufferIndex 27
|
||||
#define mLastBufferIndex 29
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
@@ -553,6 +574,13 @@ double lowHKBuffer[];
|
||||
#define closeHKBufferIndex mLastBufferIndex + 19
|
||||
double closeHKBuffer[];
|
||||
|
||||
//
|
||||
// KI ...
|
||||
|
||||
//
|
||||
#define kiStateBufferIndex mLastBufferIndex + 20
|
||||
double kiStateBuffer[];
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
@@ -1288,6 +1316,21 @@ void DefineBuffers()
|
||||
PlotIndexSetInteger(hLLBufferPlotIndex, PLOT_DRAW_TYPE, hDrawType);
|
||||
PlotIndexSetDouble(hLLBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// KI ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(kiBuffer, true);
|
||||
SetIndexBuffer(kiBufferIndex, kiBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(kiBufferPlotIndex, PLOT_SHOW_DATA, showKI);
|
||||
PlotIndexSetDouble(kiBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(kiColorBuffer, true);
|
||||
SetIndexBuffer(kiColorBufferIndex, kiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
@@ -1374,6 +1417,13 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(closeHKBuffer, true);
|
||||
SetIndexBuffer(closeHKBufferIndex, closeHKBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// KI ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(kiStateBuffer, true);
|
||||
SetIndexBuffer(kiStateBufferIndex, kiStateBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1684,6 +1734,7 @@ void CalculateBuffers(
|
||||
void FillBuffersZero(int barIndex)
|
||||
{
|
||||
//
|
||||
kiColorBuffer[barIndex] = hideColorIDX;
|
||||
sarColorBuffer[barIndex] = hideColorIDX;
|
||||
trendColorBuffer[barIndex] = hideColorIDX;
|
||||
|
||||
@@ -1741,6 +1792,19 @@ void CalculateValues(
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
// KI ...
|
||||
CalculateKI(
|
||||
barIndex,
|
||||
prevCalculated,
|
||||
ratesTotal,
|
||||
open,
|
||||
high,
|
||||
close,
|
||||
low,
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
// PV ...
|
||||
CalculatePV(
|
||||
@@ -1895,6 +1959,90 @@ void CalculateCycleRanges(
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void CalculateKI(
|
||||
int barIndex,
|
||||
const int prevCalculated,
|
||||
const int ratesTotal,
|
||||
const double &open[],
|
||||
const double &high[],
|
||||
const double &close[],
|
||||
const double &low[],
|
||||
const long &tickVolume[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int lastBarIndex = barIndex + 1;
|
||||
bool isFirstBar =
|
||||
startCalculationForLastBars > 0
|
||||
? barIndex == startCalculationForLastBars
|
||||
: barIndex == firstBarIndex;
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
double iClose = close[barIndex];
|
||||
|
||||
//
|
||||
// Calculate KI / Color ...
|
||||
double lastKI =
|
||||
isFirstBar
|
||||
? emptyValue
|
||||
: kiBuffer[lastBarIndex];
|
||||
double iKI = lastKI;
|
||||
if (isInited)
|
||||
{
|
||||
//
|
||||
double iLLKI = iBar.FindLowest(kiLength, MODE_LOW);
|
||||
double iHHKI = iBar.FindHighest(kiLength, MODE_HIGH);
|
||||
|
||||
//
|
||||
iKI = (iHHKI + iLLKI) / 2;
|
||||
if (iLLKI == 0 || iHHKI == 0)
|
||||
{
|
||||
iKI = lastKI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iKI = lastKI;
|
||||
}
|
||||
kiBuffer[barIndex] = iKI;
|
||||
|
||||
//
|
||||
double iKIState = neuturalState;
|
||||
double iKIColor = neuturalColorIDX;
|
||||
if (iClose > iKI)
|
||||
{
|
||||
//
|
||||
iKIState = bullishState;
|
||||
iKIColor =
|
||||
!showKI
|
||||
? hideColorIDX
|
||||
: bullishColorIDX;
|
||||
}
|
||||
else if (iClose < iKI)
|
||||
{
|
||||
//
|
||||
iKIState = bearishState;
|
||||
iKIColor =
|
||||
!showKI
|
||||
? hideColorIDX
|
||||
: bearishColorIDX;
|
||||
}
|
||||
kiStateBuffer[barIndex] = iKIState;
|
||||
kiColorBuffer[barIndex] = iKIColor;
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
void CalculatePV(
|
||||
int barIndex,
|
||||
|
||||
Reference in New Issue
Block a user