mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-07-27 20:47:44 +00:00
refactor: Refactored to use MovingAverage_Engine
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "3.21" // Fixed display mode bug
|
||||
#property version "4.00" // Refactored to use MovingAverage_Engine
|
||||
#property description "A professional, unified RSI with selectable price source (incl. Heikin Ashi),"
|
||||
#property description "a flexible MA signal line, and optional Bollinger Bands."
|
||||
|
||||
//--- Indicator Window and Plot Properties ---
|
||||
#property indicator_separate_window
|
||||
#property indicator_buffers 4
|
||||
#property indicator_plots 4
|
||||
@@ -56,17 +57,16 @@ input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
|
||||
input group "Overlay Settings"
|
||||
input ENUM_DISPLAY_MODE InpDisplayMode = DISPLAY_RSI_AND_BANDS;
|
||||
input int InpPeriodMA = 20;
|
||||
input ENUM_MA_METHOD InpMethodMA = MODE_SMA;
|
||||
// UPDATED: Use ENUM_MA_TYPE
|
||||
input ENUM_MA_TYPE InpMethodMA = SMA;
|
||||
input double InpBandsDev = 2.0;
|
||||
|
||||
//--- Indicator Buffers ---
|
||||
double BufferRSI[], BufferSignalMA[], BufferUpperBand[], BufferLowerBand[];
|
||||
|
||||
//--- Global calculator object (as a base class pointer) ---
|
||||
//--- Global calculator object ---
|
||||
CRSIProCalculator *g_calculator;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function. |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
@@ -80,7 +80,6 @@ int OnInit()
|
||||
ArraySetAsSeries(BufferUpperBand, false);
|
||||
ArraySetAsSeries(BufferLowerBand, false);
|
||||
|
||||
//--- Dynamic Calculator Instantiation ---
|
||||
if(InpSourcePrice <= PRICE_HA_CLOSE)
|
||||
{
|
||||
g_calculator = new CRSIProCalculator_HA();
|
||||
@@ -108,8 +107,6 @@ int OnInit()
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator deinitialization function. |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
@@ -117,8 +114,6 @@ void OnDeinit(const int reason)
|
||||
delete g_calculator;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator calculation function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnCalculate(const int rates_total,
|
||||
const int prev_calculated,
|
||||
@@ -139,14 +134,9 @@ int OnCalculate(const int rates_total,
|
||||
else
|
||||
price_type = (ENUM_APPLIED_PRICE)InpSourcePrice;
|
||||
|
||||
//--- Delegate calculation (Calculates ALL buffers)
|
||||
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close,
|
||||
BufferRSI, BufferSignalMA, BufferUpperBand, BufferLowerBand);
|
||||
|
||||
//--- FIX: Force hide unused buffers for the ENTIRE history
|
||||
//--- Since the calculator fills them all, we must clear what we don't want to see.
|
||||
//--- Clearing a double array is very fast, so we do it from 0.
|
||||
|
||||
if(InpDisplayMode == DISPLAY_RSI_ONLY)
|
||||
{
|
||||
ArrayInitialize(BufferSignalMA, EMPTY_VALUE);
|
||||
|
||||
Reference in New Issue
Block a user