Files
mql5/Indicators/MyIndicators/Holt_Oscillator_HeikinAshi.mq5
T
2025-09-22 13:53:55 +02:00

80 lines
3.1 KiB
Plaintext

//+------------------------------------------------------------------+
//| 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 <MyIncludes\Holt_Calculator.mqh>
//--- 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);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+