Skip to content

Commit

Permalink
Fixes timeframe handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Jun 27, 2022
1 parent b010f5d commit fc68e55
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Indicator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ class Indicator : public IndicatorData {
*/
// ENUM_TIMEFRAMES GetTf() { return Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF); }

/**
* Gets indicator's time-frame.
*/
ENUM_TIMEFRAMES GetTf() { return iparams.tf.GetTf(); }

/**
* Gets indicator's signals.
*
Expand Down
7 changes: 0 additions & 7 deletions IndicatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(CHART_PARAM_SYMBOL); }

/**
* Gets indicator's time-frame.
*/
ENUM_TIMEFRAMES GetTf() { return Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF); }

/* Defines MQL backward compatible methods */

double iCustom(int& _handle, string _symbol, ENUM_TIMEFRAMES _tf, string _name, int _mode, int _shift) {
Expand Down
6 changes: 3 additions & 3 deletions IndicatorData.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IS_FED))) {
// Calculating start_bar.
Expand Down Expand Up @@ -521,7 +521,7 @@ class IndicatorData : public IndicatorBase {
Ref<IndicatorData> _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);
Expand Down
4 changes: 2 additions & 2 deletions Storage/ValueStorage.indicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class IndicatorBufferValueStorage : public HistoryValueStorage<C> {
/**
* 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.
Expand Down

0 comments on commit fc68e55

Please sign in to comment.