diff --git a/ChartBase.h b/ChartBase.h index 7cf488116..99010949a 100644 --- a/ChartBase.h +++ b/ChartBase.h @@ -96,7 +96,7 @@ class ChartBase : public Dynamic { /** * Returns time of the bar with a given shift. */ - virtual datetime GetBarTime(int _shift = 0) = 0; + virtual datetime GetBarTime(int _rel_shift = 0) = 0; datetime GetLastBarTime() { return last_bar_time; } @@ -170,14 +170,14 @@ class ChartBase : public Dynamic { /** * Gets OHLC price values. */ - virtual BarOHLC GetOHLC(int _shift = 0) { - datetime _time = GetBarTime(_shift); + virtual BarOHLC GetOHLC(int _rel_shift = 0) { + datetime _time = GetBarTime(_rel_shift); float _open = 0, _high = 0, _low = 0, _close = 0; if (_time > 0) { - _open = (float)GetOpen(_shift); - _high = (float)GetHigh(_shift); - _low = (float)GetLow(_shift); - _close = (float)GetClose(_shift); + _open = (float)GetOpen(_rel_shift); + _high = (float)GetHigh(_rel_shift); + _low = (float)GetLow(_rel_shift); + _close = (float)GetClose(_rel_shift); } BarOHLC _ohlc(_open, _high, _low, _close, _time); return _ohlc; diff --git a/ChartMt.h b/ChartMt.h index b09ea050b..5f32f0230 100644 --- a/ChartMt.h +++ b/ChartMt.h @@ -67,11 +67,11 @@ class ChartMt : public ChartBase { /** * Returns time of the bar with a given shift. */ - virtual datetime GetBarTime(int _shift = 0) override { - datetime _time = ::iTime(GetSymbol(), GetTf(), _shift); + virtual datetime GetBarTime(int _rel_shift = 0) override { + datetime _time = ::iTime(GetSymbol(), GetTf(), _rel_shift); if (_LastError != ERR_NO_ERROR) { - Print("Error: ", _LastError, " while doing ::iTime() in ChartMt::GetBarTime(", _shift, ")"); + Print("Error: ", _LastError, " while doing ::iTime() in ChartMt::GetBarTime(", _rel_shift, ")"); DebugBreak(); } diff --git a/Indicator/Details.md b/Indicator/Details.md index e7dfb7644..cbb2e3414 100644 --- a/Indicator/Details.md +++ b/Indicator/Details.md @@ -1,8 +1,9 @@ -# Explanation of shift parameters in Indicator/IndicatorData classes for following methods: -- `GetEntryValue(int _mode, int _abs_shift)` +#Explanation of shift parameters in Indicator / IndicatorData / other classes for following methods: +- `GetEntryValue(int _mode = 0, int _abs_shift = 0)` - `GetEntryAlter(IndicatorDataEntry &_entry, int _rel_shift)` - `GetValue(int _mode = 0, int _rel_shift = 0)` - `GetEntry(int _rel_shift = 0)` +- `GetBarTime(int _rel_shift = 0)` ## GetEntryValue(int _mode, int _abs_shift) - overridable method @@ -10,50 +11,93 @@ Method must be overriden in any new indicator and MUST NOT apply shift from `ipa Returns indicators's value for a given mode and absolute shift (the shift is directly passed to built-in methods such as iATR(), OnCalculate methods such as `iVIDyAOnIndicator()` and also to `iCustom()`). -For `OnCalculate()` methods such as iVIDyAOnIndicator(), the shift is passed to `return _cache.GetTailValue(_mode, _shift);` so we can return value calculated in the past (or just retrieve **DBL_MAX** in case the value was not yet calculated). -Note that `OnCalculate()` methods uses single/multiple price buffers, e.g., applied price or OHLCs from base indicator. +For `OnCalculate()` methods such as iVIDyAOnIndicator(), the shift is passed to `return _cache.GetTailValue(_mode, _shift); +` so we can return value calculated in the past(or just retrieve * *DBL_MAX * *in case the value was not yet calculated) + .Note that `OnCalculate()` methods uses single / + multiple price buffers, + e.g., + applied price or OHLCs from base indicator. -In scenario of `VIDyA[shift = 2] <- Candle <- TickMt` call hierarchy looks like: + In scenario of `VIDyA[shift = 2] < -Candle < -TickMt` call hierarchy looks like : +```cpp - VIDyA::GetEntry(_rel_shift = 1) // Then per each mode: + - entry.values[_mode] = + Indicator::GetValue(_mode, _rel_shift = 1) - VIDyA::GetEntryValue(_mode, _abs_shift = iparams.shift + 1) - + VIDyA::iVIDyAOnIndicator(..., _mode, _shift = 3) then : // Shift is absolute. + -VIDyA::iVIDyAOnArray(..., _mode, _shift = 3) then + : // Shift is absolute. + return _cache.GetTailValue(_mode, _shift = 3); // Shift is absolute. +``` Last line means that we will retrieve **VIDyA **value shifted by 3(2 from `iparams.shift` + 1 from `GetEntry()`) + .It is correct. + + ##GetEntryAlter(IndicatorDataEntry &_entry, int _rel_shift) - + overridable method + + Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`) + . + + Method calls(seen in **MWMFI **, **CCI **, **Envelopes **, **Momentum **, **Pivot **) + : ```cpp -- VIDyA::GetEntry(_rel_shift = 1) // Then per each mode: -- entry.values[_mode] = Indicator::GetValue(_mode, _rel_shift = 1) -- VIDyA::GetEntryValue(_mode, _abs_shift = iparams.shift + 1) -- VIDyA::iVIDyAOnIndicator(..., _mode, _shift = 3) then: // Shift is absolute. -- VIDyA::iVIDyAOnArray(..., _mode, _shift = 3) then: // Shift is absolute. - return _cache.GetTailValue(_mode, _shift = 3); // Shift is absolute. + - + GetValue(_mode, _rel_shift) // GetValue() takes relative shift. ``` -Last line means that we will retrieve **VIDyA** value shifted by 3 (2 from `iparams.shift` + 1 from `GetEntry()`). It is correct. -## GetEntryAlter(IndicatorDataEntry &_entry, int _rel_shift) - overridable method + ##GetValue(int _mode = 0, int _rel_shift = 0) - + non - + overridable method -Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). + Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`) + . -Method calls (seen in **MWMFI**, **CCI**, **Envelopes**, **Momentum**, **Pivot**): + Method calls : ```cpp -- GetValue(_mode, _rel_shift) // GetValue() takes relative shift. + - + GetEntryValue(_mode, _abs_shift = iparams.shift + _rel_shift) ``` -## GetValue(int _mode = 0, int _rel_shift = 0) - non-overridable method + ##GetEntry(int _rel_shift = 0) - + overridable method -Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). + Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`) + . -Method calls: -```cpp -- GetEntryValue(_mode, _abs_shift = iparams.shift + _rel_shift) + If you need to access entries from absolute shift, + use `GetEntryByAbsShift(int _abs_shift)` + . + + Note that values accessed via index + operator `storage[rel_shift]` e.g., + inside `OnCalculate()` methods like `double _o = + open[rel_shift = 4].Get()` will take relative shift + and retrieve open price shifted by(in this scenario) `4 + iparams.shift` set in base indicator : +```cpp - double _o = + open[_rel_shift = 4] - IndicatorBufferValueStorage::Fetch(_rel_shift = 4) - + IndicatorData::GetValue(_mode, _rel_shift = 4) - + Indicator::GetEntryValue( + _mode, _abs_shift = iparams.shift + + 4) // As GetEntryValue() takes absolute shift, we add shift from iparams.shift. + - Indicator::GetEntry(_rel_shift = + _abs_shift - + iparams.shift)... // Converting absolute shift into relative one for GetEntry(). + - ...[_mode]; // IndicatorDataEntry.values[_mode].Get(...); ``` -## GetEntry(int _rel_shift = 0) - overridable method +## GetBarTime(int _rel_shift = 0) Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). -If you need to access entries from absolute shift, use `GetEntryByAbsShift(int _abs_shift)`. +## GetPrice(ENUM_APPLIED_PRICE _ap, int _rel_shift = 0) -Note that values accessed via index operator `storage[rel_shift]` e.g., inside `OnCalculate()` methods like `double _o = open[rel_shift = 4].Get()` will take relative shift and retrieve open price shifted by (in this scenario) `4 + iparams.shift` set in base indicator: -```cpp -- double _o = open[_rel_shift = 4] -- IndicatorBufferValueStorage::Fetch(_rel_shift = 4) -- IndicatorData::GetValue(_mode, _rel_shift = 4) -- Indicator::GetEntryValue(_mode, _abs_shift = iparams.shift + 4) // As GetEntryValue() takes absolute shift, we add shift from iparams.shift. -- Indicator::GetEntry(_rel_shift = _abs_shift - iparams.shift)... // Converting absolute shift into relative one for GetEntry(). -- ...[_mode]; // IndicatorDataEntry.values[_mode].Get(...); -``` \ No newline at end of file +Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). + +## GetBars() + +Number of returned bars is decremented by `IndicatorParams::shift` (read via `Indicator::iparams.shift`). Thus if there are **10** bars and *shift* is **8** then `GetBars()` will return **2**. That means that you can safely do `GetEntry()` for relative shifts **0** or **1**. There won't be any value in other relative shifts. + +## HistoryValueStorage::Fetch(int _rel_shift) + +Shift passed is relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). + +## Indi_\*::\*OnIndicator(..., _shift, [_shift1], [_shift2]) + +All shifts passed are relative to the shift from `IndicatorParams::shift` (read via `Indicator::iparams.shift`). diff --git a/Indicator/Indicator.define.h b/Indicator/Indicator.define.h index d2ef7bce3..3d1a65c24 100644 --- a/Indicator/Indicator.define.h +++ b/Indicator/Indicator.define.h @@ -137,5 +137,5 @@ // We're adding 1 because e.g., shift 1 means that we need two bars to exist in // history in order to retrieve bar at shift 1. -#define INDI_REQUIRE_SHIFT_OR_RETURN(_indi, _shift, _ret) INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _shift + 1) -#define INDI_REQUIRE_SHIFT_OR_RETURN_EMPTY(_indi, _shift) INDI_REQUIRE_SHIFT_OR_RETURN(_indi, _shift, DBL_MAX) +#define INDI_REQUIRE_SHIFT_OR_RETURN(_indi, _rel_shift, _ret) INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _rel_shift + 1) +#define INDI_REQUIRE_SHIFT_OR_RETURN_EMPTY(_indi, _rel_shift) INDI_REQUIRE_SHIFT_OR_RETURN(_indi, _rel_shift, DBL_MAX) diff --git a/Indicator/Indicator.h b/Indicator/Indicator.h index c2a9af4a4..9bab3b18f 100644 --- a/Indicator/Indicator.h +++ b/Indicator/Indicator.h @@ -212,6 +212,18 @@ class Indicator : public IndicatorData { draw.SetWindow(_window); } + /* Converters */ + + /** + * Converts relative shift into absolute one. + */ + int ToAbsShift(int _rel_shift) override { return _rel_shift + iparams.shift; } + + /** + * Converts absolute shift into relative one. + */ + int ToRelShift(int _abs_shift) override { return _abs_shift - iparams.shift; } + /* Buffer methods */ virtual string CacheKey() { return GetFullName(); } @@ -575,11 +587,9 @@ class Indicator : public IndicatorData { * @return * Returns IndicatorDataEntry struct filled with indicator values. */ - IndicatorDataEntry GetEntry(int _index = 0) override { + IndicatorDataEntry GetEntry(int _rel_shift = 0) override { ResetLastError(); - int _ishift = _index + iparams.GetShift(); - long _bar_time; - _bar_time = GetBarTime(_ishift); + long _bar_time = GetBarTime(_rel_shift); if (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE)) == IDATA_BUILTIN && (GetPossibleDataModes() & IDATA_BUILTIN) == 0) { @@ -598,7 +608,7 @@ class Indicator : public IndicatorData { if (_bar_time > 0 && !_entry.IsValid() && !_entry.CheckFlag(INDI_ENTRY_FLAG_INSUFFICIENT_DATA)) { int _max_modes = Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES)); _entry.Resize(_max_modes); - _entry.timestamp = GetBarTime(_ishift); + _entry.timestamp = GetBarTime(_rel_shift); #ifndef __MQL4__ if (IndicatorData::Get(STRUCT_ENUM(IndicatorState, INDICATOR_STATE_PROP_IS_CHANGED))) { // Resets the handle on any parameter changes. @@ -611,22 +621,22 @@ class Indicator : public IndicatorData { case TYPE_BOOL: case TYPE_CHAR: case TYPE_INT: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_LONG: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_UINT: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_ULONG: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_DOUBLE: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_FLOAT: - _entry.values[_mode] = GetValue(_mode, _ishift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_STRING: case TYPE_UCHAR: @@ -637,12 +647,12 @@ class Indicator : public IndicatorData { if (_LastError != ERR_SUCCESS) { datetime _bar_dt = (datetime)_bar_time; - Print("Error: Code ", _LastError, " while trying to retrieve entry at shift ", _ishift, ", mode ", _mode, - ", time ", _bar_dt); + Print("Error: Code ", _LastError, " while trying to retrieve entry at shift ", _rel_shift, " (absolute ", + ToAbsShift(_rel_shift), "), mode ", _mode, ", time ", _bar_dt); DebugBreak(); } } - GetEntryAlter(_entry, _ishift); + GetEntryAlter(_entry, _rel_shift); _entry.SetFlag(INDI_ENTRY_FLAG_IS_VALID, IsValidEntry(_entry)); if (_entry.IsValid()) { idata.Add(_entry, _bar_time); @@ -665,7 +675,7 @@ class Indicator : public IndicatorData { * This method allows user to modify the struct entry before it's added to cache. * This method is called on GetEntry() right after values are set. */ - virtual void GetEntryAlter(IndicatorDataEntry& _entry, int _shift) { + virtual void GetEntryAlter(IndicatorDataEntry& _entry, int _rel_shift) { ENUM_DATATYPE _dtype = Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_DTYPE)); _entry.AddFlags(_entry.GetDataTypeFlags(_dtype)); }; @@ -678,9 +688,8 @@ class Indicator : public IndicatorData { * @return * Returns DataParamEntry struct filled with a single value. */ - IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) override { - int _ishift = _shift + iparams.GetShift(); - return GetEntry(_ishift)[_mode]; + IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) override { + return GetEntry(ToRelShift(_abs_shift))[_mode]; } /* Virtual methods */ diff --git a/Indicator/IndicatorCandle.h b/Indicator/IndicatorCandle.h index 78c603869..202635575 100644 --- a/Indicator/IndicatorCandle.h +++ b/Indicator/IndicatorCandle.h @@ -149,12 +149,12 @@ class IndicatorCandle : public Indicator { int GetBarIndex() override { return history.GetCurrentIndex(); } /** - * Returns the number of bars on the chart. + * Returns the number of bars on the chart decremented by iparams.shift. */ int GetBars() override { // Will return number of bars prepended and appended to the history, // even if those bars were cleaned up because of history's candle limit. - return (int)history.GetPeakSize(); + return (int)history.GetPeakSize() - iparams.shift; } /** @@ -182,7 +182,7 @@ class IndicatorCandle : public Indicator { /** * Returns time of the bar for a given shift. */ - virtual datetime GetBarTime(int _shift = 0) { return history.GetItemTimeByShift(_shift); } + virtual datetime GetBarTime(int _rel_shift = 0) { return history.GetItemTimeByShift(_rel_shift); } /** * Traverses source indicators' hierarchy and tries to find OHLC-featured @@ -196,11 +196,11 @@ class IndicatorCandle : public Indicator { /** * Gets OHLC price values. */ - BarOHLC GetOHLC(int _shift = 0) override { + BarOHLC GetOHLC(int _rel_shift = 0) override { BarOHLC _bar; CandleOCTOHLC _candle; - if (history.TryGetItemByShift(_shift, _candle)) { + if (history.TryGetItemByShift(ToAbsShift(_rel_shift), _candle)) { _bar = BarOHLC(_candle.open, _candle.high, _candle.low, _candle.close, _candle.start_time); } diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index 5d5842183..a97045afa 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -155,17 +155,17 @@ class IndicatorData : public IndicatorBase { /** * Access indicator entry data using [] operator via shift. */ - IndicatorDataEntry operator[](int _index) { + IndicatorDataEntry operator[](int _rel_shift) { if (!bool(flags | INDI_FLAG_INDEXABLE_BY_SHIFT)) { Print(GetFullName(), " is not indexable by shift!"); DebugBreak(); IndicatorDataEntry _default; return _default; } - return GetEntry(_index); + return GetEntry(_rel_shift); } - IndicatorDataEntry operator[](ENUM_INDICATOR_INDEX _index) { return GetEntry((int)_index); } + IndicatorDataEntry operator[](ENUM_INDICATOR_INDEX _rel_shift) { return GetEntry((int)_rel_shift); } /* Getters */ @@ -188,8 +188,8 @@ class IndicatorData : public IndicatorBase { /** * Gets an indicator property flag. */ - bool GetFlag(INDICATOR_ENTRY_FLAGS _prop, int _shift = 0) { - IndicatorDataEntry _entry = GetEntry(_shift); + bool GetFlag(INDICATOR_ENTRY_FLAGS _prop, int _rel_shift = 0) { + IndicatorDataEntry _entry = GetEntry(_rel_shift); return _entry.CheckFlag(_prop); } @@ -1013,9 +1013,9 @@ class IndicatorData : public IndicatorBase { } template - T GetValue(int _mode = 0, int _index = 0) { + T GetValue(int _mode = 0, int _rel_shift = 0) { T _out; - GetEntryValue(_mode, _index).Get(_out); + GetEntryValue(_mode, ToAbsShift(_rel_shift)).Get(_out); return _out; } @@ -1108,7 +1108,7 @@ class IndicatorData : public IndicatorBase { virtual double GetBid(int _shift = 0) { return GetTick() PTR_DEREF GetBid(_shift); } /** - * Returns the number of bars on the chart. + * Returns the number of bars on the chart decremented by iparams.shift. */ virtual int GetBars() { return GetCandle() PTR_DEREF GetBars(); } @@ -1120,7 +1120,7 @@ class IndicatorData : public IndicatorBase { /** * Returns time of the bar for a given shift. */ - virtual datetime GetBarTime(int _shift = 0) { + virtual datetime GetBarTime(int _rel_shift = 0) { IndicatorData* _indi = GetCandle(false); if (_indi == nullptr) _indi = GetTick(false); @@ -1132,10 +1132,10 @@ class IndicatorData : public IndicatorBase { } #ifdef __debug_items_history__ - Print("Getting bar time for shift ", _shift, " for ", GetFullName()); + Print("Getting bar time for shift ", _rel_shift, " for ", GetFullName()); #endif - return _indi PTR_DEREF GetBarTime(_shift); + return _indi PTR_DEREF GetBarTime(_rel_shift); } /** @@ -1186,7 +1186,7 @@ class IndicatorData : public IndicatorBase { /** * Returns the indicator's struct value via index. */ - virtual IndicatorDataEntry GetEntry(int _index = 0) = NULL; + virtual IndicatorDataEntry GetEntry(int _rel_shift = 0) = NULL; /** * Returns the indicator's struct value via timestamp. @@ -1211,7 +1211,7 @@ class IndicatorData : public IndicatorBase { /** * Returns the indicator's entry value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) = NULL; + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) = NULL; /** * Returns the shift of the maximum value over a specific number of periods depending on type. @@ -1257,7 +1257,7 @@ class IndicatorData : public IndicatorBase { /** * Gets OHLC price values. */ - virtual BarOHLC GetOHLC(int _shift = 0) { return GetCandle() PTR_DEREF GetOHLC(_shift); } + virtual BarOHLC GetOHLC(int _rel_shift = 0) { return GetCandle() PTR_DEREF GetOHLC(_rel_shift); } /** * Get peak price at given number of bars. @@ -1271,8 +1271,8 @@ class IndicatorData : public IndicatorBase { /** * Returns the current price value given applied price type, symbol and timeframe. */ - virtual double GetPrice(ENUM_APPLIED_PRICE _ap, int _shift = 0) { - return GetCandle() PTR_DEREF GetPrice(_ap, _shift); + virtual double GetPrice(ENUM_APPLIED_PRICE _ap, int _rel_shift = 0) { + return GetCandle() PTR_DEREF GetPrice(_ap, _rel_shift); } /** @@ -1871,6 +1871,16 @@ class IndicatorData : public IndicatorBase { return false; }; + /** + * Converts relative shift into absolute one. + */ + virtual int ToAbsShift(int _rel_shift) = 0; + + /** + * Converts absolute shift into relative one. + */ + virtual int ToRelShift(int _abs_shift) = 0; + /** * Loads and validates built-in indicators whose can be used as data source. */ diff --git a/Indicator/IndicatorRenko.h b/Indicator/IndicatorRenko.h index ef21c5e20..df4a403da 100644 --- a/Indicator/IndicatorRenko.h +++ b/Indicator/IndicatorRenko.h @@ -274,8 +274,8 @@ class IndicatorRenko : public IndicatorCandle { /** * Returns time of the bar for a given shift. */ - datetime GetBarTime(int _shift = 0) override { return history.GetItemTimeByShift(_shift); } + datetime GetBarTime(int _rel_shift = 0) override { return history.GetItemTimeByShift(_rel_shift); } /** * Gets ask price for a given date and time. Return current ask price if _dt wasn't passed or is 0. @@ -194,12 +194,10 @@ class IndicatorTick : public Indicator { * @return * Returns DataParamEntry struct filled with a single value. */ - IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) override { - int _ishift = _shift + iparams.GetShift(); - + IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) override { TickTAB _tick; - if (history.TryGetItemByShift(_ishift, _tick)) { + if (history.TryGetItemByShift(_abs_shift, _tick)) { switch (_mode) { case INDI_TICK_MODE_PRICE_ASK: return _tick.ask; diff --git a/Indicators/Bitwise/Indi_Candle.mqh b/Indicators/Bitwise/Indi_Candle.mqh index 95707754e..949ab5d3c 100644 --- a/Indicators/Bitwise/Indi_Candle.mqh +++ b/Indicators/Bitwise/Indi_Candle.mqh @@ -91,15 +91,14 @@ class Indi_Candle : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); BarOHLC _ohlcs[1]; switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: // In this mode, price is fetched from IndicatorCandle. - _ohlcs[0] = GetCandle() PTR_DEREF GetOHLC(_ishift); + _ohlcs[0] = GetCandle() PTR_DEREF GetOHLC(ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: // In this mode, price is fetched from given indicator. Such indicator @@ -118,10 +117,10 @@ class Indi_Candle : public Indicator { break; } - _ohlcs[0].open = GetDataSource().GetValue(PRICE_OPEN, _ishift); - _ohlcs[0].high = GetDataSource().GetValue(PRICE_HIGH, _ishift); - _ohlcs[0].low = GetDataSource().GetValue(PRICE_LOW, _ishift); - _ohlcs[0].close = GetDataSource().GetValue(PRICE_CLOSE, _ishift); + _ohlcs[0].open = GetDataSource().GetValue(PRICE_OPEN, ToRelShift(_abs_shift)); + _ohlcs[0].high = GetDataSource().GetValue(PRICE_HIGH, ToRelShift(_abs_shift)); + _ohlcs[0].low = GetDataSource().GetValue(PRICE_LOW, ToRelShift(_abs_shift)); + _ohlcs[0].close = GetDataSource().GetValue(PRICE_CLOSE, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 948c6aff2..a1c4740e0 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -84,12 +84,11 @@ class Indi_Pattern : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { int i; - int _ishift = _shift + iparams.GetShift(); int _max_modes = Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES)); - INDI_REQUIRE_SHIFT_OR_RETURN(GetCandle(), _max_modes + _ishift, WRONG_VALUE); + INDI_REQUIRE_SHIFT_OR_RETURN(GetCandle(), ToRelShift(_abs_shift) + _max_modes, WRONG_VALUE); BarOHLC _ohlcs[8]; @@ -97,7 +96,7 @@ class Indi_Pattern : public Indicator { case IDATA_BUILTIN: // In this mode, price is fetched from candle. for (i = 0; i < _max_modes; ++i) { - _ohlcs[i] = GetCandle() PTR_DEREF GetOHLC(_ishift + i); + _ohlcs[i] = GetCandle() PTR_DEREF GetOHLC(ToRelShift(_abs_shift) + i); if (!_ohlcs[i].IsValid()) { // Return empty entry on invalid candles. return WRONG_VALUE; @@ -122,10 +121,10 @@ class Indi_Pattern : public Indicator { } for (i = 0; i < _max_modes; ++i) { - _ohlcs[i].open = GetDataSource().GetValue(PRICE_OPEN, _ishift + i); - _ohlcs[i].high = GetDataSource().GetValue(PRICE_HIGH, _ishift + i); - _ohlcs[i].low = GetDataSource().GetValue(PRICE_LOW, _ishift + i); - _ohlcs[i].close = GetDataSource().GetValue(PRICE_CLOSE, _ishift + i); + _ohlcs[i].open = GetDataSource().GetValue(PRICE_OPEN, ToRelShift(_abs_shift) + i); + _ohlcs[i].high = GetDataSource().GetValue(PRICE_HIGH, ToRelShift(_abs_shift) + i); + _ohlcs[i].low = GetDataSource().GetValue(PRICE_LOW, ToRelShift(_abs_shift) + i); + _ohlcs[i].close = GetDataSource().GetValue(PRICE_CLOSE, ToRelShift(_abs_shift) + i); if (!_ohlcs[i].IsValid()) { // Return empty entry on invalid candles. return WRONG_VALUE; @@ -143,9 +142,9 @@ class Indi_Pattern : public Indicator { /** * Alters indicator's struct value. */ - void GetEntryAlter(IndicatorDataEntry& _entry, int _shift) override { + void GetEntryAlter(IndicatorDataEntry& _entry, int _rel_shift) override { _entry.SetFlag(INDI_ENTRY_FLAG_IS_BITWISE, true); - Indicator::GetEntryAlter(_entry, _shift); + Indicator::GetEntryAlter(_entry, _rel_shift); } /** diff --git a/Indicators/Indi_AC.mqh b/Indicators/Indi_AC.mqh index 74ad06e2c..d51e1e7b2 100644 --- a/Indicators/Indi_AC.mqh +++ b/Indicators/Indi_AC.mqh @@ -108,15 +108,15 @@ class Indi_AC : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) override { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) override { IndicatorDataEntryValue _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_AC::iAC(GetSymbol(), GetTf(), _ishift, THIS_PTR); + _value = Indi_AC::iAC(GetSymbol(), GetTf(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_AD.mqh b/Indicators/Indi_AD.mqh index 8fb4cf664..de2dcc19c 100644 --- a/Indicators/Indi_AD.mqh +++ b/Indicators/Indi_AD.mqh @@ -96,15 +96,15 @@ class Indi_AD : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_AD::iAD(GetSymbol(), GetTf(), _ishift, THIS_PTR); + _value = Indi_AD::iAD(GetSymbol(), GetTf(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ADX.mqh b/Indicators/Indi_ADX.mqh index d171e4f95..4719f9835 100644 --- a/Indicators/Indi_ADX.mqh +++ b/Indicators/Indi_ADX.mqh @@ -116,16 +116,16 @@ class Indi_ADX : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_ADX::iADX(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _mode, _ishift, THIS_PTR); + _value = Indi_ADX::iADX(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift), + THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ADXW.mqh b/Indicators/Indi_ADXW.mqh index 8fc6a9494..af81fe622 100644 --- a/Indicators/Indi_ADXW.mqh +++ b/Indicators/Indi_ADXW.mqh @@ -266,22 +266,21 @@ class Indi_ADXW : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_ADXW::iADXWilder(GetSymbol(), GetTf(), GetPeriod(), _mode, _ishift, THIS_PTR); + _value = Indi_ADXW::iADXWilder(GetSymbol(), GetTf(), GetPeriod(), _mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = Indi_ADXW::iADXWilder(THIS_PTR, GetPeriod(), _mode, _ishift); + _value = Indi_ADXW::iADXWilder(THIS_PTR, GetPeriod(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_ADXW::iADXWilder(THIS_PTR, GetPeriod(), _mode, _ishift); + _value = Indi_ADXW::iADXWilder(THIS_PTR, GetPeriod(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_AMA.mqh b/Indicators/Indi_AMA.mqh index 30c7e6150..9161002e7 100644 --- a/Indicators/Indi_AMA.mqh +++ b/Indicators/Indi_AMA.mqh @@ -229,26 +229,25 @@ class Indi_AMA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_AMA::iAMA(GetSymbol(), GetTf(), /*[*/ GetPeriod(), GetFastPeriod(), GetSlowPeriod(), - GetAMAShift(), GetAppliedPrice() /*]*/, _mode, _ishift, THIS_PTR); + GetAMAShift(), GetAppliedPrice() /*]*/, _mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - GetFastPeriod(), GetSlowPeriod(), GetAMAShift() /*]*/, _mode, _ishift); + GetFastPeriod(), GetSlowPeriod(), GetAMAShift() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_ONCALCULATE: _value = Indi_AMA::iAMAOnIndicator(THIS_PTR, /*[*/ GetPeriod(), GetFastPeriod(), GetSlowPeriod(), GetAMAShift(), - GetAppliedPrice() /*]*/, _mode, _ishift); + GetAppliedPrice() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_AMA::iAMAOnIndicator(THIS_PTR, /*[*/ GetPeriod(), GetFastPeriod(), GetSlowPeriod(), GetAMAShift(), - GetAppliedPrice() /*]*/, _mode, _ishift); + GetAppliedPrice() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_AO.mqh b/Indicators/Indi_AO.mqh index 74c755b45..eeb9c4661 100644 --- a/Indicators/Indi_AO.mqh +++ b/Indicators/Indi_AO.mqh @@ -107,15 +107,15 @@ class Indi_AO : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_AO::iAO(GetSymbol(), GetTf(), _ishift, _mode, THIS_PTR); + _value = Indi_AO::iAO(GetSymbol(), GetTf(), ToRelShift(_abs_shift), _mode, THIS_PTR); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ASI.mqh b/Indicators/Indi_ASI.mqh index 160686eff..53e4617e9 100644 --- a/Indicators/Indi_ASI.mqh +++ b/Indicators/Indi_ASI.mqh @@ -206,20 +206,19 @@ class Indi_ASI : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), - /*[*/ GetMaximumPriceChanging() /*]*/, 0, _ishift); + /*[*/ GetMaximumPriceChanging() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_ONCALCULATE: - _value = Indi_ASI::iASI(THIS_PTR, GetMaximumPriceChanging(), _mode, _ishift); + _value = Indi_ASI::iASI(THIS_PTR, GetMaximumPriceChanging(), _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_ASI::iASI(THIS_PTR, GetMaximumPriceChanging(), _mode, _ishift); + _value = Indi_ASI::iASI(THIS_PTR, GetMaximumPriceChanging(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ATR.mqh b/Indicators/Indi_ATR.mqh index ca40c4661..9f94ab076 100644 --- a/Indicators/Indi_ATR.mqh +++ b/Indicators/Indi_ATR.mqh @@ -90,15 +90,15 @@ class Indi_ATR : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), _ishift, THIS_PTR); + _value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Alligator.mqh b/Indicators/Indi_Alligator.mqh index 446035319..d1834add6 100644 --- a/Indicators/Indi_Alligator.mqh +++ b/Indicators/Indi_Alligator.mqh @@ -152,9 +152,8 @@ class Indi_Alligator : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); #ifdef __MQL4__ if (_mode == 0) { // In MQL4 mode 0 should be treated as mode 1 as Alligator buffers starts from index 1. @@ -163,9 +162,10 @@ class Indi_Alligator : public Indicator { #endif switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_Alligator::iAlligator(GetSymbol(), GetTf(), GetJawPeriod(), GetJawShift(), GetTeethPeriod(), - GetTeethShift(), GetLipsPeriod(), GetLipsShift(), GetMAMethod(), - GetAppliedPrice(), (ENUM_ALLIGATOR_LINE)_mode, _ishift, THIS_PTR); + _value = + Indi_Alligator::iAlligator(GetSymbol(), GetTf(), GetJawPeriod(), GetJawShift(), GetTeethPeriod(), + GetTeethShift(), GetLipsPeriod(), GetLipsShift(), GetMAMethod(), + GetAppliedPrice(), (ENUM_ALLIGATOR_LINE)_mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ @@ -173,7 +173,7 @@ class Indi_Alligator : public Indicator { GetLipsShift(), GetMAMethod(), GetAppliedPrice() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_AppliedPrice.mqh b/Indicators/Indi_AppliedPrice.mqh index fa910dc8b..0132b481f 100644 --- a/Indicators/Indi_AppliedPrice.mqh +++ b/Indicators/Indi_AppliedPrice.mqh @@ -87,13 +87,13 @@ class Indi_AppliedPrice : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_INDICATOR: if (HasDataSource()) { - _value = Indi_AppliedPrice::iAppliedPriceOnIndicator(GetDataSource(), GetAppliedPrice(), _ishift); + _value = + Indi_AppliedPrice::iAppliedPriceOnIndicator(GetDataSource(), GetAppliedPrice(), ToRelShift(_abs_shift)); } break; default: diff --git a/Indicators/Indi_BWMFI.mqh b/Indicators/Indi_BWMFI.mqh index f7e8f52c1..d9df71a79 100644 --- a/Indicators/Indi_BWMFI.mqh +++ b/Indicators/Indi_BWMFI.mqh @@ -117,17 +117,16 @@ class Indi_BWMFI : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = BWMFI_BUFFER, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = BWMFI_BUFFER, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_BWMFI::iBWMFI(GetSymbol(), GetTf(), _ishift, (ENUM_BWMFI_BUFFER)_mode, THIS_PTR); + _value = Indi_BWMFI::iBWMFI(GetSymbol(), GetTf(), ToRelShift(_abs_shift), (ENUM_BWMFI_BUFFER)_mode, THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ VOLUME_TICK /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_BWZT.mqh b/Indicators/Indi_BWZT.mqh index d05f05624..c709bf10b 100644 --- a/Indicators/Indi_BWZT.mqh +++ b/Indicators/Indi_BWZT.mqh @@ -251,19 +251,19 @@ class Indi_BWZT : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = Indi_BWZT::iBWZT(THIS_PTR, _mode, _ishift); + _value = Indi_BWZT::iBWZT(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_BWZT::iBWZT(THIS_PTR, _mode, _ishift); + _value = Indi_BWZT::iBWZT(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Bands.mqh b/Indicators/Indi_Bands.mqh index 090574ef6..f22163aa7 100644 --- a/Indicators/Indi_Bands.mqh +++ b/Indicators/Indi_Bands.mqh @@ -255,28 +255,27 @@ class Indi_Bands : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = BAND_BASE, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = BAND_BASE, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_Bands::iBands(GetSymbol(), GetTf(), GetPeriod(), GetDeviation(), GetBandsShift(), - GetAppliedPrice(), (ENUM_BANDS_LINE)_mode, _ishift, THIS_PTR); + GetAppliedPrice(), (ENUM_BANDS_LINE)_mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = - Indi_Bands::iBandsOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), GetDeviation(), - GetBandsShift(), GetAppliedPrice(), (ENUM_BANDS_LINE)_mode, _ishift); + _value = Indi_Bands::iBandsOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), + GetDeviation(), GetBandsShift(), GetAppliedPrice(), + (ENUM_BANDS_LINE)_mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ GetPeriod(), - GetBandsShift(), GetDeviation(), GetAppliedPrice() /* ] */, _mode, _ishift); + GetBandsShift(), GetDeviation(), GetAppliedPrice() /* ] */, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: // Calculating bands value from specified indicator. _value = Indi_Bands::iBandsOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), GetDeviation(), GetBandsShift(), GetAppliedPrice(), - (ENUM_BANDS_LINE)_mode, _ishift, THIS_PTR); + (ENUM_BANDS_LINE)_mode, ToRelShift(_abs_shift), THIS_PTR); break; } return _value; diff --git a/Indicators/Indi_BearsPower.mqh b/Indicators/Indi_BearsPower.mqh index 27efa2cae..aab484fac 100644 --- a/Indicators/Indi_BearsPower.mqh +++ b/Indicators/Indi_BearsPower.mqh @@ -91,16 +91,16 @@ class Indi_BearsPower : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = _value = iBearsPower(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _ishift, THIS_PTR); + _value = _value = + iBearsPower(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_BullsPower.mqh b/Indicators/Indi_BullsPower.mqh index 50db9e96f..bb9bf2d6f 100644 --- a/Indicators/Indi_BullsPower.mqh +++ b/Indicators/Indi_BullsPower.mqh @@ -91,16 +91,15 @@ class Indi_BullsPower : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = iBullsPower(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _ishift, THIS_PTR); + _value = iBullsPower(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /**/ GetPeriod() /**/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index 5734716a7..93065d544 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -166,30 +166,29 @@ class Indi_CCI : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: // @fixit Somehow shift isn't used neither in MT4 nor MT5. - _value = Indi_CCI::iCCI(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _ishift /* + iparams.shift*/, - THIS_PTR); + _value = Indi_CCI::iCCI(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), + ToRelShift(_abs_shift) /* + iparams.shift*/, THIS_PTR); break; case IDATA_ONCALCULATE: // @fixit Somehow shift isn't used neither in MT4 nor MT5. - _value = - Indi_CCI::iCCIOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), _ishift /* + iparams.shift*/); + _value = Indi_CCI::iCCIOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), + ToRelShift(_abs_shift) /* + iparams.shift*/); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ GetPeriod(), - GetAppliedPrice() /* ] */, 0, _ishift); + GetAppliedPrice() /* ] */, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: ValidateSelectedDataSource(); // @fixit Somehow shift isn't used neither in MT4 nor MT5. - _value = - Indi_CCI::iCCIOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), _ishift /* + iparams.shift*/); + _value = Indi_CCI::iCCIOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), + ToRelShift(_abs_shift) /* + iparams.shift*/); break; } return _value; diff --git a/Indicators/Indi_CHO.mqh b/Indicators/Indi_CHO.mqh index 5f0452621..b15c4bdff 100644 --- a/Indicators/Indi_CHO.mqh +++ b/Indicators/Indi_CHO.mqh @@ -198,22 +198,21 @@ class Indi_CHO : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: _value = Indi_CHO::iChaikin(GetSymbol(), GetTf(), /*[*/ GetSlowMA(), GetFastMA(), GetSmoothMethod(), - GetInputVolume() /*]*/, _mode, _ishift, THIS_PTR); + GetInputVolume() /*]*/, _mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetFastMA(), - GetSlowMA(), GetSmoothMethod(), GetInputVolume() /*]*/, 0, _ishift); + GetSlowMA(), GetSmoothMethod(), GetInputVolume() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_CHO::iChaikinOnIndicator(GetDataSource(), /*[*/ GetFastMA(), GetSlowMA(), GetSmoothMethod(), - GetInputVolume() /*]*/, _mode, _ishift); + GetInputVolume() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_CHV.mqh b/Indicators/Indi_CHV.mqh index 6cbbd7228..8a38c6d79 100644 --- a/Indicators/Indi_CHV.mqh +++ b/Indicators/Indi_CHV.mqh @@ -189,20 +189,19 @@ class Indi_CHV : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iCHV(THIS_PTR, GetSmoothPeriod(), GetCHVPeriod(), GetSmoothMethod(), _mode, _ishift); + _value = iCHV(THIS_PTR, GetSmoothPeriod(), GetCHVPeriod(), GetSmoothMethod(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetSmoothPeriod(), - GetCHVPeriod(), GetSmoothMethod() /*]*/, _mode, _ishift); + GetCHVPeriod(), GetSmoothMethod() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iCHV(THIS_PTR, GetSmoothPeriod(), GetCHVPeriod(), GetSmoothMethod(), _mode, _ishift); + _value = iCHV(THIS_PTR, GetSmoothPeriod(), GetCHVPeriod(), GetSmoothMethod(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ColorBars.mqh b/Indicators/Indi_ColorBars.mqh index df7682591..3465ca8bf 100644 --- a/Indicators/Indi_ColorBars.mqh +++ b/Indicators/Indi_ColorBars.mqh @@ -125,19 +125,19 @@ class Indi_ColorBars : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = Indi_ColorBars::iColorBars(THIS_PTR, _mode, _ishift); + _value = Indi_ColorBars::iColorBars(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_ColorBars::iColorBars(THIS_PTR, _mode, _ishift); + _value = Indi_ColorBars::iColorBars(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ColorCandlesDaily.mqh b/Indicators/Indi_ColorCandlesDaily.mqh index 21fbae9c2..9751e4a8e 100644 --- a/Indicators/Indi_ColorCandlesDaily.mqh +++ b/Indicators/Indi_ColorCandlesDaily.mqh @@ -135,19 +135,19 @@ class Indi_ColorCandlesDaily : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = Indi_ColorCandlesDaily::iCCD(THIS_PTR, _mode, _ishift); + _value = Indi_ColorCandlesDaily::iCCD(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_ColorCandlesDaily::iCCD(THIS_PTR, _mode, _ishift); + _value = Indi_ColorCandlesDaily::iCCD(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ColorLine.mqh b/Indicators/Indi_ColorLine.mqh index 8359515bc..f52044f8b 100644 --- a/Indicators/Indi_ColorLine.mqh +++ b/Indicators/Indi_ColorLine.mqh @@ -218,19 +218,19 @@ class Indi_ColorLine : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iColorLine(THIS_PTR, _mode, _ishift); + _value = iColorLine(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iColorLine(THIS_PTR, _mode, _ishift); + _value = iColorLine(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_CustomMovingAverage.mqh b/Indicators/Indi_CustomMovingAverage.mqh index afd5b677a..3dd961f02 100644 --- a/Indicators/Indi_CustomMovingAverage.mqh +++ b/Indicators/Indi_CustomMovingAverage.mqh @@ -79,13 +79,12 @@ class Indi_CustomMovingAverage : public Indicator /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetSmoothPeriod(), - GetSmoothShift(), GetSmoothMethod() /*]*/, 0, _ishift); + GetSmoothShift(), GetSmoothMethod() /*]*/, 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_DEMA.mqh b/Indicators/Indi_DEMA.mqh index 69facb42d..2f2f33632 100644 --- a/Indicators/Indi_DEMA.mqh +++ b/Indicators/Indi_DEMA.mqh @@ -180,29 +180,28 @@ class Indi_DEMA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: // We're getting DEMA from Price indicator. _value = Indi_DEMA::iDEMA(GetSymbol(), GetTf(), /*[*/ GetPeriod(), GetMAShift(), GetAppliedPrice() /*]*/, - _ishift, _mode, THIS_PTR); + ToRelShift(_abs_shift), _mode, THIS_PTR); break; case IDATA_ONCALCULATE: _value = Indi_DEMA::iDEMAOnIndicator(GetDataSource(), /*[*/ GetPeriod(), GetMAShift(), GetAppliedPrice() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /*[*/ GetPeriod(), GetMAShift(), - GetAppliedPrice() /*]*/, _mode, _ishift); + GetAppliedPrice() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: // Calculating DEMA value from specified indicator. _value = Indi_DEMA::iDEMAOnIndicator(GetDataSource(), /*[*/ GetPeriod(), GetMAShift(), GetAppliedPrice() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; } return _value; diff --git a/Indicators/Indi_DeMarker.mqh b/Indicators/Indi_DeMarker.mqh index c0cfb11b8..690909d80 100644 --- a/Indicators/Indi_DeMarker.mqh +++ b/Indicators/Indi_DeMarker.mqh @@ -88,16 +88,15 @@ class Indi_DeMarker : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = _value = Indi_DeMarker::iDeMarker(GetSymbol(), GetTf(), GetPeriod(), _ishift, THIS_PTR); + _value = _value = Indi_DeMarker::iDeMarker(GetSymbol(), GetTf(), GetPeriod(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Demo.mqh b/Indicators/Indi_Demo.mqh index 0544a56f3..d4bf22c37 100644 --- a/Indicators/Indi_Demo.mqh +++ b/Indicators/Indi_Demo.mqh @@ -79,11 +79,10 @@ class Indi_Demo : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); - double _value = Indi_Demo::iDemo(THIS_PTR, _ishift); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { + double _value = Indi_Demo::iDemo(THIS_PTR, ToRelShift(_abs_shift)); if (idparams.is_draw) { - draw.DrawLineTo(GetName(), GetCandle() PTR_DEREF GetBarTime(_ishift), _value); + draw.DrawLineTo(GetName(), GetCandle() PTR_DEREF GetBarTime(ToRelShift(_abs_shift)), _value); } return _value; } diff --git a/Indicators/Indi_DetrendedPrice.mqh b/Indicators/Indi_DetrendedPrice.mqh index 0fa35cd23..4a9bcf17d 100644 --- a/Indicators/Indi_DetrendedPrice.mqh +++ b/Indicators/Indi_DetrendedPrice.mqh @@ -136,20 +136,19 @@ class Indi_DetrendedPrice : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iDPO(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = iDPO(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iDPO(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = iDPO(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index 81c0ac92a..d12dc6368 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -194,15 +194,15 @@ class Indi_Drawer : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_Drawer::iDrawer(GetSymbol(), GetTf(), _ishift, THIS_PTR); + _value = Indi_Drawer::iDrawer(GetSymbol(), GetTf(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_INDICATOR: - _value = Indi_Drawer::iDrawerOnIndicator(GetDataSource(), THIS_PTR, GetSymbol(), GetTf(), _ishift); + _value = + Indi_Drawer::iDrawerOnIndicator(GetDataSource(), THIS_PTR, GetSymbol(), GetTf(), ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Envelopes.mqh b/Indicators/Indi_Envelopes.mqh index 902f3478c..7fc7ffd19 100644 --- a/Indicators/Indi_Envelopes.mqh +++ b/Indicators/Indi_Envelopes.mqh @@ -204,28 +204,28 @@ class Indi_Envelopes : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_Envelopes::iEnvelopes(GetSymbol(), GetTf(), GetMAPeriod(), GetMAMethod(), GetMAShift(), - GetAppliedPrice(), GetDeviation(), _mode, _ishift, THIS_PTR); + GetAppliedPrice(), GetDeviation(), _mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: // @todo Is cache needed here? _value = Indi_Envelopes::iEnvelopesOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetMAPeriod(), GetMAMethod(), GetAppliedPrice(), GetMAShift(), GetDeviation(), - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /**/ GetMAPeriod(), - GetMAMethod(), GetMAShift(), GetAppliedPrice(), GetDeviation() /**/, _mode, _ishift); + _value = + iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /**/ GetMAPeriod(), + GetMAMethod(), GetMAShift(), GetAppliedPrice(), GetDeviation() /**/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_Envelopes::iEnvelopesOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetMAPeriod(), GetMAMethod(), GetAppliedPrice(), GetMAShift(), GetDeviation(), - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index c74c90071..a60b03669 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -105,17 +105,16 @@ class Indi_Force : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = - Indi_Force::iForce(GetSymbol(), GetTf(), GetPeriod(), GetMAMethod(), GetAppliedPrice(), _ishift, THIS_PTR); + _value = Indi_Force::iForce(GetSymbol(), GetTf(), GetPeriod(), GetMAMethod(), GetAppliedPrice(), + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - GetMAMethod(), GetAppliedPrice(), VOLUME_TICK /*]*/, 0, _ishift); + GetMAMethod(), GetAppliedPrice(), VOLUME_TICK /*]*/, 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_FractalAdaptiveMA.mqh b/Indicators/Indi_FractalAdaptiveMA.mqh index a7d7d6d2e..ca3595020 100644 --- a/Indicators/Indi_FractalAdaptiveMA.mqh +++ b/Indicators/Indi_FractalAdaptiveMA.mqh @@ -177,23 +177,24 @@ class Indi_FrAMA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = - iFrAMA(GetSymbol(), GetTf(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, _ishift, THIS_PTR); + _value = iFrAMA(GetSymbol(), GetTf(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = iFrAMAOnIndicator(GetDataSource(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, _ishift); + _value = iFrAMAOnIndicator(GetDataSource(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - GetFRAMAShift() /*]*/, 0, _ishift); + GetFRAMAShift() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iFrAMAOnIndicator(GetDataSource(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, _ishift); + _value = iFrAMAOnIndicator(GetDataSource(), GetPeriod(), GetFRAMAShift(), GetAppliedPrice(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Fractals.mqh b/Indicators/Indi_Fractals.mqh index afb24f0b2..6e920d173 100644 --- a/Indicators/Indi_Fractals.mqh +++ b/Indicators/Indi_Fractals.mqh @@ -104,15 +104,16 @@ class Indi_Fractals : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_Fractals::iFractals(GetSymbol(), GetTf(), (ENUM_LO_UP_LINE)_mode, _ishift, THIS_PTR); + _value = + Indi_Fractals::iFractals(GetSymbol(), GetTf(), (ENUM_LO_UP_LINE)_mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Gator.mqh b/Indicators/Indi_Gator.mqh index 380377b1c..cbec2fac4 100644 --- a/Indicators/Indi_Gator.mqh +++ b/Indicators/Indi_Gator.mqh @@ -175,14 +175,13 @@ class Indi_Gator : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_Gator::iGator(GetSymbol(), GetTf(), GetJawPeriod(), GetJawShift(), GetTeethPeriod(), GetTeethShift(), GetLipsPeriod(), GetLipsShift(), GetMAMethod(), GetAppliedPrice(), - (ENUM_GATOR_HISTOGRAM)_mode, _ishift, THIS_PTR); + (ENUM_GATOR_HISTOGRAM)_mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /**/ @@ -190,7 +189,7 @@ class Indi_Gator : public Indicator { GetLipsShift(), GetMAMethod(), GetAppliedPrice() /**/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_HeikenAshi.mqh b/Indicators/Indi_HeikenAshi.mqh index 4c1b5ee3a..6727150e7 100644 --- a/Indicators/Indi_HeikenAshi.mqh +++ b/Indicators/Indi_HeikenAshi.mqh @@ -215,9 +215,8 @@ class Indi_HeikenAshi : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = HA_OPEN, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = HA_OPEN, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: @@ -238,17 +237,18 @@ class Indi_HeikenAshi : public Indicator { break; } #endif - _value = Indi_HeikenAshi::iHeikenAshi(THIS_PTR, _mode, _ishift); + _value = Indi_HeikenAshi::iHeikenAshi(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM_LEGACY: _value = Indi_HeikenAshi::iCustomLegacyHeikenAshi(GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, - _ishift, THIS_PTR); + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_INDICATOR: - _value = Indi_HeikenAshi::iHeikenAshi(THIS_PTR, _mode, _ishift); + _value = Indi_HeikenAshi::iHeikenAshi(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Ichimoku.mqh b/Indicators/Indi_Ichimoku.mqh index 02a009ca9..42878ac52 100644 --- a/Indicators/Indi_Ichimoku.mqh +++ b/Indicators/Indi_Ichimoku.mqh @@ -144,17 +144,16 @@ class Indi_Ichimoku : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_Ichimoku::iIchimoku(GetSymbol(), GetTf(), GetTenkanSen(), GetKijunSen(), GetSenkouSpanB(), _mode, - _ishift, THIS_PTR); + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetTenkanSen(), - GetKijunSen(), GetSenkouSpanB() /*]*/, _mode, _ishift); + GetKijunSen(), GetSenkouSpanB() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Killzones.mqh b/Indicators/Indi_Killzones.mqh index 4712a66f8..eb71c61e1 100644 --- a/Indicators/Indi_Killzones.mqh +++ b/Indicators/Indi_Killzones.mqh @@ -131,10 +131,9 @@ class Indi_Killzones : public Indicator { /** * Returns the indicator's value. */ - IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { float _value = FLT_MAX; int _index = (int)_mode / 2; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: // Builtin mode not supported. @@ -144,8 +143,8 @@ class Indi_Killzones : public Indicator { ikt.Set(::TimeGMT()); if (ikt.CheckHours(_index)) { // Pass values to check for new highs or lows. - ikt.Update(_mode % 2 == 0 ? (float)GetCandle() PTR_DEREF GetHigh(_ishift) - : (float)GetCandle() PTR_DEREF GetLow(_ishift), + ikt.Update(_mode % 2 == 0 ? (float)GetCandle() PTR_DEREF GetHigh(ToRelShift(_abs_shift)) + : (float)GetCandle() PTR_DEREF GetLow(ToRelShift(_abs_shift)), _index); } // Set a final value. diff --git a/Indicators/Indi_MA.mqh b/Indicators/Indi_MA.mqh index 7102f3fa8..2258d5966 100644 --- a/Indicators/Indi_MA.mqh +++ b/Indicators/Indi_MA.mqh @@ -633,26 +633,25 @@ class Indi_MA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_MA::iMA(GetSymbol(), GetTf(), GetPeriod(), GetMAShift(), GetMAMethod(), GetAppliedPrice(), - _ishift, THIS_PTR); + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: _value = Indi_MA::iMAOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), GetMAShift(), - GetMAMethod(), GetAppliedPrice(), _ishift); + GetMAMethod(), GetAppliedPrice(), ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ GetPeriod(), - GetMAShift(), GetMAMethod(), GetAppliedPrice() /* ] */, 0, _ishift); + GetMAShift(), GetMAMethod(), GetAppliedPrice() /* ] */, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: // Calculating MA value from specified indicator. _value = Indi_MA::iMAOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), GetMAShift(), - GetMAMethod(), GetAppliedPrice(), _ishift); + GetMAMethod(), GetAppliedPrice(), ToRelShift(_abs_shift)); break; } diff --git a/Indicators/Indi_MACD.mqh b/Indicators/Indi_MACD.mqh index 98f3cbf4f..f2b74ebd6 100644 --- a/Indicators/Indi_MACD.mqh +++ b/Indicators/Indi_MACD.mqh @@ -105,18 +105,17 @@ class Indi_MACD : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_MACD::iMACD(GetSymbol(), GetTf(), GetEmaFastPeriod(), GetEmaSlowPeriod(), GetSignalPeriod(), - GetAppliedPrice(), (ENUM_SIGNAL_LINE)_mode, _ishift, THIS_PTR); + GetAppliedPrice(), (ENUM_SIGNAL_LINE)_mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetEmaFastPeriod(), - GetEmaSlowPeriod(), GetSignalPeriod(), GetAppliedPrice() /*]*/, _mode, _ishift); + GetEmaSlowPeriod(), GetSignalPeriod(), GetAppliedPrice() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_MFI.mqh b/Indicators/Indi_MFI.mqh index 3f21ef6d6..37ff09cdc 100644 --- a/Indicators/Indi_MFI.mqh +++ b/Indicators/Indi_MFI.mqh @@ -99,20 +99,20 @@ class Indi_MFI : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: #ifdef __MQL4__ _value = Indi_MFI::iMFI(GetSymbol(), GetTf(), GetPeriod(), _ishift); #else // __MQL5__ - _value = Indi_MFI::iMFI(GetSymbol(), GetTf(), GetPeriod(), GetAppliedVolume(), _ishift, THIS_PTR); + _value = + Indi_MFI::iMFI(GetSymbol(), GetTf(), GetPeriod(), GetAppliedVolume(), ToRelShift(_abs_shift), THIS_PTR); #endif break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - VOLUME_TICK /*]*/, 0, _ishift); + VOLUME_TICK /*]*/, 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_MassIndex.mqh b/Indicators/Indi_MassIndex.mqh index 3d15a2629..fe9aa452c 100644 --- a/Indicators/Indi_MassIndex.mqh +++ b/Indicators/Indi_MassIndex.mqh @@ -176,20 +176,21 @@ class Indi_MassIndex : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = Indi_MassIndex::iMI(THIS_PTR, GetPeriod(), GetSecondPeriod(), GetSumPeriod(), _mode, _ishift); + _value = Indi_MassIndex::iMI(THIS_PTR, GetPeriod(), GetSecondPeriod(), GetSumPeriod(), _mode, + ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - GetSecondPeriod(), GetSumPeriod() /*]*/, _mode, _ishift); + GetSecondPeriod(), GetSumPeriod() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_MassIndex::iMI(THIS_PTR, GetPeriod(), GetSecondPeriod(), GetSumPeriod(), _mode, _ishift); + _value = Indi_MassIndex::iMI(THIS_PTR, GetPeriod(), GetSecondPeriod(), GetSumPeriod(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index 5646d34c0..122c15e37 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -138,35 +138,34 @@ class Indi_Momentum : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: // @fixit Somehow shift isn't used neither in MT4 nor MT5. - _value = Indi_Momentum::iMomentum(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), iparams.shift + _ishift, - THIS_PTR); + _value = Indi_Momentum::iMomentum(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), + iparams.shift + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: // @fixit Somehow shift isn't used neither in MT4 nor MT5. _value = Indi_Momentum::iMomentumOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), - iparams.shift + _shift); + iparams.shift + ToRelShift(_abs_shift)); if (idparams.is_draw) { - draw.DrawLineTo(StringFormat("%s", GetName()), GetBarTime(iparams.shift + _shift), _value, 1); + draw.DrawLineTo(StringFormat("%s", GetName()), GetBarTime(iparams.shift + ToRelShift(_abs_shift)), _value, 1); } break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: ValidateSelectedDataSource(); // @fixit Somehow shift isn't used neither in MT4 nor MT5. _value = Indi_Momentum::iMomentumOnIndicator(GetDataSource(), GetSymbol(), GetTf(), GetPeriod(), - iparams.shift + _shift); + iparams.shift + ToRelShift(_abs_shift)); if (idparams.is_draw) { - draw.DrawLineTo(StringFormat("%s", GetName()), GetBarTime(iparams.shift + _shift), _value, 1); + draw.DrawLineTo(StringFormat("%s", GetName()), GetBarTime(iparams.shift + ToRelShift(_abs_shift)), _value, 1); } break; } diff --git a/Indicators/Indi_OBV.mqh b/Indicators/Indi_OBV.mqh index 7156fa2ad..2740f9245 100644 --- a/Indicators/Indi_OBV.mqh +++ b/Indicators/Indi_OBV.mqh @@ -114,20 +114,19 @@ class Indi_OBV : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: #ifdef __MQL4__ _value = Indi_OBV::iOBV(GetSymbol(), GetTf(), GetAppliedPrice(), _ishift); #else // __MQL5__ - _value = Indi_OBV::iOBV(GetSymbol(), GetTf(), GetAppliedVolume(), _ishift, THIS_PTR); + _value = Indi_OBV::iOBV(GetSymbol(), GetTf(), GetAppliedVolume(), ToRelShift(_abs_shift), THIS_PTR); #endif break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ VOLUME_TICK /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_OsMA.mqh b/Indicators/Indi_OsMA.mqh index bd72bb5da..86017ceeb 100644 --- a/Indicators/Indi_OsMA.mqh +++ b/Indicators/Indi_OsMA.mqh @@ -99,18 +99,17 @@ class Indi_OsMA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_OsMA::iOsMA(GetSymbol(), GetTf(), GetEmaFastPeriod(), GetEmaSlowPeriod(), GetSignalPeriod(), - GetAppliedPrice(), _ishift, THIS_PTR); + GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetEmaFastPeriod(), - GetEmaSlowPeriod(), GetSignalPeriod(), GetAppliedPrice() /*]*/, 0, _ishift); + GetEmaSlowPeriod(), GetSignalPeriod(), GetAppliedPrice() /*]*/, 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Pivot.mqh b/Indicators/Indi_Pivot.mqh index 94adc5634..5a767296d 100644 --- a/Indicators/Indi_Pivot.mqh +++ b/Indicators/Indi_Pivot.mqh @@ -99,14 +99,13 @@ class Indi_Pivot : public Indicator { * @return * Returns IndicatorDataEntry struct filled with indicator values. */ - virtual IndicatorDataEntry GetEntry(int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); - long _bar_time = GetCandle() PTR_DEREF GetBarTime(_ishift); + virtual IndicatorDataEntry GetEntry(int _rel_shift = 0) { + long _bar_time = GetCandle() PTR_DEREF GetBarTime(_rel_shift); IndicatorDataEntry _entry = idata.GetByKey(_bar_time); if (_bar_time > 0 && !_entry.IsValid() && !_entry.CheckFlag(INDI_ENTRY_FLAG_INSUFFICIENT_DATA)) { ResetLastError(); - BarOHLC _ohlc = GetOHLC(_ishift); - _entry.timestamp = GetCandle() PTR_DEREF GetBarTime(_ishift); + BarOHLC _ohlc = GetOHLC(_rel_shift); + _entry.timestamp = GetCandle() PTR_DEREF GetBarTime(_rel_shift); if (_ohlc.IsValid()) { _entry.Resize(Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES))); _ohlc.GetPivots(GetMethod(), _entry.values[0].value.vdbl, _entry.values[1].value.vdbl, @@ -117,7 +116,7 @@ class Indi_Pivot : public Indicator { _entry.values[i].SetDataType(TYPE_DOUBLE); } } - GetEntryAlter(_entry, _shift); + GetEntryAlter(_entry, _rel_shift); _entry.SetFlag(INDI_ENTRY_FLAG_IS_VALID, IsValidEntry(_entry)); if (_entry.IsValid()) { idata.Add(_entry, _bar_time); @@ -137,9 +136,8 @@ class Indi_Pivot : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); - return GetEntry(_ishift)[_mode]; + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { + return GetEntry(ToRelShift(_abs_shift))[_mode]; } /* Getters */ diff --git a/Indicators/Indi_PriceChannel.mqh b/Indicators/Indi_PriceChannel.mqh index d0a3582aa..759efadb9 100644 --- a/Indicators/Indi_PriceChannel.mqh +++ b/Indicators/Indi_PriceChannel.mqh @@ -126,20 +126,19 @@ class Indi_PriceChannel : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iPriceChannel(THIS_PTR, GetPeriod(), _mode, _ishift); + _value = iPriceChannel(THIS_PTR, GetPeriod(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iPriceChannel(THIS_PTR, GetPeriod(), _mode, _ishift); + _value = iPriceChannel(THIS_PTR, GetPeriod(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_PriceFeeder.mqh b/Indicators/Indi_PriceFeeder.mqh index ce6970486..cbe8b7213 100644 --- a/Indicators/Indi_PriceFeeder.mqh +++ b/Indicators/Indi_PriceFeeder.mqh @@ -88,13 +88,12 @@ class Indi_PriceFeeder : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { int data_size = ArraySize(iparams.price_data); - int _ishift = _shift + iparams.GetShift(); - if (_ishift >= data_size || _ishift < 0) return DBL_MIN; + if (_abs_shift >= data_size || _abs_shift < 0) return DBL_MIN; - double _value = iparams.price_data[data_size - _ishift - 1]; + double _value = iparams.price_data[data_size - _abs_shift - 1]; return _value; } diff --git a/Indicators/Indi_PriceVolumeTrend.mqh b/Indicators/Indi_PriceVolumeTrend.mqh index 28b131513..6f51e2e4b 100644 --- a/Indicators/Indi_PriceVolumeTrend.mqh +++ b/Indicators/Indi_PriceVolumeTrend.mqh @@ -140,20 +140,19 @@ class Indi_PriceVolumeTrend : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iPVT(THIS_PTR, GetAppliedVolume(), _mode, _ishift); + _value = iPVT(THIS_PTR, GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), - /*[*/ GetAppliedVolume() /*]*/, 0, _ishift); + /*[*/ GetAppliedVolume() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iPVT(THIS_PTR, GetAppliedVolume(), _mode, _ishift); + _value = iPVT(THIS_PTR, GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_RS.mqh b/Indicators/Indi_RS.mqh index a45448fcb..975e336ac 100644 --- a/Indicators/Indi_RS.mqh +++ b/Indicators/Indi_RS.mqh @@ -104,8 +104,7 @@ class Indi_RS : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_MATH: // Updating Maths' data sources to be the same as RS data source. diff --git a/Indicators/Indi_RSI.mqh b/Indicators/Indi_RSI.mqh index b63cac3e6..aa522f958 100644 --- a/Indicators/Indi_RSI.mqh +++ b/Indicators/Indi_RSI.mqh @@ -309,25 +309,24 @@ class Indi_RSI : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; double _res[]; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = - Indi_RSI::iRSI(GetSymbol(), GetTf(), iparams.GetPeriod(), iparams.GetAppliedPrice(), _ishift, THIS_PTR); + _value = Indi_RSI::iRSI(GetSymbol(), GetTf(), iparams.GetPeriod(), iparams.GetAppliedPrice(), + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: // @todo Modify iRSIOnIndicator() to operate on single IndicatorData pointer. break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ iparams.GetPeriod(), - iparams.GetAppliedPrice() /* ] */, 0, _ishift); + iparams.GetAppliedPrice() /* ] */, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_RSI::iRSIOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), iparams.GetPeriod(), - iparams.GetAppliedPrice(), _ishift); + iparams.GetAppliedPrice(), ToRelShift(_abs_shift)); break; } return _value; diff --git a/Indicators/Indi_RVI.mqh b/Indicators/Indi_RVI.mqh index ca4da8681..2c70f66fd 100644 --- a/Indicators/Indi_RVI.mqh +++ b/Indicators/Indi_RVI.mqh @@ -94,16 +94,16 @@ class Indi_RVI : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_RVI::iRVI(GetSymbol(), GetTf(), GetPeriod(), (ENUM_SIGNAL_LINE)_mode, _ishift, THIS_PTR); + _value = Indi_RVI::iRVI(GetSymbol(), GetTf(), GetPeriod(), (ENUM_SIGNAL_LINE)_mode, ToRelShift(_abs_shift), + THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - _mode, _ishift); + _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_RateOfChange.mqh b/Indicators/Indi_RateOfChange.mqh index 3eac51e1f..14929f1a8 100644 --- a/Indicators/Indi_RateOfChange.mqh +++ b/Indicators/Indi_RateOfChange.mqh @@ -126,20 +126,19 @@ class Indi_RateOfChange : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iROC(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = iROC(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iROC(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = iROC(THIS_PTR, GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_SAR.mqh b/Indicators/Indi_SAR.mqh index b1200e193..9c4be3413 100644 --- a/Indicators/Indi_SAR.mqh +++ b/Indicators/Indi_SAR.mqh @@ -90,16 +90,15 @@ class Indi_SAR : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_SAR::iSAR(GetSymbol(), GetTf(), GetStep(), GetMax(), _ishift, THIS_PTR); + _value = Indi_SAR::iSAR(GetSymbol(), GetTf(), GetStep(), GetMax(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetStep(), - GetMax() /*]*/, _mode, _ishift); + GetMax() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 375499ae2..e04142519 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -226,25 +226,24 @@ class Indi_StdDev : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_StdDev::iStdDev(GetSymbol(), GetTf(), GetMAPeriod(), GetMAShift(), GetMAMethod(), - GetAppliedPrice(), _ishift, THIS_PTR); + GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: _value = Indi_StdDev::iStdDevOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetMAPeriod(), - GetMAShift(), GetAppliedPrice(), _ishift, THIS_PTR); + GetMAShift(), GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetMAPeriod(), - GetMAShift(), GetMAMethod() /*]*/, 0, _ishift); + GetMAShift(), GetMAMethod() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_StdDev::iStdDevOnIndicator(THIS_PTR, GetDataSource(), GetSymbol(), GetTf(), GetMAPeriod(), - GetMAShift(), GetAppliedPrice(), _ishift, THIS_PTR); + GetMAShift(), GetAppliedPrice(), ToRelShift(_abs_shift), THIS_PTR); break; } return _value; diff --git a/Indicators/Indi_Stochastic.mqh b/Indicators/Indi_Stochastic.mqh index 25eeb7686..1ca6a0ea9 100644 --- a/Indicators/Indi_Stochastic.mqh +++ b/Indicators/Indi_Stochastic.mqh @@ -110,17 +110,16 @@ class Indi_Stochastic : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_Stochastic::iStochastic(GetSymbol(), GetTf(), GetKPeriod(), GetDPeriod(), GetSlowing(), - GetMAMethod(), GetPriceField(), _mode, _ishift, THIS_PTR); + GetMAMethod(), GetPriceField(), _mode, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetKPeriod(), - GetDPeriod(), GetSlowing() /*]*/, _mode, _ishift); + GetDPeriod(), GetSlowing() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_TEMA.mqh b/Indicators/Indi_TEMA.mqh index 6b89d2cba..0fbc8fdec 100644 --- a/Indicators/Indi_TEMA.mqh +++ b/Indicators/Indi_TEMA.mqh @@ -154,22 +154,23 @@ class Indi_TEMA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_TEMA::iTEMA(GetSymbol(), GetTf(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), 0, _ishift, - THIS_PTR); + _value = Indi_TEMA::iTEMA(GetSymbol(), GetTf(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), 0, + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = iTEMAOnIndicator(GetDataSource(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), _mode, _ishift); + _value = iTEMAOnIndicator(GetDataSource(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), _mode, + ToRelShift(_abs_shift)); case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(), - GetTEMAShift() /*]*/, 0, _ishift); + GetTEMAShift() /*]*/, 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iTEMAOnIndicator(GetDataSource(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), _mode, _ishift); + _value = iTEMAOnIndicator(GetDataSource(), GetPeriod(), GetTEMAShift(), GetAppliedPrice(), _mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_TRIX.mqh b/Indicators/Indi_TRIX.mqh index ac08b6b1d..e5ccd25e2 100644 --- a/Indicators/Indi_TRIX.mqh +++ b/Indicators/Indi_TRIX.mqh @@ -154,23 +154,24 @@ class Indi_TRIX : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_TRIX::iTriX(GetSymbol(), GetTf(), /*[*/ GetPeriod(), GetAppliedPrice() /*]*/, _mode, _ishift, - THIS_PTR); + _value = Indi_TRIX::iTriX(GetSymbol(), GetTf(), /*[*/ GetPeriod(), GetAppliedPrice() /*]*/, _mode, + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = Indi_TRIX::iTriXOnIndicator(GetDataSource(), GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = + Indi_TRIX::iTriXOnIndicator(GetDataSource(), GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_TRIX::iTriXOnIndicator(GetDataSource(), GetPeriod(), GetAppliedPrice(), _mode, _ishift); + _value = + Indi_TRIX::iTriXOnIndicator(GetDataSource(), GetPeriod(), GetAppliedPrice(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_UltimateOscillator.mqh b/Indicators/Indi_UltimateOscillator.mqh index d00c0526a..cbf4a091b 100644 --- a/Indicators/Indi_UltimateOscillator.mqh +++ b/Indicators/Indi_UltimateOscillator.mqh @@ -249,25 +249,24 @@ class Indi_UltimateOscillator : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: _value = Indi_UltimateOscillator::iUO(THIS_PTR, GetFastPeriod(), GetMiddlePeriod(), GetSlowPeriod(), GetFastK(), - GetMiddleK(), GetSlowK(), _mode, _ishift); + GetMiddleK(), GetSlowK(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetFastPeriod(), GetMiddlePeriod(), GetSlowPeriod(), GetFastK(), GetMiddleK(), GetSlowK() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: _value = Indi_UltimateOscillator::iUO(THIS_PTR, GetFastPeriod(), GetMiddlePeriod(), GetSlowPeriod(), GetFastK(), - GetMiddleK(), GetSlowK(), _mode, _ishift); + GetMiddleK(), GetSlowK(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_VIDYA.mqh b/Indicators/Indi_VIDYA.mqh index 037e25c0a..e93fa1eae 100644 --- a/Indicators/Indi_VIDYA.mqh +++ b/Indicators/Indi_VIDYA.mqh @@ -177,30 +177,29 @@ class Indi_VIDYA : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: _value = Indi_VIDYA::iVIDyA(GetSymbol(), GetTf(), /*[*/ GetCMOPeriod(), GetMAPeriod(), GetVIDYAShift(), - GetAppliedPrice() /*]*/, 0, _ishift, THIS_PTR); + GetAppliedPrice() /*]*/, 0, ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ONCALCULATE: - _value = - Indi_VIDYA::iVIDyAOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetCMOPeriod(), GetMAPeriod(), - GetVIDYAShift(), GetAppliedPrice() /*]*/, _mode, _ishift, THIS_PTR); + _value = Indi_VIDYA::iVIDyAOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetCMOPeriod(), + GetMAPeriod(), GetVIDYAShift(), GetAppliedPrice() /*]*/, _mode, + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetCMOPeriod(), GetMAPeriod(), GetVIDYAShift() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = - Indi_VIDYA::iVIDyAOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetCMOPeriod(), GetMAPeriod(), - GetVIDYAShift(), GetAppliedPrice() /*]*/, _mode, _ishift, THIS_PTR); + _value = Indi_VIDYA::iVIDyAOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetCMOPeriod(), + GetMAPeriod(), GetVIDYAShift(), GetAppliedPrice() /*]*/, _mode, + ToRelShift(_abs_shift), THIS_PTR); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_VROC.mqh b/Indicators/Indi_VROC.mqh index 3854a7051..48d436b1d 100644 --- a/Indicators/Indi_VROC.mqh +++ b/Indicators/Indi_VROC.mqh @@ -153,20 +153,19 @@ class Indi_VROC : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iVROC(THIS_PTR, GetPeriod(), GetAppliedVolume(), _mode, _ishift); + _value = iVROC(THIS_PTR, GetPeriod(), GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), - /*[*/ GetPeriod(), GetAppliedVolume() /*]*/, _mode, _ishift); + /*[*/ GetPeriod(), GetAppliedVolume() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iVROC(THIS_PTR, GetPeriod(), GetAppliedVolume(), _mode, _ishift); + _value = iVROC(THIS_PTR, GetPeriod(), GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_Volumes.mqh b/Indicators/Indi_Volumes.mqh index feaf8a5c4..d5b607764 100644 --- a/Indicators/Indi_Volumes.mqh +++ b/Indicators/Indi_Volumes.mqh @@ -147,20 +147,19 @@ class Indi_Volumes : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = Indi_Volumes::iVolumes(THIS_PTR, GetAppliedVolume(), _mode, _ishift); + _value = Indi_Volumes::iVolumes(THIS_PTR, GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), - /*[*/ GetAppliedVolume() /*]*/, _mode, _ishift); + /*[*/ GetAppliedVolume() /*]*/, _mode, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = Indi_Volumes::iVolumes(THIS_PTR, GetAppliedVolume(), _mode, _ishift); + _value = Indi_Volumes::iVolumes(THIS_PTR, GetAppliedVolume(), _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_WPR.mqh b/Indicators/Indi_WPR.mqh index 3c978b23d..192b9d378 100644 --- a/Indicators/Indi_WPR.mqh +++ b/Indicators/Indi_WPR.mqh @@ -117,16 +117,15 @@ class Indi_WPR : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: - _value = Indi_WPR::iWPR(GetSymbol(), GetTf(), GetPeriod(), _ishift, THIS_PTR); + _value = Indi_WPR::iWPR(GetSymbol(), GetTf(), GetPeriod(), ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, - 0, _ishift); + 0, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_WilliamsAD.mqh b/Indicators/Indi_WilliamsAD.mqh index e2103a1ad..e8769d903 100644 --- a/Indicators/Indi_WilliamsAD.mqh +++ b/Indicators/Indi_WilliamsAD.mqh @@ -149,19 +149,19 @@ class Indi_WilliamsAD : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iWAD(THIS_PTR, _mode, _ishift); + _value = iWAD(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), 0, _ishift); + _value = + iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), 0, ToRelShift(_abs_shift)); break; case IDATA_INDICATOR: - _value = iWAD(THIS_PTR, _mode, _ishift); + _value = iWAD(THIS_PTR, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ZigZag.mqh b/Indicators/Indi_ZigZag.mqh index e2fadc062..35c46706d 100644 --- a/Indicators/Indi_ZigZag.mqh +++ b/Indicators/Indi_ZigZag.mqh @@ -373,21 +373,22 @@ class Indi_ZigZag : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: case IDATA_ONCALCULATE: - _value = iZigZag(THIS_PTR, GetDepth(), GetDeviation(), GetBackstep(), (ENUM_ZIGZAG_LINE)_mode, _ishift); + _value = iZigZag(THIS_PTR, GetDepth(), GetDeviation(), GetBackstep(), (ENUM_ZIGZAG_LINE)_mode, + ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: - _value = - Indi_ZigZag::iCustomZigZag(GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetDepth(), - GetDeviation(), GetBackstep() /*]*/, (ENUM_ZIGZAG_LINE)_mode, _ishift, THIS_PTR); + _value = Indi_ZigZag::iCustomZigZag(GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetDepth(), + GetDeviation(), GetBackstep() /*]*/, (ENUM_ZIGZAG_LINE)_mode, + ToRelShift(_abs_shift), THIS_PTR); break; case IDATA_INDICATOR: - _value = iZigZag(THIS_PTR, GetDepth(), GetDeviation(), GetBackstep(), (ENUM_ZIGZAG_LINE)_mode, _ishift); + _value = iZigZag(THIS_PTR, GetDepth(), GetDeviation(), GetBackstep(), (ENUM_ZIGZAG_LINE)_mode, + ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_ZigZagColor.mqh b/Indicators/Indi_ZigZagColor.mqh index 9bc8b1bb1..db25ae9c1 100644 --- a/Indicators/Indi_ZigZagColor.mqh +++ b/Indicators/Indi_ZigZagColor.mqh @@ -295,17 +295,16 @@ class Indi_ZigZagColor : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_ONCALCULATE: _value = Indi_ZigZagColor::iZigZagColor(THIS_PTR, GetDepth(), GetDeviation(), GetBackstep(), - (ENUM_ZIGZAG_LINE)_mode, _ishift); + (ENUM_ZIGZAG_LINE)_mode, ToRelShift(_abs_shift)); break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), - /*[*/ GetDepth(), GetDeviation(), GetBackstep() /*]*/, _mode, _ishift); + /*[*/ GetDepth(), GetDeviation(), GetBackstep() /*]*/, _mode, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/OHLC/Indi_OHLC.mqh b/Indicators/OHLC/Indi_OHLC.mqh index 411cae002..08ac367f2 100644 --- a/Indicators/OHLC/Indi_OHLC.mqh +++ b/Indicators/OHLC/Indi_OHLC.mqh @@ -89,8 +89,7 @@ class Indi_OHLC : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { ENUM_APPLIED_PRICE _ap = PRICE_OPEN; switch (_mode) { case INDI_OHLC_CLOSE: @@ -106,6 +105,6 @@ class Indi_OHLC : public Indicator { _ap = PRICE_LOW; break; } - return GetDataSource() PTR_DEREF GetPrice(_ap, _shift); + return GetDataSource() PTR_DEREF GetPrice(_ap, ToRelShift(_abs_shift)); } }; diff --git a/Indicators/Price/Indi_Price.mqh b/Indicators/Price/Indi_Price.mqh index c4f4e3a44..cac647fb6 100644 --- a/Indicators/Price/Indi_Price.mqh +++ b/Indicators/Price/Indi_Price.mqh @@ -73,10 +73,9 @@ class Indi_Price : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { - int _ishift = _shift + iparams.GetShift(); + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { return GetCandle() PTR_DEREF GetSpecificAppliedPriceValueStorage(iparams.GetAppliedPrice()) - PTR_DEREF Fetch(_ishift); + PTR_DEREF Fetch(ToRelShift(_abs_shift)); } /** diff --git a/Indicators/Special/Indi_Custom.mqh b/Indicators/Special/Indi_Custom.mqh index 332af4bdf..3d94d5ffa 100644 --- a/Indicators/Special/Indi_Custom.mqh +++ b/Indicators/Special/Indi_Custom.mqh @@ -98,23 +98,23 @@ class Indi_Custom : public Indicator { /** * Returns the indicator's value. */ - IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_ICUSTOM: switch (iparams.GetParamsSize()) { case 0: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, _mode, _ishift); + _value = + iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, _mode, ToRelShift(_abs_shift)); break; case 1: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, - iparams.GetParam(1).ToValue(), _mode, _ishift); + iparams.GetParam(1).ToValue(), _mode, ToRelShift(_abs_shift)); break; case 2: - _value = - iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, - iparams.GetParam(1).ToValue(), iparams.GetParam(2).ToValue(), _mode, _ishift); + _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, + iparams.GetParam(1).ToValue(), iparams.GetParam(2).ToValue(), _mode, + ToRelShift(_abs_shift)); break; } break; diff --git a/Indicators/Special/Indi_Math.mqh b/Indicators/Special/Indi_Math.mqh index c4084a06e..0c8ed1d63 100644 --- a/Indicators/Special/Indi_Math.mqh +++ b/Indicators/Special/Indi_Math.mqh @@ -114,9 +114,8 @@ class Indi_Math : public Indicator { /** * Returns the indicator's value. */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { double _value = EMPTY_VALUE; - int _ishift = _shift + iparams.GetShift(); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_INDICATOR: if (!indi_src.IsSet()) { @@ -134,12 +133,12 @@ class Indi_Math : public Indicator { case MATH_OP_MODE_BUILTIN: _value = Indi_Math::iMathOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetOpBuiltIn(), GetMode1(), GetMode2(), GetShift1(), - GetShift2() /*]*/, 0, _ishift, &this); + GetShift2() /*]*/, 0, ToRelShift(_abs_shift), &this); break; case MATH_OP_MODE_CUSTOM_FUNCTION: _value = Indi_Math::iMathOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetOpFunction(), GetMode1(), GetMode2(), GetShift1(), - GetShift2() /*]*/, 0, _ishift, &this); + GetShift2() /*]*/, 0, ToRelShift(_abs_shift), &this); break; } break; diff --git a/Storage/ValueStorage.applied_price.h b/Storage/ValueStorage.applied_price.h index 902dfa5ab..bb752a5b5 100644 --- a/Storage/ValueStorage.applied_price.h +++ b/Storage/ValueStorage.applied_price.h @@ -54,19 +54,20 @@ class AppliedPriceValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - double Fetch(int _shift) override { + double Fetch(int _rel_shift) override { switch (ap) { case PRICE_OPEN: case PRICE_HIGH: case PRICE_LOW: case PRICE_CLOSE: - return Fetch(ap, _shift); + return Fetch(ap, _rel_shift); case PRICE_MEDIAN: - return (Fetch(PRICE_HIGH, _shift) + Fetch(PRICE_LOW, _shift)) / 2; + return (Fetch(PRICE_HIGH, _rel_shift) + Fetch(PRICE_LOW, _rel_shift)) / 2; case PRICE_TYPICAL: - return (Fetch(PRICE_HIGH, _shift) + Fetch(PRICE_LOW, _shift) + Fetch(PRICE_CLOSE, _shift)) / 3; + return (Fetch(PRICE_HIGH, _rel_shift) + Fetch(PRICE_LOW, _rel_shift) + Fetch(PRICE_CLOSE, _rel_shift)) / 3; case PRICE_WEIGHTED: - return (Fetch(PRICE_HIGH, _shift) + Fetch(PRICE_LOW, _shift) + (2 * Fetch(PRICE_CLOSE, _shift))) / 4; + return (Fetch(PRICE_HIGH, _rel_shift) + Fetch(PRICE_LOW, _rel_shift) + (2 * Fetch(PRICE_CLOSE, _rel_shift))) / + 4; default: Print("We shouldn't be here!"); DebugBreak(); @@ -74,7 +75,9 @@ class AppliedPriceValueStorage : public HistoryValueStorage { return 0.0; } - double Fetch(ENUM_APPLIED_PRICE _ap, int _shift) { return indi_candle REF_DEREF GetPrice(_ap, RealShift(_shift)); } + double Fetch(ENUM_APPLIED_PRICE _ap, int _rel_shift) { + return indi_candle REF_DEREF GetPrice(_ap, RealShift(_rel_shift)); + } static double GetApplied(ValueStorage &_open, ValueStorage &_high, ValueStorage &_low, ValueStorage &_close, int _shift, ENUM_APPLIED_PRICE _ap) { diff --git a/Storage/ValueStorage.h b/Storage/ValueStorage.h index bbe358b36..1700bef52 100644 --- a/Storage/ValueStorage.h +++ b/Storage/ValueStorage.h @@ -153,7 +153,7 @@ class ValueStorage : public IValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - virtual C Fetch(int _shift) { + virtual C Fetch(int _rel_shift) { Alert("Fetching data by shift is not supported from this value storage!"); DebugBreak(); return (C)0; diff --git a/Storage/ValueStorage.history.h b/Storage/ValueStorage.history.h index 61c378964..ed11af3c9 100644 --- a/Storage/ValueStorage.history.h +++ b/Storage/ValueStorage.history.h @@ -84,6 +84,8 @@ class HistoryValueStorage : public ValueStorage { /** * Number of bars passed from the start. There will be a single bar at the start. + * + * Note that number of bars are decremented by iparams.shift of the candle indicator. */ int BarsFromStart() { if (!indi_candle.ObjectExists()) { diff --git a/Storage/ValueStorage.indicator.h b/Storage/ValueStorage.indicator.h index 7f8478955..88887f356 100644 --- a/Storage/ValueStorage.indicator.h +++ b/Storage/ValueStorage.indicator.h @@ -54,5 +54,5 @@ class IndicatorBufferValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - C Fetch(int _shift) override { return indi_candle REF_DEREF GetValue(mode, RealShift(_shift)); } + C Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetValue(mode, RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.native.h b/Storage/ValueStorage.native.h index 46ca12565..b034ca646 100644 --- a/Storage/ValueStorage.native.h +++ b/Storage/ValueStorage.native.h @@ -59,7 +59,7 @@ class NativeValueStorage : public ValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - C Fetch(int _shift) override { + C Fetch(int _rel_shift) override { if (_shift < 0 || _shift >= ArraySize(_values)) { return (C)EMPTY_VALUE; // Print("Invalid buffer data index: ", _shift, ". Buffer size: ", ArraySize(_values)); diff --git a/Storage/ValueStorage.price_median.h b/Storage/ValueStorage.price_median.h index 24b9c1a1a..3752af417 100644 --- a/Storage/ValueStorage.price_median.h +++ b/Storage/ValueStorage.price_median.h @@ -49,9 +49,9 @@ class PriceMedianValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - double Fetch(int _shift) override { + double Fetch(int _rel_shift) override { ResetLastError(); - double _value = indi_candle REF_DEREF GetOHLC(RealShift(_shift)).GetMedian(); + double _value = indi_candle REF_DEREF GetOHLC(RealShift(_rel_shift)).GetMedian(); if (_LastError != ERR_NO_ERROR) { Print("Cannot fetch OHLC! Error: ", _LastError); DebugBreak(); diff --git a/Storage/ValueStorage.price_typical.h b/Storage/ValueStorage.price_typical.h index 91337dc77..4bf51f786 100644 --- a/Storage/ValueStorage.price_typical.h +++ b/Storage/ValueStorage.price_typical.h @@ -46,9 +46,9 @@ class PriceTypicalValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - double Fetch(int _shift) override { + double Fetch(int _rel_shift) override { ResetLastError(); - double _value = indi_candle REF_DEREF GetOHLC(RealShift(_shift)).GetTypical(); + double _value = indi_candle REF_DEREF GetOHLC(RealShift(_rel_shift)).GetTypical(); if (_LastError != ERR_NO_ERROR) { Print("Cannot fetch OHLC! Error: ", _LastError); DebugBreak(); diff --git a/Storage/ValueStorage.price_weighted.h b/Storage/ValueStorage.price_weighted.h index 1fab60e08..17818583e 100644 --- a/Storage/ValueStorage.price_weighted.h +++ b/Storage/ValueStorage.price_weighted.h @@ -46,9 +46,9 @@ class PriceWeightedValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - double Fetch(int _shift) override { + double Fetch(int _rel_shift) override { ResetLastError(); - double _value = indi_candle REF_DEREF GetOHLC(RealShift(_shift)).GetWeighted(); + double _value = indi_candle REF_DEREF GetOHLC(RealShift(_rel_shift)).GetWeighted(); if (_LastError != ERR_NO_ERROR) { Print("Cannot fetch OHLC! Error: ", _LastError); DebugBreak(); diff --git a/Storage/ValueStorage.spread.h b/Storage/ValueStorage.spread.h index 3b4202e11..98e3689fc 100644 --- a/Storage/ValueStorage.spread.h +++ b/Storage/ValueStorage.spread.h @@ -47,5 +47,5 @@ class SpreadValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _shift) override { return indi_candle REF_DEREF GetSpread(RealShift(_shift)); } + long Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetSpread(RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.tick_volume.h b/Storage/ValueStorage.tick_volume.h index f94fb7435..cc6dd5ec6 100644 --- a/Storage/ValueStorage.tick_volume.h +++ b/Storage/ValueStorage.tick_volume.h @@ -46,5 +46,5 @@ class TickVolumeValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _shift) override { return indi_candle REF_DEREF GetVolume(RealShift(_shift)); } + long Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.time.h b/Storage/ValueStorage.time.h index 076a41de8..67461a958 100644 --- a/Storage/ValueStorage.time.h +++ b/Storage/ValueStorage.time.h @@ -47,5 +47,5 @@ class TimeValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - datetime Fetch(int _shift) override { return indi_candle REF_DEREF GetBarTime(RealShift(_shift)); } + datetime Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetBarTime(RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.volume.h b/Storage/ValueStorage.volume.h index 51ddd9cb2..68d5320ba 100644 --- a/Storage/ValueStorage.volume.h +++ b/Storage/ValueStorage.volume.h @@ -46,9 +46,9 @@ class VolumeValueStorage : public HistoryValueStorage { /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _shift) override { + long Fetch(int _rel_shift) override { ResetLastError(); - long _volume = indi_candle REF_DEREF GetVolume(RealShift(_shift)); + long _volume = indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); if (_LastError != ERR_NO_ERROR) { Print("Cannot fetch iVolume! Error: ", _LastError); DebugBreak();