diff --git a/Indicators/MyIndicators/Holt_Oscillator_HeikinAshi.mq5 b/Indicators/MyIndicators/Holt_Oscillator_HeikinAshi.mq5 new file mode 100644 index 0000000..29cee5c --- /dev/null +++ b/Indicators/MyIndicators/Holt_Oscillator_HeikinAshi.mq5 @@ -0,0 +1,79 @@ +//+------------------------------------------------------------------+ +//| Holt_Oscillator_HeikinAshi.mq5 | +//| Copyright 2025, xxxxxxxx| +//+------------------------------------------------------------------+ +#property copyright "Copyright 2025, xxxxxxxx" +#property version "1.00" +#property description "Holt's Trend Oscillator on Heikin Ashi data." + +#property indicator_separate_window +#property indicator_buffers 1 +#property indicator_plots 1 +#property indicator_level1 0.0 +#property indicator_levelstyle STYLE_DOT +#property indicator_levelcolor clrGray + +#include + +//--- Plot 1: Holt Trend Oscillator +#property indicator_label1 "Holt Trend (HA)" +#property indicator_type1 DRAW_HISTOGRAM +#property indicator_color1 clrSeaGreen, clrTomato +#property indicator_style1 STYLE_SOLID +#property indicator_width1 2 + +//--- Input Parameters --- +input int InpPeriod = 20; +input double InpAlpha = 0.1; +input double InpBeta = 0.05; + +//--- Indicator Buffers --- +double BufferOscillator[]; + +//--- Global calculator object --- +CHoltMACalculator_HA *g_calculator; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function. | +//+------------------------------------------------------------------+ +int OnInit() + { + SetIndexBuffer(0, BufferOscillator, INDICATOR_DATA); + ArraySetAsSeries(BufferOscillator, false); + + PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 2); + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Holt Osc HA(%d, %.2f, %.2f)", InpPeriod, InpAlpha, InpBeta)); + IndicatorSetInteger(INDICATOR_DIGITS, _Digits+2); + + g_calculator = new CHoltMACalculator_HA(); + if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriod, InpAlpha, InpBeta)) + { + Print("Failed to initialize Holt MA HA Calculator."); + return(INIT_FAILED); + } + return(INIT_SUCCEEDED); + } + +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function. | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) + { + if(CheckPointer(g_calculator) != POINTER_INVALID) + delete g_calculator; + } + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function. | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, const int, const datetime&[], const double &open[], const double &high[], const double &low[], const double &close[], const long&[], const long&[], const int&[]) + { + if(CheckPointer(g_calculator) != POINTER_INVALID) + { + double dummy_forecast[], dummy_level[]; + g_calculator.Calculate(rates_total, PRICE_CLOSE, open, high, low, close, dummy_forecast, BufferOscillator, dummy_level); + } + return(rates_total); + } +//+------------------------------------------------------------------+ +//+------------------------------------------------------------------+