Add support for Golden Zone inside XPV indicator and it's Helper ...

This commit is contained in:
2025-03-08 22:00:36 +03:30
parent e0e081628a
commit 3b7ce3816a
9 changed files with 682 additions and 132 deletions
+80 -8
View File
@@ -58,8 +58,9 @@ input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
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 ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
input ENUM_X_FIBO_LEVELS goldenZoneLevel = X_FIBO_LEVEL_382; // Golden Zone Detection
//
input group "Sar Detection";
@@ -77,9 +78,10 @@ input int peaksArrowCode = 159; // Peaks Arrow Code
input int valesArrowCode = 159; // Vales Arrow Code
//
input bool showSar = true; // Show Parabolic Sar
input bool showPeaks = true; // Show Peaks
input bool showVales = true; // Show Vales
input bool showSar = true; // Show Parabolic Sar
input bool showPeaks = true; // Show Peaks
input bool showVales = true; // Show Vales
input bool showGoldenZones = true; // Show Golden Zones
//
// Buffers ...
@@ -94,8 +96,8 @@ input bool showVales = true; // Show Vales
#property indicator_chart_window
//
#property indicator_buffers 13
#property indicator_plots 3
#property indicator_buffers 15
#property indicator_plots 5
//
// Plot Buffers ...
@@ -136,11 +138,33 @@ double sarBuffer[];
#property indicator_color3 clrYellow
#property indicator_width3 1
//
#define peaksGoldenZoneBufferIndex 3
double peaksGoldenZoneBuffer[];
//
#property indicator_label4 "X121 PEAKGZ"
#property indicator_type4 DRAW_LINE
#property indicator_color4 clrGold
#property indicator_style4 STYLE_DOT
#property indicator_width4 1
//
#define valesGoldenZoneBufferIndex 4
double valesGoldenZoneBuffer[];
//
#property indicator_label5 "X121 VALEGZ"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrGold
#property indicator_style5 STYLE_DOT
#property indicator_width5 1
//
// Data Buffers ...
//
int mLastBufferIndex = 2;
int mLastBufferIndex = 4;
//
// CURRENT ...
@@ -529,6 +553,34 @@ void DefineBuffers()
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode);
//
// Golden Zones ...
//
ENUM_DRAW_TYPE goldenZonesDrawType = showGoldenZones ? DRAW_LINE : DRAW_NONE;
//
// PEAK Golden Zone ...
//
ArraySetAsSeries(peaksGoldenZoneBuffer, true);
SetIndexBuffer(peaksGoldenZoneBufferIndex, peaksGoldenZoneBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones);
PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType);
//
// VALE Golden Zone ...
//
ArraySetAsSeries(valesGoldenZoneBuffer, true);
SetIndexBuffer(valesGoldenZoneBufferIndex, valesGoldenZoneBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones);
PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType);
//
// Data Buffers ...
@@ -997,6 +1049,26 @@ void CalculatePeaksAndVales(int barIndex)
? sValue
: lastVale;
valesBuffer[barIndex] = iVale;
//
// Peaks Golden Zone ...
double iPeakGoldenZone = GetFibonacciLevel(
iPeak,
iVale,
goldenZoneLevel,
X_DIRECTION_BULLISH //
);
peaksGoldenZoneBuffer[barIndex] = iPeakGoldenZone;
//
// Vales Golden Zone ...
double iValeGoldenZone = GetFibonacciLevel(
iPeak,
iVale,
goldenZoneLevel,
X_DIRECTION_BEARISH //
);
valesGoldenZoneBuffer[barIndex] = iValeGoldenZone;
}
//