From 202329c5283636eea751bdf68ed58ec4d129046d Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Tue, 25 Nov 2025 09:29:00 +0100 Subject: [PATCH] new files added --- .../Authors/Kaufman/Chaikin_AD_Pro.mq5 | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Indicators/MyIndicators/Authors/Kaufman/Chaikin_AD_Pro.mq5 diff --git a/Indicators/MyIndicators/Authors/Kaufman/Chaikin_AD_Pro.mq5 b/Indicators/MyIndicators/Authors/Kaufman/Chaikin_AD_Pro.mq5 new file mode 100644 index 0000000..c7261ce --- /dev/null +++ b/Indicators/MyIndicators/Authors/Kaufman/Chaikin_AD_Pro.mq5 @@ -0,0 +1,79 @@ +//+------------------------------------------------------------------+ +//| Chaikin_AD_Pro.mq5 | +//| Copyright 2025, xxxxxxxx| +//| | +//+------------------------------------------------------------------+ +#property copyright "Copyright 2025, xxxxxxxx" +#property version "1.00" +#property description "Chaikin Accumulation/Distribution (A/D) Line." +#property description "Also known as Volume Accumulator." + +#property indicator_separate_window +#property indicator_buffers 1 +#property indicator_plots 1 +#property indicator_label1 "A/D Line" +#property indicator_type1 DRAW_LINE +#property indicator_color1 clrDodgerBlue +#property indicator_style1 STYLE_SOLID +#property indicator_width1 1 + +#include + +//--- Input Parameters --- +input ENUM_APPLIED_VOLUME InpVolumeType = VOLUME_TICK; // Volume type to use +input ENUM_CANDLE_SOURCE InpCandleSource = CANDLE_STANDARD; // Candle source + +//--- Indicator Buffers --- +double BufferAD[]; + +//--- Global calculator object --- +CChaikinADCalculator *g_calculator; + +//+------------------------------------------------------------------+ +int OnInit() + { + if(InpVolumeType == VOLUME_REAL && SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_LIMIT) == 0) + { + Print("Error: Real Volume is not available for this symbol ('", _Symbol, "'). Please use Tick Volume."); + return(INIT_FAILED); + } + + SetIndexBuffer(0, BufferAD, INDICATOR_DATA); + ArraySetAsSeries(BufferAD, false); + + if(InpCandleSource == CANDLE_HEIKIN_ASHI) + g_calculator = new CChaikinADCalculator_HA(); + else + g_calculator = new CChaikinADCalculator(); + + if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpVolumeType)) + { + Print("Failed to initialize Chaikin A/D Calculator."); + return(INIT_FAILED); + } + + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Chaikin A/D%s", (InpCandleSource == CANDLE_HEIKIN_ASHI ? " HA" : ""))); + IndicatorSetInteger(INDICATOR_DIGITS, 0); + PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 1); + + return(INIT_SUCCEEDED); + } + +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) { if(CheckPointer(g_calculator) != POINTER_INVALID) delete g_calculator; } + +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, const int, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) + { + if(CheckPointer(g_calculator) == POINTER_INVALID) + return 0; + + if(InpVolumeType == VOLUME_REAL) + g_calculator.Calculate(rates_total, open, high, low, close, volume, BufferAD); + else + g_calculator.Calculate(rates_total, open, high, low, close, tick_volume, BufferAD); + + return(rates_total); + } +//+------------------------------------------------------------------+ +//+------------------------------------------------------------------+