remove fibo lines from x121 indicator and also add support for rsi in data buffers ...
This commit is contained in:
+74
-278
@@ -62,6 +62,11 @@ input group "Boundary Detection";
|
||||
input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
|
||||
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
|
||||
//
|
||||
input group "Rsi Detection";
|
||||
input int rsiLength = 14; // Length
|
||||
input ENUM_APPLIED_PRICE rsiAppliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
input group "Parabolic Sar Detection";
|
||||
input double sarStep = 0.02; // Step
|
||||
@@ -92,6 +97,11 @@ input group "Presentation";
|
||||
//
|
||||
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||
|
||||
//
|
||||
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||
input int peaksArrowCode = 159; // Peaks Arrow Code
|
||||
input int valesArrowCode = 159; // Vales Arrow Code
|
||||
|
||||
//
|
||||
input bool showSar = true; // Show Parabolic Sar
|
||||
input bool showAtr = true; // Show Atr
|
||||
@@ -100,14 +110,6 @@ input bool showVales = true; // Show Vales
|
||||
input bool showVWap = true; // Show VWap
|
||||
input bool showDonchain = true; // Show Donchain
|
||||
|
||||
//
|
||||
input group "Fibonachi Presentation";
|
||||
input bool showFibo1Levels = false; // Show Fibo 1st Level
|
||||
input bool showFibo2Levels = false; // Show Fibo 2nd Level
|
||||
input bool showFibo3Levels = false; // Show Fibo 3rd Level
|
||||
input bool showFibo4Levels = false; // Show Fibo 4th Level
|
||||
input bool showFibo5Levels = false; // Show Fibo 5th Level
|
||||
|
||||
//
|
||||
input group "Atr Presentation";
|
||||
input bool showAtrUpper = true; // Show Upper Zone
|
||||
@@ -128,22 +130,6 @@ input bool showHigh = false; // Show High
|
||||
input bool showClose = true; // Show Close
|
||||
input bool showLow = false; // Show Low
|
||||
|
||||
//
|
||||
// Non Important Inputs ...
|
||||
|
||||
//
|
||||
input group "Fibonacci";
|
||||
input double fiboLevel1 = 0.236; // Fibio 1st Level
|
||||
input double fiboLevel2 = 0.382; // Fibio 2st Level
|
||||
input double fiboLevel3 = 0.5; // Fibio 3rd Level
|
||||
input double fiboLevel4 = 0.618; // Fibio 4th Level
|
||||
input double fiboLevel5 = 0.764; // Fibio 5th Level
|
||||
|
||||
//
|
||||
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||
input int peaksArrowCode = 159; // Peaks Arrow Code
|
||||
input int valesArrowCode = 159; // Vales Arrow Code
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
@@ -157,8 +143,8 @@ input int valesArrowCode = 159; // Vales Arrow Code
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 42
|
||||
#property indicator_plots 21
|
||||
#property indicator_buffers 38
|
||||
#property indicator_plots 16
|
||||
|
||||
//
|
||||
// PEAKS ...
|
||||
@@ -382,89 +368,11 @@ double donCloseLowerBuffer[];
|
||||
#property indicator_color16 clrCoral
|
||||
#property indicator_width16 1
|
||||
|
||||
//
|
||||
// FIBONACCI ...
|
||||
|
||||
//
|
||||
// FIBBO Level 1 ...
|
||||
|
||||
//
|
||||
#define fl1BufferIndex 19
|
||||
double fl1Buffer[];
|
||||
|
||||
//
|
||||
#define fl1PlotBufferIndex 16
|
||||
#property indicator_label17 "X121 FL1"
|
||||
#property indicator_type17 DRAW_LINE
|
||||
#property indicator_color17 clrGold
|
||||
#property indicator_style17 STYLE_DASHDOTDOT
|
||||
#property indicator_width17 1
|
||||
|
||||
//
|
||||
// FIBBO Level 2 ...
|
||||
|
||||
//
|
||||
#define fl2BufferIndex 20
|
||||
double fl2Buffer[];
|
||||
|
||||
//
|
||||
#define fl2PlotBufferIndex 17
|
||||
#property indicator_label18 "X121 FL2"
|
||||
#property indicator_type18 DRAW_LINE
|
||||
#property indicator_color18 clrGold
|
||||
#property indicator_style18 STYLE_DASHDOTDOT
|
||||
#property indicator_width18 1
|
||||
|
||||
//
|
||||
// FIBBO Level 3 ...
|
||||
|
||||
//
|
||||
#define fl3BufferIndex 21
|
||||
double fl3Buffer[];
|
||||
|
||||
//
|
||||
#define fl3PlotBufferIndex 18
|
||||
#property indicator_label19 "X121 FL3"
|
||||
#property indicator_type19 DRAW_LINE
|
||||
#property indicator_color19 clrGold
|
||||
#property indicator_style19 STYLE_DASHDOTDOT
|
||||
#property indicator_width19 1
|
||||
|
||||
//
|
||||
// FIBBO Level 4 ...
|
||||
|
||||
//
|
||||
#define fl4BufferIndex 22
|
||||
double fl4Buffer[];
|
||||
|
||||
//
|
||||
#define fl4PlotBufferIndex 19
|
||||
#property indicator_label20 "X121 FL4"
|
||||
#property indicator_type20 DRAW_LINE
|
||||
#property indicator_color20 clrGold
|
||||
#property indicator_style20 STYLE_DASHDOTDOT
|
||||
#property indicator_width20 1
|
||||
|
||||
//
|
||||
// FIBBO Level 5 ...
|
||||
|
||||
//
|
||||
#define fl5BufferIndex 23
|
||||
double fl5Buffer[];
|
||||
|
||||
//
|
||||
#define fl5PlotBufferIndex 20
|
||||
#property indicator_label21 "X121 FL5"
|
||||
#property indicator_type21 DRAW_LINE
|
||||
#property indicator_color21 clrGold
|
||||
#property indicator_style21 STYLE_DASHDOTDOT
|
||||
#property indicator_width21 1
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
int mLastBufferIndex = 23;
|
||||
int mLastBufferIndex = 18;
|
||||
|
||||
//
|
||||
// CURRENT ...
|
||||
@@ -522,7 +430,7 @@ double hHHBuffer[];
|
||||
double hLLBuffer[];
|
||||
|
||||
//
|
||||
// VOLUME ...
|
||||
// VWAP ...
|
||||
#define vwapVolumeBufferIndex mLastBufferIndex + 11
|
||||
double vwapVolumeBuffer[];
|
||||
|
||||
@@ -558,6 +466,11 @@ double atrUpperRawBuffer[];
|
||||
#define atrLowerRawBufferIndex mLastBufferIndex + 18
|
||||
double atrLowerRawBuffer[];
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
#define rsiBufferIndex mLastBufferIndex + 19
|
||||
double rsiBuffer[];
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
@@ -568,6 +481,10 @@ int limit;
|
||||
//
|
||||
int maxLength;
|
||||
|
||||
//
|
||||
// RSI Handler ...
|
||||
int rsiHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
// SAR Handler ...
|
||||
int sarHandler = INVALID_HANDLE;
|
||||
@@ -619,6 +536,20 @@ int OnInit()
|
||||
//
|
||||
// Initialize Indicator Handlers ...
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
rsiHandler = iRSI(
|
||||
_Symbol,
|
||||
_Period,
|
||||
rsiLength,
|
||||
rsiAppliedTo //
|
||||
);
|
||||
bool isInited = rsiHandler != INVALID_HANDLE;
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
sarHandler = iSAR(
|
||||
@@ -627,7 +558,7 @@ int OnInit()
|
||||
sarStep,
|
||||
sarMax //
|
||||
);
|
||||
bool isInited = sarHandler != INVALID_HANDLE;
|
||||
isInited = sarHandler != INVALID_HANDLE;
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
@@ -692,6 +623,7 @@ void OnDeinit(const int reason)
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
IndicatorRelease(rsiHandler);
|
||||
IndicatorRelease(sarHandler);
|
||||
IndicatorRelease(atrHandler);
|
||||
}
|
||||
@@ -749,6 +681,10 @@ int OnCalculate(
|
||||
//
|
||||
// Validate Calculated Bars ...
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
int rsiCalculatedBars = BarsCalculated(rsiHandler);
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
int sarCalculatedBars = BarsCalculated(sarHandler);
|
||||
@@ -759,11 +695,14 @@ int OnCalculate(
|
||||
|
||||
//
|
||||
bool isPassedRequiredCalculatedBars =
|
||||
//
|
||||
// RSI ...
|
||||
rsiCalculatedBars >= maxLength &&
|
||||
//
|
||||
// SAR ...
|
||||
sarCalculatedBars >= maxLength &&
|
||||
//
|
||||
// ATR...
|
||||
// ATR ...
|
||||
sarCalculatedBars >= maxLength
|
||||
//
|
||||
;
|
||||
@@ -778,6 +717,10 @@ int OnCalculate(
|
||||
//
|
||||
// Buffers Copy ...
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
int copiedRsis = CopyBuffer(rsiHandler, 0, 0, limit, rsiBuffer);
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
|
||||
@@ -791,8 +734,13 @@ int OnCalculate(
|
||||
bool isPassedRequiredCopiedItems =
|
||||
//
|
||||
//
|
||||
// RSI ...
|
||||
copiedRsis > 0 &&
|
||||
//
|
||||
// SAR ...
|
||||
copiedSars > 0 &&
|
||||
//
|
||||
// ATR ...
|
||||
copiedAtrs > 0
|
||||
//
|
||||
;
|
||||
@@ -835,6 +783,9 @@ bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result =
|
||||
//
|
||||
// RSI ...
|
||||
rsiLength > 0 &&
|
||||
//
|
||||
// PSAR ...
|
||||
sarMax > 0 &&
|
||||
@@ -891,6 +842,10 @@ int ExtractMaxLengthOfInputs()
|
||||
// ATR ...
|
||||
result = MathMax(result, atrLength);
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
result = MathMax(result, rsiLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1096,59 +1051,6 @@ void DefineBuffers()
|
||||
PlotIndexSetInteger(donLowLowerPlotBufferIndex, PLOT_SHOW_DATA, canShowCLowLower);
|
||||
PlotIndexSetInteger(donLowLowerPlotBufferIndex, PLOT_DRAW_TYPE, donLowLowerDrawType);
|
||||
|
||||
//
|
||||
// FIBONNACI ...
|
||||
|
||||
//
|
||||
// LEVEL 1 ...
|
||||
bool canShowFl1 = showFibo1Levels;
|
||||
ENUM_DRAW_TYPE fl1DrawType = canShowFl1 ? DRAW_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(fl1Buffer, true);
|
||||
SetIndexBuffer(fl1BufferIndex, fl1Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(fl1PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(fl1PlotBufferIndex, PLOT_SHOW_DATA, canShowFl1);
|
||||
PlotIndexSetInteger(fl1PlotBufferIndex, PLOT_DRAW_TYPE, fl1DrawType);
|
||||
|
||||
//
|
||||
// LEVEL 2 ...
|
||||
bool canShowFl2 = showFibo2Levels;
|
||||
ENUM_DRAW_TYPE fl2DrawType = canShowFl2 ? DRAW_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(fl2Buffer, true);
|
||||
SetIndexBuffer(fl2BufferIndex, fl2Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(fl2PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(fl2PlotBufferIndex, PLOT_SHOW_DATA, canShowFl2);
|
||||
PlotIndexSetInteger(fl2PlotBufferIndex, PLOT_DRAW_TYPE, fl2DrawType);
|
||||
|
||||
//
|
||||
// LEVEL 3 ...
|
||||
bool canShowFl3 = showFibo3Levels;
|
||||
ENUM_DRAW_TYPE fl3DrawType = canShowFl3 ? DRAW_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(fl3Buffer, true);
|
||||
SetIndexBuffer(fl3BufferIndex, fl3Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(fl3PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(fl3PlotBufferIndex, PLOT_SHOW_DATA, canShowFl3);
|
||||
PlotIndexSetInteger(fl3PlotBufferIndex, PLOT_DRAW_TYPE, fl3DrawType);
|
||||
|
||||
//
|
||||
// LEVEL 4 ...
|
||||
bool canShowFl4 = showFibo4Levels;
|
||||
ENUM_DRAW_TYPE fl4DrawType = canShowFl4 ? DRAW_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(fl4Buffer, true);
|
||||
SetIndexBuffer(fl4BufferIndex, fl4Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(fl4PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(fl4PlotBufferIndex, PLOT_SHOW_DATA, canShowFl4);
|
||||
PlotIndexSetInteger(fl4PlotBufferIndex, PLOT_DRAW_TYPE, fl4DrawType);
|
||||
|
||||
//
|
||||
// LEVEL 5 ...
|
||||
bool canShowFl5 = showFibo5Levels;
|
||||
ENUM_DRAW_TYPE fl5DrawType = canShowFl5 ? DRAW_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(fl5Buffer, true);
|
||||
SetIndexBuffer(fl5BufferIndex, fl5Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(fl5PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(fl5PlotBufferIndex, PLOT_SHOW_DATA, canShowFl5);
|
||||
PlotIndexSetInteger(fl5PlotBufferIndex, PLOT_DRAW_TYPE, fl5DrawType);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
@@ -1249,6 +1151,13 @@ void DefineBuffers()
|
||||
//
|
||||
ArraySetAsSeries(atrLowerRawBuffer, true);
|
||||
SetIndexBuffer(atrLowerRawBufferIndex, atrLowerRawBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(rsiBuffer, true);
|
||||
SetIndexBuffer(rsiBufferIndex, rsiBuffer, INDICATOR_CALCULATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1324,11 +1233,6 @@ void CalculateBuffers(
|
||||
low //
|
||||
);
|
||||
|
||||
//
|
||||
CalculateFibonacci(
|
||||
bar_index //
|
||||
);
|
||||
|
||||
//
|
||||
// Calculate Required VWAP Data Buffers ...
|
||||
if (ratesTotal - bar_index <= maxLength)
|
||||
@@ -1539,6 +1443,10 @@ void FillBuffersZero(int barIndex)
|
||||
// SARS ...
|
||||
sarBuffer[barIndex] = 0;
|
||||
|
||||
//
|
||||
// RSIS ...
|
||||
rsiBuffer[barIndex] = 0;
|
||||
|
||||
//
|
||||
// ATRS ...
|
||||
atrBuffer[barIndex] = 0;
|
||||
@@ -1574,13 +1482,6 @@ void FillBuffersZero(int barIndex)
|
||||
donHighLowerBuffer[barIndex] = 0;
|
||||
donLowUpperBuffer[barIndex] = 0;
|
||||
donLowLowerBuffer[barIndex] = 0;
|
||||
|
||||
//
|
||||
fl1Buffer[barIndex] = 0;
|
||||
fl2Buffer[barIndex] = 0;
|
||||
fl3Buffer[barIndex] = 0;
|
||||
fl4Buffer[barIndex] = 0;
|
||||
fl5Buffer[barIndex] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2213,109 +2114,4 @@ void CalculateAtrZones(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Fibonacci Levels ...
|
||||
*
|
||||
* @param bar_index: Integer, current Bar Index ...
|
||||
*/
|
||||
void CalculateFibonacci(
|
||||
int bar_index //
|
||||
)
|
||||
{
|
||||
//
|
||||
double fiboUpper = 0;
|
||||
double fiboLower = 0;
|
||||
|
||||
//
|
||||
fiboUpper = peaksBuffer[bar_index];
|
||||
fiboLower = valesBuffer[bar_index];
|
||||
|
||||
//
|
||||
// Level 1 ...
|
||||
bool canCalculateFiboLevel1 = fiboLevel1 > 0;
|
||||
if (canCalculateFiboLevel1)
|
||||
{
|
||||
//
|
||||
double iFib = GetFibonacciLevel(
|
||||
fiboUpper,
|
||||
fiboLower,
|
||||
fiboLevel1,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
fl1Buffer[bar_index] = iFib;
|
||||
}
|
||||
|
||||
//
|
||||
// Level 2 ...
|
||||
bool canCalculateFiboLevel2 = fiboLevel2 > 0;
|
||||
if (canCalculateFiboLevel2)
|
||||
{
|
||||
//
|
||||
double iFib = GetFibonacciLevel(
|
||||
fiboUpper,
|
||||
fiboLower,
|
||||
fiboLevel2,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
fl2Buffer[bar_index] = iFib;
|
||||
}
|
||||
|
||||
//
|
||||
// Level 3 ...
|
||||
bool canCalculateFiboLevel3 = fiboLevel3 > 0;
|
||||
if (canCalculateFiboLevel3)
|
||||
{
|
||||
//
|
||||
double iFib = GetFibonacciLevel(
|
||||
fiboUpper,
|
||||
fiboLower,
|
||||
fiboLevel3,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
fl3Buffer[bar_index] = iFib;
|
||||
}
|
||||
|
||||
//
|
||||
// Level 4 ...
|
||||
bool canCalculateFiboLevel4 = fiboLevel4 > 0;
|
||||
if (canCalculateFiboLevel4)
|
||||
{
|
||||
//
|
||||
double iFib = GetFibonacciLevel(
|
||||
fiboUpper,
|
||||
fiboLower,
|
||||
fiboLevel4,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
fl4Buffer[bar_index] = iFib;
|
||||
}
|
||||
|
||||
//
|
||||
// Level 5 ...
|
||||
bool canCalculateFiboLevel5 = fiboLevel5 > 0;
|
||||
if (canCalculateFiboLevel5)
|
||||
{
|
||||
//
|
||||
double iFib = GetFibonacciLevel(
|
||||
fiboUpper,
|
||||
fiboLower,
|
||||
fiboLevel5,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
fl5Buffer[bar_index] = iFib;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user