This commit is contained in:
2025-05-05 12:16:36 +03:30
parent eeda9917dc
commit 83242e6d1e
7 changed files with 6317 additions and 168 deletions
+282 -133
View File
@@ -63,8 +63,10 @@ input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
//
input group "Fibo Levels";
input ENUM_X_FIBO_LEVELS fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
input ENUM_X_FIBO_LEVELS fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
input ENUM_X_FIBO_LEVELS fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
input ENUM_X_FIBO_LEVELS fiboLevel2 = X_FIBO_LEVEL_382; // Fibo Level 2
input ENUM_X_FIBO_LEVELS fiboLevel3 = X_FIBO_LEVEL_500; // Fibo Level 3
input ENUM_X_FIBO_LEVELS fiboLevel4 = X_FIBO_LEVEL_618; // Fibo Level 4
input ENUM_X_FIBO_LEVELS fiboLevel5 = X_FIBO_LEVEL_764; // Fibo Level 5
//
input group "Sar Detection";
@@ -96,8 +98,8 @@ input int swingLength = 5; // Length
//
input group "Support and Resistance";
input int supResSmoothingLength = 7; // Smoothing Length
input ENUM_X_MA_METHOD supResSmoothingMode = X_MA_MODE_SMA; // Smoothing Method
input int supResSmoothingLength = 7; // Smoothing Length
input ENUM_X_MA_METHOD supResSmoothingMode = X_MA_MODE_NONE; // Smoothing Method
//
// Presentation ...
@@ -119,13 +121,17 @@ input bool showSwings = true; // Show Swings
input bool showFiboLevel1 = true; // Show Fibo Level 1
input bool showFiboLevel2 = true; // Show Fibo Level 2
input bool showFiboLevel3 = true; // Show Fibo Level 3
input bool showFiboLevel4 = true; // Show Fibo Level 4
input bool showFiboLevel5 = true; // Show Fibo Level 5
input bool showPeaksAndVales = true; // Show Peaks And Vales
input bool showPeakAndValeGolden = true; // Show Peak and Vale Golden
input bool showSupportAndResistance = true; // Show Support and Resistance
input bool showShortCycle = true; // Show Short Cycle
input bool showMediumCycle = true; // Show Medium Cycle
input bool showLongCycle = true; // Show Long Cycle
input bool showHindCycle = true; // Show Hind Cycle
//
bool showShortCycle = false; // Show Short Cycle
bool showMediumCycle = false; // Show Medium Cycle
bool showLongCycle = false; // Show Long Cycle
bool showHindCycle = false; // Show Hind Cycle
//
int sarArrowCode = 159; // Parabolic Sar Arrow Code
@@ -155,8 +161,8 @@ int swingHighArrowCode = 226; // Swing High Arrow Code
#property indicator_chart_window
//
#property indicator_buffers 37
#property indicator_plots 27
#property indicator_buffers 39
#property indicator_plots 29
//
// Plot Buffers ...
@@ -367,8 +373,8 @@ double fiboLevel2Buffer[];
//
#property indicator_label16 "Fibo L2"
#property indicator_type16 DRAW_LINE
#property indicator_color16 clrYellow
#property indicator_style16 STYLE_DASH
#property indicator_color16 clrGold
#property indicator_style16 STYLE_DOT
#property indicator_width16 1
//
@@ -381,176 +387,204 @@ double fiboLevel3Buffer[];
//
#property indicator_label17 "Fibo L3"
#property indicator_type17 DRAW_LINE
#property indicator_color17 clrGold
#property indicator_style17 STYLE_DOT
#property indicator_color17 clrYellow
#property indicator_style17 STYLE_DASH
#property indicator_width17 1
//
// FIBO Level 4
//
#define fiboLevel4BufferIndex 17
double fiboLevel4Buffer[];
//
#property indicator_label18 "Fibo L4"
#property indicator_type18 DRAW_LINE
#property indicator_color18 clrGold
#property indicator_style18 STYLE_DOT
#property indicator_width18 1
//
// FIBO Level 5
//
#define fiboLevel5BufferIndex 18
double fiboLevel5Buffer[];
//
#property indicator_label19 "Fibo L5"
#property indicator_type19 DRAW_LINE
#property indicator_color19 clrGold
#property indicator_style19 STYLE_DOT
#property indicator_width19 1
//
// SAR ...
//
#define sarBufferIndex 17
#define sarBufferIndex 19
double sarBuffer[];
//
#property indicator_label18 "SAR"
#property indicator_type18 DRAW_ARROW
#property indicator_color18 clrYellow
#property indicator_width18 1
#property indicator_label20 "SAR"
#property indicator_type20 DRAW_ARROW
#property indicator_color20 clrYellow
#property indicator_width20 1
//
// TREND ...
//
#define trendBufferIndex 18
#define trendBufferPlotIndex 18
#define trendBufferIndex 20
#define trendBufferPlotIndex 20
double trendBuffer[];
//
#define trendColorBufferIndex 19
#define trendColorBufferIndex 21
double trendColorBuffer[];
//
#property indicator_label19 "TRND"
#property indicator_type19 DRAW_COLOR_LINE
#property indicator_color19 CLR_NONE, clrAqua, clrMagenta, clrGray
#property indicator_style19 STYLE_DASH
#property indicator_width19 2
#property indicator_label21 "TRND"
#property indicator_type21 DRAW_COLOR_LINE
#property indicator_color21 CLR_NONE, clrAqua, clrMagenta, clrGray
#property indicator_style21 STYLE_DASH
#property indicator_width21 2
//
// KI ...
//
#define kiBufferIndex 20
#define kiBufferPlotIndex 19
#define kiBufferIndex 22
#define kiBufferPlotIndex 21
double kiBuffer[];
//
#define kiColorBufferIndex 21
#define kiColorBufferIndex 23
double kiColorBuffer[];
//
#property indicator_label20 "KI"
#property indicator_type20 DRAW_COLOR_LINE
#property indicator_color20 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style20 STYLE_DASHDOTDOT
#property indicator_width20 2
#property indicator_label22 "KI"
#property indicator_type22 DRAW_COLOR_LINE
#property indicator_color22 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style22 STYLE_DASHDOTDOT
#property indicator_width22 2
//
// SWING Low ...
//
#define swingLowBufferIndex 22
#define swingLowBufferPlotIndex 20
#define swingLowBufferIndex 24
#define swingLowBufferPlotIndex 22
double swingLowBuffer[];
//
#property indicator_label21 "SWL"
#property indicator_type21 DRAW_ARROW
#property indicator_color21 clrGreen
#property indicator_width21 1
#property indicator_label23 "SWL"
#property indicator_type23 DRAW_ARROW
#property indicator_color23 clrGreen
#property indicator_width23 1
//
// SWING High ...
//
#define swingHighBufferIndex 23
#define swingHighBufferPlotIndex 21
#define swingHighBufferIndex 25
#define swingHighBufferPlotIndex 23
double swingHighBuffer[];
//
#property indicator_label22 "SWH"
#property indicator_type22 DRAW_ARROW
#property indicator_color22 clrRed
#property indicator_width22 1
#property indicator_label24 "SWH"
#property indicator_type24 DRAW_ARROW
#property indicator_color24 clrRed
#property indicator_width24 1
//
// TKI ...
//
#define tkiBufferIndex 24
#define tkiBufferPlotIndex 22
#define tkiBufferIndex 26
#define tkiBufferPlotIndex 24
double tkiBuffer[];
//
#define tkiColorBufferIndex 25
#define tkiColorBufferIndex 27
double tkiColorBuffer[];
//
#property indicator_label23 "TKI"
#property indicator_type23 DRAW_COLOR_LINE
#property indicator_color23 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style23 STYLE_DASHDOTDOT
#property indicator_width23 2
#property indicator_label25 "TKI"
#property indicator_type25 DRAW_COLOR_LINE
#property indicator_color25 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style25 STYLE_DASHDOTDOT
#property indicator_width25 2
//
// VIDYA ...
//
#define vidyaBufferIndex 26
#define vidyaBufferPlotIndex 23
#define vidyaBufferIndex 28
#define vidyaBufferPlotIndex 25
double vidyaBuffer[];
//
#define vidyaColorBufferIndex 27
#define vidyaColorBufferIndex 29
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
#property indicator_label26 "VIDYA"
#property indicator_type26 DRAW_COLOR_LINE
#property indicator_color26 CLR_NONE, clrAqua, clrMagenta, clrGray
#property indicator_style26 STYLE_SOLID
#property indicator_width26 1
//
// MAH ...
//
#define mahBufferIndex 28
#define mahBufferPlotIndex 24
#define mahBufferIndex 30
#define mahBufferPlotIndex 26
double mahBuffer[];
//
#property indicator_label25 "MAH"
#property indicator_type25 DRAW_LINE
#property indicator_color25 clrMagenta
#property indicator_style25 STYLE_SOLID
#property indicator_width25 1
#property indicator_label27 "MAH"
#property indicator_type27 DRAW_LINE
#property indicator_color27 clrMagenta
#property indicator_style27 STYLE_SOLID
#property indicator_width27 1
//
// MAL ...
//
#define malBufferIndex 29
#define malBufferPlotIndex 25
#define malBufferIndex 31
#define malBufferPlotIndex 27
double malBuffer[];
//
#property indicator_label26 "MAL"
#property indicator_type26 DRAW_LINE
#property indicator_color26 clrAqua
#property indicator_style26 STYLE_SOLID
#property indicator_width26 1
#property indicator_label28 "MAL"
#property indicator_type28 DRAW_LINE
#property indicator_color28 clrAqua
#property indicator_style28 STYLE_SOLID
#property indicator_width28 1
//
// MAC ...
//
#define macBufferIndex 30
#define macBufferPlotIndex 26
#define macBufferIndex 32
#define macBufferPlotIndex 28
double macBuffer[];
//
#property indicator_label27 "MAC"
#property indicator_type27 DRAW_LINE
#property indicator_color27 clrYellow
#property indicator_style27 STYLE_SOLID
#property indicator_width27 1
#property indicator_label29 "MAC"
#property indicator_type29 DRAW_LINE
#property indicator_color29 clrYellow
#property indicator_style29 STYLE_SOLID
#property indicator_width29 1
//
// Data Buffers ...
#define mLastBufferIndex 30
#define mLastBufferIndex 32
//
#define trendStateBufferIndex mLastBufferIndex + 1
@@ -1361,6 +1395,40 @@ void DefineBuffers()
//
PlotIndexSetDouble(fiboLevel3BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
//
// FIBO L4 ...
//
ENUM_DRAW_TYPE fiboL4DrawType = showFiboLevel4 ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(fiboLevel4Buffer, true);
SetIndexBuffer(fiboLevel4BufferIndex, fiboLevel4Buffer, INDICATOR_DATA);
//
PlotIndexSetInteger(fiboLevel4BufferIndex, PLOT_SHOW_DATA, showFiboLevel4);
PlotIndexSetInteger(fiboLevel4BufferIndex, PLOT_DRAW_TYPE, fiboL4DrawType);
//
PlotIndexSetDouble(fiboLevel4BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
//
// FIBO L5 ...
//
ENUM_DRAW_TYPE fiboL5DrawType = showFiboLevel5 ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(fiboLevel5Buffer, true);
SetIndexBuffer(fiboLevel5BufferIndex, fiboLevel5Buffer, INDICATOR_DATA);
//
PlotIndexSetInteger(fiboLevel5BufferIndex, PLOT_SHOW_DATA, showFiboLevel5);
PlotIndexSetInteger(fiboLevel5BufferIndex, PLOT_DRAW_TYPE, fiboL5DrawType);
//
PlotIndexSetDouble(fiboLevel5BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
//
// SAR ...
@@ -1819,6 +1887,14 @@ void FillBuffersZero(int barIndex)
valeBuffer[barIndex] = emptyValue;
valeGoldenBuffer[barIndex] = emptyValue;
//
// FiBo ...
fiboLevel1Buffer[barIndex] = emptyValue;
fiboLevel2Buffer[barIndex] = emptyValue;
fiboLevel3Buffer[barIndex] = emptyValue;
fiboLevel4Buffer[barIndex] = emptyValue;
fiboLevel5Buffer[barIndex] = emptyValue;
//
// SAR ...
sarBuffer[barIndex] = emptyValue;
@@ -2030,12 +2106,6 @@ void CalculateValues(
double iHHH = hHHBuffer[bar_index];
double iHLL = hLLBuffer[bar_index];
//
// Calculate BOS ...
//
// Calculate CHOCH ...
//
// Calculate Support ...
double lastSupport =
@@ -2131,15 +2201,105 @@ void CalculateValues(
);
}
//
// Calculate Swings ...
//
double lastSwingLow =
isFirstBar
? emptyValue
: swingLowBuffer[lastBarIndex];
double lastSwingHigh =
isFirstBar
? emptyValue
: swingHighBuffer[lastBarIndex];
//
bool isSwingLow = IsSwingLow(
high,
low,
bar_index,
swingLength //
);
bool isSwingHigh = IsSwingHigh(
high,
low,
bar_index,
swingLength //
);
bool hasSwing = isSwingLow ||
isSwingHigh;
double iSwingLow = emptyValue;
double iSwingHigh = emptyValue;
if (!hasSwing)
{
//
// FillBuffersZero(bar_index);
//
iSwingLow = lastSwingLow;
iSwingHigh = lastSwingHigh;
//
swingLowBuffer[bar_index] = lastSwingLow;
swingHighBuffer[bar_index] = lastSwingHigh;
}
else
{
//
iSwingLow = low[bar_index];
double iSwingHigh = high[bar_index];
//
if (isSwingLow && !isSwingHigh)
{
iSwingHigh = lastSwingHigh;
}
else if (isSwingHigh && !isSwingLow)
{
iSwingLow = lastSwingLow;
}
//
if (iSwingLow > lastSwingLow &&
iSwingHigh == lastSwingHigh)
{
iSwingLow = lastSwingLow;
}
//
if (iSwingHigh < lastSwingHigh &&
iSwingLow == lastSwingLow)
{
iSwingHigh = lastSwingHigh;
}
//
swingLowBuffer[bar_index] = iSwingLow;
swingHighBuffer[bar_index] = iSwingHigh;
}
//
// Calculate Fibo Levels ...
//
double iFiboUpper = peakBuffer[bar_index];
double iFiboLower = valeBuffer[bar_index];
double iFiboValues[] = {
peakBuffer[bar_index],
valeBuffer[bar_index],
supBuffer[bar_index],
swingLowBuffer[bar_index],
swingHighBuffer[bar_index],
resBuffer[bar_index], //
};
//
double iFiboLevel1 = GetFibonacciLevel(
double iFiboUpper = GetMax(iFiboValues);
double iFiboLower = GetMin(iFiboValues);
//
// Fibo Level 1 ...
double iFiboLevel1 = emptyValue;
iFiboLevel1 = GetFibonacciLevel(
iFiboUpper,
iFiboLower,
fiboLevel1,
@@ -2148,7 +2308,9 @@ void CalculateValues(
fiboLevel1Buffer[bar_index] = iFiboLevel1;
//
double iFiboLevel2 = GetFibonacciLevel(
// Fibo Level 2 ...
double iFiboLevel2 = emptyValue;
iFiboLevel2 = GetFibonacciLevel(
iFiboUpper,
iFiboLower,
fiboLevel2,
@@ -2157,7 +2319,9 @@ void CalculateValues(
fiboLevel2Buffer[bar_index] = iFiboLevel2;
//
double iFiboLevel3 = GetFibonacciLevel(
// Fibo Level 3 ...
double iFiboLevel3 = emptyValue;
iFiboLevel3 = GetFibonacciLevel(
iFiboUpper,
iFiboLower,
fiboLevel3,
@@ -2165,6 +2329,28 @@ void CalculateValues(
);
fiboLevel3Buffer[bar_index] = iFiboLevel3;
//
// Fibo Level 4 ...
double iFiboLevel4 = emptyValue;
iFiboLevel4 = GetFibonacciLevel(
iFiboUpper,
iFiboLower,
fiboLevel4,
X_DIRECTION_BEARISH //
);
fiboLevel4Buffer[bar_index] = iFiboLevel4;
//
// Fibo Level 5 ...
double iFiboLevel5 = emptyValue;
iFiboLevel5 = GetFibonacciLevel(
iFiboUpper,
iFiboLower,
fiboLevel5,
X_DIRECTION_BEARISH //
);
fiboLevel5Buffer[bar_index] = iFiboLevel5;
//
// Calculate Trend Color Buffer ...
double iClose = close[bar_index];
@@ -2279,43 +2465,6 @@ void CalculateValues(
peakGoldenBuffer[bar_index] = iPeakGold;
valeGoldenBuffer[bar_index] = iValeGold;
//
// Calculate Swings ...
//
double lastSwingLow =
isFirstBar
? emptyValue
: swingLowBuffer[lastBarIndex];
bool isSwingLow = IsSwingLow(
high,
low,
bar_index,
swingLength //
);
double iSwingLow =
isSwingLow
? low[bar_index]
: lastSwingLow;
swingLowBuffer[bar_index] = iSwingLow;
//
double lastSwingHigh =
isFirstBar
? emptyValue
: swingHighBuffer[lastBarIndex];
bool isSwingHigh = IsSwingHigh(
high,
low,
bar_index,
swingLength //
);
double iSwingHigh =
isSwingHigh
? high[bar_index]
: lastSwingHigh;
swingHighBuffer[bar_index] = iSwingHigh;
//
// TKI State and Color ...