add supports for VIDYA in xca and also it's helper and in xcaea ...
This commit is contained in:
@@ -76,6 +76,14 @@ input double sarMax = 0.2; // Maximum
|
||||
input group "KI";
|
||||
input int kiLength = 26; // KI Length
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
// Variable Index Dynamic Average ...
|
||||
input group "VIDYA";
|
||||
input int vidyaCMOLength = 20; // CMO (Candle Momentum) Length
|
||||
input int vidyaEMALength = 14; // EMA Length
|
||||
input ENUM_APPLIED_PRICE vidyaAppliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
input group "Swing Detection";
|
||||
input int swingLength = 5; // Length
|
||||
@@ -96,6 +104,7 @@ input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||
input bool showSar = true; // Show Sar
|
||||
input bool showKI = true; // Show KI
|
||||
input bool showTKI = true; // Show KI Trend
|
||||
input bool showVidya = true; // Show Vidya
|
||||
input bool showTrend = true; // Show Trend
|
||||
input bool showSwings = true; // Show Swings
|
||||
input bool showFiboLevel1 = true; // Show Fibo Level 1
|
||||
@@ -137,8 +146,8 @@ input int swingHighArrowCode = 226; // Swing High Arrow Code
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 31
|
||||
#property indicator_plots 23
|
||||
#property indicator_buffers 34
|
||||
#property indicator_plots 24
|
||||
|
||||
//
|
||||
// Plot Buffers ...
|
||||
@@ -465,10 +474,29 @@ double tkiColorBuffer[];
|
||||
#property indicator_style23 STYLE_DASHDOTDOT
|
||||
#property indicator_width23 2
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
|
||||
//
|
||||
#define vidyaBufferIndex 26
|
||||
#define vidyaBufferPlotIndex 23
|
||||
double vidyaBuffer[];
|
||||
|
||||
//
|
||||
#define vidyaColorBufferIndex 27
|
||||
double vidyaColorBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label24 "VIDYA"
|
||||
#property indicator_type24 DRAW_COLOR_LINE
|
||||
#property indicator_color24 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||
#property indicator_style24 STYLE_SOLID
|
||||
#property indicator_width24 1
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
#define mLastBufferIndex 25
|
||||
#define mLastBufferIndex 27
|
||||
|
||||
//
|
||||
#define trendStateBufferIndex mLastBufferIndex + 1
|
||||
@@ -483,11 +511,15 @@ double kiStateBuffer[];
|
||||
double tkiStateBuffer[];
|
||||
|
||||
//
|
||||
#define supBufferIndex mLastBufferIndex + 4
|
||||
#define vidyaStateBufferIndex mLastBufferIndex + 4
|
||||
double vidyaStateBuffer[];
|
||||
|
||||
//
|
||||
#define supBufferIndex mLastBufferIndex + 5
|
||||
double supBuffer[];
|
||||
|
||||
//
|
||||
#define resBufferIndex mLastBufferIndex + 5
|
||||
#define resBufferIndex mLastBufferIndex + 6
|
||||
double resBuffer[];
|
||||
|
||||
//
|
||||
@@ -507,6 +539,7 @@ int sarHandler = INVALID_HANDLE;
|
||||
//
|
||||
// TREND Handler ...
|
||||
int tkiHandler = INVALID_HANDLE;
|
||||
int vidyaHandler = INVALID_HANDLE;
|
||||
int trendHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
@@ -585,6 +618,22 @@ int OnInit()
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
vidyaHandler = iVIDyA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
vidyaCMOLength,
|
||||
vidyaEMALength,
|
||||
0,
|
||||
vidyaAppliedTo //
|
||||
);
|
||||
isInited = vidyaHandler != INVALID_HANDLE;
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// TREND ...
|
||||
trendHandler = iMA(
|
||||
@@ -642,6 +691,8 @@ void OnDeinit(const int reason)
|
||||
|
||||
//
|
||||
IndicatorRelease(sarHandler);
|
||||
IndicatorRelease(tkiHandler);
|
||||
IndicatorRelease(vidyaHandler);
|
||||
IndicatorRelease(trendHandler);
|
||||
}
|
||||
|
||||
@@ -696,6 +747,10 @@ int OnCalculate(
|
||||
// TKI ...
|
||||
int tkiCalculatedBars = BarsCalculated(tkiHandler);
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
int vidyaCalculatedBars = BarsCalculated(vidyaHandler);
|
||||
|
||||
//
|
||||
// TREND ...
|
||||
int trendCalculatedBars = BarsCalculated(trendHandler);
|
||||
@@ -709,6 +764,9 @@ int OnCalculate(
|
||||
// TKI ...
|
||||
tkiCalculatedBars >= maxLength &&
|
||||
//
|
||||
// VIDYA ...
|
||||
vidyaCalculatedBars >= maxLength &&
|
||||
//
|
||||
// TREND ...
|
||||
trendCalculatedBars >= maxLength
|
||||
//
|
||||
@@ -734,6 +792,10 @@ int OnCalculate(
|
||||
// TKI ...
|
||||
int copiedTKIs = CopyBuffer(tkiHandler, 0, 0, limit, tkiBuffer);
|
||||
|
||||
//
|
||||
// TKI ...
|
||||
int copiedVidyas = CopyBuffer(vidyaHandler, 0, 0, limit, vidyaBuffer);
|
||||
|
||||
//
|
||||
// TREND ...
|
||||
int copiedTrends = CopyBuffer(trendHandler, MAIN_LINE, 0, limit + 1, trendBuffer);
|
||||
@@ -748,6 +810,9 @@ int OnCalculate(
|
||||
// TKI ...
|
||||
copiedTKIs >= limit &&
|
||||
//
|
||||
// VIDYA ...
|
||||
copiedVidyas >= limit &&
|
||||
//
|
||||
// TREND ...
|
||||
copiedTrends >= limit
|
||||
//
|
||||
@@ -801,6 +866,8 @@ bool ValidateInputs()
|
||||
kiLength > 0 &&
|
||||
swingLength > 0 &&
|
||||
sarMax > sarStep &&
|
||||
vidyaEMALength > 0 &&
|
||||
vidyaCMOLength > 0 &&
|
||||
//
|
||||
// XCA ...
|
||||
(IsValid(scMethod, scPeriod) &&
|
||||
@@ -826,6 +893,8 @@ int ExtractMaxLengthOfInputs()
|
||||
|
||||
//
|
||||
result = MathMax(kiLength, swingLength);
|
||||
result = MathMax(result, vidyaCMOLength);
|
||||
result = MathMax(result, vidyaEMALength);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1211,6 +1280,27 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(tkiColorBuffer, true);
|
||||
SetIndexBuffer(tkiColorBufferIndex, tkiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
|
||||
//
|
||||
ENUM_DRAW_TYPE vidyaDrawType = showVidya ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(vidyaBuffer, true);
|
||||
SetIndexBuffer(vidyaBufferIndex, vidyaBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(vidyaBufferPlotIndex, PLOT_SHOW_DATA, showKI);
|
||||
// PlotIndexSetInteger(vidyaBufferPlotIndex, PLOT_DRAW_TYPE, vidyaDrawType);
|
||||
|
||||
//
|
||||
PlotIndexSetDouble(vidyaBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(vidyaColorBuffer, true);
|
||||
SetIndexBuffer(vidyaColorBufferIndex, vidyaColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
// SWINGS ...
|
||||
|
||||
@@ -1258,6 +1348,14 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(kiStateBuffer, true);
|
||||
SetIndexBuffer(kiStateBufferIndex, kiStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(tkiStateBuffer, true);
|
||||
SetIndexBuffer(tkiStateBufferIndex, tkiStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(vidyaStateBuffer, true);
|
||||
SetIndexBuffer(vidyaStateBufferIndex, vidyaStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(supBuffer, true);
|
||||
SetIndexBuffer(supBufferIndex, supBuffer, INDICATOR_CALCULATIONS);
|
||||
@@ -1266,10 +1364,6 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(resBuffer, true);
|
||||
SetIndexBuffer(resBufferIndex, resBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(tkiStateBuffer, true);
|
||||
SetIndexBuffer(tkiStateBufferIndex, tkiStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1541,19 +1635,25 @@ void FillBuffersZero(int barIndex)
|
||||
// TREND ...
|
||||
trendBuffer[barIndex] = emptyValue;
|
||||
trendColorBuffer[barIndex] = hideColorIDX;
|
||||
trendStateBuffer[barIndex] = hideColorIDX;
|
||||
trendStateBuffer[barIndex] = neuturalState;
|
||||
|
||||
//
|
||||
// KI ...
|
||||
kiBuffer[barIndex] = emptyValue;
|
||||
kiColorBuffer[barIndex] = hideColorIDX;
|
||||
kiStateBuffer[barIndex] = hideColorIDX;
|
||||
kiStateBuffer[barIndex] = neuturalState;
|
||||
|
||||
//
|
||||
// TKI ...
|
||||
tkiBuffer[barIndex] = emptyValue;
|
||||
tkiColorBuffer[barIndex] = hideColorIDX;
|
||||
tkiStateBuffer[barIndex] = hideColorIDX;
|
||||
tkiStateBuffer[barIndex] = neuturalState;
|
||||
|
||||
//
|
||||
// VIDYA ...
|
||||
vidyaBuffer[barIndex] = emptyValue;
|
||||
vidyaColorBuffer[barIndex] = hideColorIDX;
|
||||
vidyaStateBuffer[barIndex] = neuturalState;
|
||||
|
||||
//
|
||||
// SWINGS ...
|
||||
@@ -2017,6 +2117,36 @@ void CalculateValues(
|
||||
tkiStateBuffer[bar_index] = iTKIState;
|
||||
tkiColorBuffer[bar_index] = iTKIColor;
|
||||
|
||||
//
|
||||
// VIDYA Color ...
|
||||
|
||||
//
|
||||
double iVIDYA = vidyaBuffer[bar_index];
|
||||
|
||||
//
|
||||
double iVIDYAState = neuturalState;
|
||||
double iVIDYAColor = neuturalColorIDX;
|
||||
if (iClose > iVIDYA)
|
||||
{
|
||||
//
|
||||
iVIDYAState = bullishState;
|
||||
iVIDYAColor =
|
||||
!showVidya
|
||||
? hideColorIDX
|
||||
: bullishColorIDX;
|
||||
}
|
||||
else if (iClose < iVIDYA)
|
||||
{
|
||||
//
|
||||
iVIDYAState = bearishState;
|
||||
iVIDYAColor =
|
||||
!showVidya
|
||||
? hideColorIDX
|
||||
: bearishColorIDX;
|
||||
}
|
||||
vidyaStateBuffer[bar_index] = iVIDYAState;
|
||||
vidyaColorBuffer[bar_index] = iVIDYAColor;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user