mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-24 17:58:07 +00:00
refactor(indicators): Refactored with Dynamic Input Levels
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
//| Copyright 2026, xxxxxxxx|
|
//| Copyright 2026, xxxxxxxx|
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
#property copyright "Copyright 2026, xxxxxxxx"
|
#property copyright "Copyright 2026, xxxxxxxx"
|
||||||
#property version "2.00" // Upgraded with Double Buffering (Session Gaps)
|
#property version "2.10" // Refactored with Dynamic Input Levels
|
||||||
#property description "V-Score Projected Bands on Main Chart."
|
#property description "V-Score Projected Bands on Main Chart."
|
||||||
#property description "Rolling standard deviation (Bollinger style) around VWAP."
|
#property description "Rolling standard deviation (Bollinger style) around VWAP."
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
#property indicator_style2 STYLE_SOLID
|
#property indicator_style2 STYLE_SOLID
|
||||||
#property indicator_width2 1
|
#property indicator_width2 1
|
||||||
|
|
||||||
//--- Plot 3 & 4: Upper 1.5 Band (Odd / Even)
|
//--- Plot 3 & 4: Upper Flow Band (Odd / Even)
|
||||||
#property indicator_label3 "Bull Flow (+1.5)"
|
#property indicator_label3 "Bull Flow" // Dynamically updated in OnInit
|
||||||
#property indicator_type3 DRAW_LINE
|
#property indicator_type3 DRAW_LINE
|
||||||
#property indicator_color3 clrCoral
|
#property indicator_color3 clrCoral
|
||||||
#property indicator_style3 STYLE_SOLID
|
#property indicator_style3 STYLE_SOLID
|
||||||
@@ -37,8 +37,8 @@
|
|||||||
#property indicator_style4 STYLE_SOLID
|
#property indicator_style4 STYLE_SOLID
|
||||||
#property indicator_width4 1
|
#property indicator_width4 1
|
||||||
|
|
||||||
//--- Plot 5 & 6: Lower 1.5 Band (Odd / Even)
|
//--- Plot 5 & 6: Lower Flow Band (Odd / Even)
|
||||||
#property indicator_label5 "Bear Flow (-1.5)"
|
#property indicator_label5 "Bear Flow" // Dynamically updated in OnInit
|
||||||
#property indicator_type5 DRAW_LINE
|
#property indicator_type5 DRAW_LINE
|
||||||
#property indicator_color5 clrLightSkyBlue
|
#property indicator_color5 clrLightSkyBlue
|
||||||
#property indicator_style5 STYLE_SOLID
|
#property indicator_style5 STYLE_SOLID
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
#property indicator_style6 STYLE_SOLID
|
#property indicator_style6 STYLE_SOLID
|
||||||
#property indicator_width6 1
|
#property indicator_width6 1
|
||||||
|
|
||||||
//--- Plot 7 & 8: Upper 2.0 Band (Odd / Even)
|
//--- Plot 7 & 8: Upper Extreme Band (Odd / Even)
|
||||||
#property indicator_label7 "Bull Extreme (+2.0)"
|
#property indicator_label7 "Bull Extreme" // Dynamically updated in OnInit
|
||||||
#property indicator_type7 DRAW_LINE
|
#property indicator_type7 DRAW_LINE
|
||||||
#property indicator_color7 clrCoral
|
#property indicator_color7 clrCoral
|
||||||
#property indicator_style7 STYLE_SOLID
|
#property indicator_style7 STYLE_SOLID
|
||||||
@@ -63,8 +63,8 @@
|
|||||||
#property indicator_style8 STYLE_SOLID
|
#property indicator_style8 STYLE_SOLID
|
||||||
#property indicator_width8 1
|
#property indicator_width8 1
|
||||||
|
|
||||||
//--- Plot 9 & 10: Lower 2.0 Band (Odd / Even)
|
//--- Plot 9 & 10: Lower Extreme Band (Odd / Even)
|
||||||
#property indicator_label9 "Bear Extreme (-2.0)"
|
#property indicator_label9 "Bear Extreme" // Dynamically updated in OnInit
|
||||||
#property indicator_type9 DRAW_LINE
|
#property indicator_type9 DRAW_LINE
|
||||||
#property indicator_color9 clrLightSkyBlue
|
#property indicator_color9 clrLightSkyBlue
|
||||||
#property indicator_style9 STYLE_SOLID
|
#property indicator_style9 STYLE_SOLID
|
||||||
@@ -76,8 +76,8 @@
|
|||||||
#property indicator_style10 STYLE_SOLID
|
#property indicator_style10 STYLE_SOLID
|
||||||
#property indicator_width10 1
|
#property indicator_width10 1
|
||||||
|
|
||||||
//--- Plot 11 & 12: Upper 2.5 Band (Odd / Even)
|
//--- Plot 11 & 12: Upper Wall Band (Odd / Even)
|
||||||
#property indicator_label11 "Bull Wall (+2.5)"
|
#property indicator_label11 "Bull Wall" // Dynamically updated in OnInit
|
||||||
#property indicator_type11 DRAW_LINE
|
#property indicator_type11 DRAW_LINE
|
||||||
#property indicator_color11 clrOrangeRed
|
#property indicator_color11 clrOrangeRed
|
||||||
#property indicator_style11 STYLE_SOLID
|
#property indicator_style11 STYLE_SOLID
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
#property indicator_style12 STYLE_SOLID
|
#property indicator_style12 STYLE_SOLID
|
||||||
#property indicator_width12 1
|
#property indicator_width12 1
|
||||||
|
|
||||||
//--- Plot 13 & 14: Lower 2.5 Band (Odd / Even)
|
//--- Plot 13 & 14: Lower Wall Band (Odd / Even)
|
||||||
#property indicator_label13 "Bear Wall (-2.5)"
|
#property indicator_label13 "Bear Wall" // Dynamically updated in OnInit
|
||||||
#property indicator_type13 DRAW_LINE
|
#property indicator_type13 DRAW_LINE
|
||||||
#property indicator_color13 clrDeepSkyBlue
|
#property indicator_color13 clrDeepSkyBlue
|
||||||
#property indicator_style13 STYLE_SOLID
|
#property indicator_style13 STYLE_SOLID
|
||||||
@@ -105,19 +105,27 @@
|
|||||||
#include <MyIncludes\VWAP_Calculator.mqh>
|
#include <MyIncludes\VWAP_Calculator.mqh>
|
||||||
|
|
||||||
//--- Input Parameters
|
//--- Input Parameters
|
||||||
input group "V-Score Logic Settings"
|
input group "V-Score Core Settings"
|
||||||
input int InpPeriod = 20; // Volatility Lookback
|
input int InpPeriod = 20; // Volatility Lookback
|
||||||
input ENUM_VWAP_PERIOD InpVWAPReset = PERIOD_SESSION; // VWAP Anchor
|
input ENUM_VWAP_PERIOD InpVWAPReset = PERIOD_SESSION; // VWAP Anchor
|
||||||
input ENUM_APPLIED_VOLUME InpVolumeType = VOLUME_TICK; // Volume Type
|
input ENUM_APPLIED_VOLUME InpVolumeType = VOLUME_TICK; // Volume Type
|
||||||
|
|
||||||
//--- Double Buffers
|
//+------------------------------------------------------------------+
|
||||||
double BufVWAP_Odd[], BufVWAP_Even[];
|
//| |
|
||||||
double BufUp15_Odd[], BufUp15_Even[];
|
//+------------------------------------------------------------------+
|
||||||
double BufDn15_Odd[], BufDn15_Even[];
|
input group "V-Score Z-Levels (Standard Deviations)"
|
||||||
double BufUp20_Odd[], BufUp20_Even[];
|
input double InpLevelFlow = 1.5; // Flow Level (Point of No Return)
|
||||||
double BufDn20_Odd[], BufDn20_Even[];
|
input double InpLevelExtreme = 2.0; // Extreme Level (Warning)
|
||||||
double BufUp25_Odd[], BufUp25_Even[];
|
input double InpLevelWall = 2.5; // Wall Level (Climax Exhaustion)
|
||||||
double BufDn25_Odd[], BufDn25_Even[];
|
|
||||||
|
//--- Double Buffers (Semantically Named)
|
||||||
|
double BufVWAP_Odd[], BufVWAP_Even[];
|
||||||
|
double BufUpFlow_Odd[], BufUpFlow_Even[];
|
||||||
|
double BufDnFlow_Odd[], BufDnFlow_Even[];
|
||||||
|
double BufUpExtr_Odd[], BufUpExtr_Even[];
|
||||||
|
double BufDnExtr_Odd[], BufDnExtr_Even[];
|
||||||
|
double BufUpWall_Odd[], BufUpWall_Even[];
|
||||||
|
double BufDnWall_Odd[], BufDnWall_Even[];
|
||||||
|
|
||||||
// Internal Arrays
|
// Internal Arrays
|
||||||
double m_vwap_odd[];
|
double m_vwap_odd[];
|
||||||
@@ -132,27 +140,35 @@ CVWAPCalculator *g_vwap;
|
|||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
int OnInit()
|
int OnInit()
|
||||||
{
|
{
|
||||||
// VWAP
|
// VWAP Base
|
||||||
SetIndexBuffer(0, BufVWAP_Odd, INDICATOR_DATA);
|
SetIndexBuffer(0, BufVWAP_Odd, INDICATOR_DATA);
|
||||||
SetIndexBuffer(1, BufVWAP_Even, INDICATOR_DATA);
|
SetIndexBuffer(1, BufVWAP_Even, INDICATOR_DATA);
|
||||||
// +1.5
|
|
||||||
SetIndexBuffer(2, BufUp15_Odd, INDICATOR_DATA);
|
// Flow Level Bands
|
||||||
SetIndexBuffer(3, BufUp15_Even, INDICATOR_DATA);
|
SetIndexBuffer(2, BufUpFlow_Odd, INDICATOR_DATA);
|
||||||
// -1.5
|
SetIndexBuffer(3, BufUpFlow_Even, INDICATOR_DATA);
|
||||||
SetIndexBuffer(4, BufDn15_Odd, INDICATOR_DATA);
|
SetIndexBuffer(4, BufDnFlow_Odd, INDICATOR_DATA);
|
||||||
SetIndexBuffer(5, BufDn15_Even, INDICATOR_DATA);
|
SetIndexBuffer(5, BufDnFlow_Even, INDICATOR_DATA);
|
||||||
// +2.0
|
|
||||||
SetIndexBuffer(6, BufUp20_Odd, INDICATOR_DATA);
|
// Extreme Level Bands
|
||||||
SetIndexBuffer(7, BufUp20_Even, INDICATOR_DATA);
|
SetIndexBuffer(6, BufUpExtr_Odd, INDICATOR_DATA);
|
||||||
// -2.0
|
SetIndexBuffer(7, BufUpExtr_Even, INDICATOR_DATA);
|
||||||
SetIndexBuffer(8, BufDn20_Odd, INDICATOR_DATA);
|
SetIndexBuffer(8, BufDnExtr_Odd, INDICATOR_DATA);
|
||||||
SetIndexBuffer(9, BufDn20_Even, INDICATOR_DATA);
|
SetIndexBuffer(9, BufDnExtr_Even, INDICATOR_DATA);
|
||||||
// +2.5
|
|
||||||
SetIndexBuffer(10, BufUp25_Odd, INDICATOR_DATA);
|
// Wall Level Bands
|
||||||
SetIndexBuffer(11, BufUp25_Even, INDICATOR_DATA);
|
SetIndexBuffer(10, BufUpWall_Odd, INDICATOR_DATA);
|
||||||
// -2.5
|
SetIndexBuffer(11, BufUpWall_Even, INDICATOR_DATA);
|
||||||
SetIndexBuffer(12, BufDn25_Odd, INDICATOR_DATA);
|
SetIndexBuffer(12, BufDnWall_Odd, INDICATOR_DATA);
|
||||||
SetIndexBuffer(13, BufDn25_Even, INDICATOR_DATA);
|
SetIndexBuffer(13, BufDnWall_Even, INDICATOR_DATA);
|
||||||
|
|
||||||
|
// Dynamically set plot labels to reflect custom input levels in the Data Window
|
||||||
|
PlotIndexSetString(2, PLOT_LABEL, StringFormat("Bull Flow (+%.2f)", InpLevelFlow));
|
||||||
|
PlotIndexSetString(4, PLOT_LABEL, StringFormat("Bear Flow (-%.2f)", InpLevelFlow));
|
||||||
|
PlotIndexSetString(6, PLOT_LABEL, StringFormat("Bull Extr (+%.2f)", InpLevelExtreme));
|
||||||
|
PlotIndexSetString(8, PLOT_LABEL, StringFormat("Bear Extr (-%.2f)", InpLevelExtreme));
|
||||||
|
PlotIndexSetString(10, PLOT_LABEL, StringFormat("Bull Wall (+%.2f)", InpLevelWall));
|
||||||
|
PlotIndexSetString(12, PLOT_LABEL, StringFormat("Bear Wall (-%.2f)", InpLevelWall));
|
||||||
|
|
||||||
// Prevent drawing lines to 0 when values are empty
|
// Prevent drawing lines to 0 when values are empty
|
||||||
for(int i=0; i<14; i++)
|
for(int i=0; i<14; i++)
|
||||||
@@ -222,18 +238,18 @@ int OnCalculate(const int rates_total,
|
|||||||
// Reset all outputs for current bar first
|
// Reset all outputs for current bar first
|
||||||
BufVWAP_Odd[i] = EMPTY_VALUE;
|
BufVWAP_Odd[i] = EMPTY_VALUE;
|
||||||
BufVWAP_Even[i] = EMPTY_VALUE;
|
BufVWAP_Even[i] = EMPTY_VALUE;
|
||||||
BufUp15_Odd[i] = EMPTY_VALUE;
|
BufUpFlow_Odd[i] = EMPTY_VALUE;
|
||||||
BufUp15_Even[i] = EMPTY_VALUE;
|
BufUpFlow_Even[i] = EMPTY_VALUE;
|
||||||
BufDn15_Odd[i] = EMPTY_VALUE;
|
BufDnFlow_Odd[i] = EMPTY_VALUE;
|
||||||
BufDn15_Even[i] = EMPTY_VALUE;
|
BufDnFlow_Even[i] = EMPTY_VALUE;
|
||||||
BufUp20_Odd[i] = EMPTY_VALUE;
|
BufUpExtr_Odd[i] = EMPTY_VALUE;
|
||||||
BufUp20_Even[i] = EMPTY_VALUE;
|
BufUpExtr_Even[i] = EMPTY_VALUE;
|
||||||
BufDn20_Odd[i] = EMPTY_VALUE;
|
BufDnExtr_Odd[i] = EMPTY_VALUE;
|
||||||
BufDn20_Even[i] = EMPTY_VALUE;
|
BufDnExtr_Even[i] = EMPTY_VALUE;
|
||||||
BufUp25_Odd[i] = EMPTY_VALUE;
|
BufUpWall_Odd[i] = EMPTY_VALUE;
|
||||||
BufUp25_Even[i] = EMPTY_VALUE;
|
BufUpWall_Even[i] = EMPTY_VALUE;
|
||||||
BufDn25_Odd[i] = EMPTY_VALUE;
|
BufDnWall_Odd[i] = EMPTY_VALUE;
|
||||||
BufDn25_Even[i] = EMPTY_VALUE;
|
BufDnWall_Even[i] = EMPTY_VALUE;
|
||||||
|
|
||||||
// If VWAP is missing or just reset, continue
|
// If VWAP is missing or just reset, continue
|
||||||
if(current_vwap == 0 || current_vwap == EMPTY_VALUE)
|
if(current_vwap == 0 || current_vwap == EMPTY_VALUE)
|
||||||
@@ -263,22 +279,22 @@ int OnCalculate(const int rates_total,
|
|||||||
BufVWAP_Odd[i] = current_vwap;
|
BufVWAP_Odd[i] = current_vwap;
|
||||||
if(std_dev > 1.0e-9)
|
if(std_dev > 1.0e-9)
|
||||||
{
|
{
|
||||||
BufUp15_Odd[i] = current_vwap + (1.5 * std_dev);
|
BufUpFlow_Odd[i] = current_vwap + (InpLevelFlow * std_dev);
|
||||||
BufDn15_Odd[i] = current_vwap - (1.5 * std_dev);
|
BufDnFlow_Odd[i] = current_vwap - (InpLevelFlow * std_dev);
|
||||||
BufUp20_Odd[i] = current_vwap + (2.0 * std_dev);
|
BufUpExtr_Odd[i] = current_vwap + (InpLevelExtreme * std_dev);
|
||||||
BufDn20_Odd[i] = current_vwap - (2.0 * std_dev);
|
BufDnExtr_Odd[i] = current_vwap - (InpLevelExtreme * std_dev);
|
||||||
BufUp25_Odd[i] = current_vwap + (2.5 * std_dev);
|
BufUpWall_Odd[i] = current_vwap + (InpLevelWall * std_dev);
|
||||||
BufDn25_Odd[i] = current_vwap - (2.5 * std_dev);
|
BufDnWall_Odd[i] = current_vwap - (InpLevelWall * std_dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Collapse bands to VWAP if zero volatility
|
// Collapse bands to VWAP if zero volatility
|
||||||
BufUp15_Odd[i] = current_vwap;
|
BufUpFlow_Odd[i] = current_vwap;
|
||||||
BufDn15_Odd[i] = current_vwap;
|
BufDnFlow_Odd[i] = current_vwap;
|
||||||
BufUp20_Odd[i] = current_vwap;
|
BufUpExtr_Odd[i] = current_vwap;
|
||||||
BufDn20_Odd[i] = current_vwap;
|
BufDnExtr_Odd[i] = current_vwap;
|
||||||
BufUp25_Odd[i] = current_vwap;
|
BufUpWall_Odd[i] = current_vwap;
|
||||||
BufDn25_Odd[i] = current_vwap;
|
BufDnWall_Odd[i] = current_vwap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -286,21 +302,22 @@ int OnCalculate(const int rates_total,
|
|||||||
BufVWAP_Even[i] = current_vwap;
|
BufVWAP_Even[i] = current_vwap;
|
||||||
if(std_dev > 1.0e-9)
|
if(std_dev > 1.0e-9)
|
||||||
{
|
{
|
||||||
BufUp15_Even[i] = current_vwap + (1.5 * std_dev);
|
BufUpFlow_Even[i] = current_vwap + (InpLevelFlow * std_dev);
|
||||||
BufDn15_Even[i] = current_vwap - (1.5 * std_dev);
|
BufDnFlow_Even[i] = current_vwap - (InpLevelFlow * std_dev);
|
||||||
BufUp20_Even[i] = current_vwap + (2.0 * std_dev);
|
BufUpExtr_Even[i] = current_vwap + (InpLevelExtreme * std_dev);
|
||||||
BufDn20_Even[i] = current_vwap - (2.0 * std_dev);
|
BufDnExtr_Even[i] = current_vwap - (InpLevelExtreme * std_dev);
|
||||||
BufUp25_Even[i] = current_vwap + (2.5 * std_dev);
|
BufUpWall_Even[i] = current_vwap + (InpLevelWall * std_dev);
|
||||||
BufDn25_Even[i] = current_vwap - (2.5 * std_dev);
|
BufDnWall_Even[i] = current_vwap - (InpLevelWall * std_dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BufUp15_Even[i] = current_vwap;
|
// Collapse bands to VWAP if zero volatility
|
||||||
BufDn15_Even[i] = current_vwap;
|
BufUpFlow_Even[i] = current_vwap;
|
||||||
BufUp20_Even[i] = current_vwap;
|
BufDnFlow_Even[i] = current_vwap;
|
||||||
BufDn20_Even[i] = current_vwap;
|
BufUpExtr_Even[i] = current_vwap;
|
||||||
BufUp25_Even[i] = current_vwap;
|
BufDnExtr_Even[i] = current_vwap;
|
||||||
BufDn25_Even[i] = current_vwap;
|
BufUpWall_Even[i] = current_vwap;
|
||||||
|
BufDnWall_Even[i] = current_vwap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user