From fc68e550c28cd050946855f0a04abcc9e867e213 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 27 Jun 2022 01:32:23 +0100 Subject: [PATCH] Fixes timeframe handling --- Indicator.mqh | 5 +++++ IndicatorBase.h | 7 ------- IndicatorData.mqh | 6 +++--- Storage/ValueStorage.indicator.h | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Indicator.mqh b/Indicator.mqh index 461bcc8f2..daee6fd22 100644 --- a/Indicator.mqh +++ b/Indicator.mqh @@ -402,6 +402,11 @@ class Indicator : public IndicatorData { */ // ENUM_TIMEFRAMES GetTf() { return Get(CHART_PARAM_TF); } + /** + * Gets indicator's time-frame. + */ + ENUM_TIMEFRAMES GetTf() { return iparams.tf.GetTf(); } + /** * Gets indicator's signals. * diff --git a/IndicatorBase.h b/IndicatorBase.h index 39deaab62..94b662314 100644 --- a/IndicatorBase.h +++ b/IndicatorBase.h @@ -320,18 +320,11 @@ class IndicatorBase : public Chart { */ // virtual bool ToString() = NULL; // @fixme? - /* Methods to get rid of */ - /** * Gets indicator's symbol. */ string GetSymbol() { return Get(CHART_PARAM_SYMBOL); } - /** - * Gets indicator's time-frame. - */ - ENUM_TIMEFRAMES GetTf() { return Get(CHART_PARAM_TF); } - /* Defines MQL backward compatible methods */ double iCustom(int& _handle, string _symbol, ENUM_TIMEFRAMES _tf, string _name, int _mode, int _shift) { diff --git a/IndicatorData.mqh b/IndicatorData.mqh index 21e374cee..0bc982946 100644 --- a/IndicatorData.mqh +++ b/IndicatorData.mqh @@ -474,8 +474,8 @@ class IndicatorData : public IndicatorBase { /* Getters */ - int GetBarsCalculated() { - int _bars = Bars(GetSymbol(), GetTf()); + int GetBarsCalculated(ENUM_TIMEFRAMES _tf = NULL) { + int _bars = Bars(GetSymbol(), _tf); if (!idparams.Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IS_FED))) { // Calculating start_bar. @@ -521,7 +521,7 @@ class IndicatorData : public IndicatorBase { Ref _indi = FetchDataSource(_type); if (!_indi.IsSet()) { Alert(GetFullName(), " does not define required indicator type ", EnumToString(_type), " for symbol ", - GetSymbol(), ", and timeframe ", GetTf(), "!"); + GetSymbol(), "!"); DebugBreak(); } else { indicators.Set((int)_type, _indi); diff --git a/Storage/ValueStorage.indicator.h b/Storage/ValueStorage.indicator.h index 928386577..6744660e6 100644 --- a/Storage/ValueStorage.indicator.h +++ b/Storage/ValueStorage.indicator.h @@ -51,8 +51,8 @@ class IndicatorBufferValueStorage : public HistoryValueStorage { /** * Constructor. */ - IndicatorBufferValueStorage(IndicatorData *_indi, int _mode = 0, bool _is_series = false) - : indicator(_indi), mode(_mode), HistoryValueStorage(_indi.GetSymbol(), _indi.GetTf()) {} + IndicatorBufferValueStorage(IndicatorData *_indi, int _mode = 0, ENUM_TIMEFRAMES _tf = NULL, bool _is_series = false) + : indicator(_indi), mode(_mode), HistoryValueStorage(_indi.GetSymbol(), _tf) {} /** * Fetches value from a given shift. Takes into consideration as-series flag.