From 1e59d35d6daa582ce8a181310b4a9f2a768256f5 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Fri, 29 Oct 2021 18:23:07 +0200 Subject: [PATCH] In the middle of Indicator::GetValue -> GetMixedValue refactoring. --- Indicator.struct.h | 248 +++++++++++++----------- Indicator.struct.serialize.h | 27 +-- IndicatorBase.h | 16 +- Indicators/Bitwise/Indi_Candle.mqh | 2 +- Indicators/Bitwise/Indi_Pattern.mqh | 2 +- Indicators/Indi_AC.mqh | 5 +- Indicators/Indi_AD.mqh | 3 +- Indicators/Indi_ADX.mqh | 2 +- Indicators/Indi_ADXW.mqh | 2 +- Indicators/Indi_AMA.mqh | 2 +- Indicators/Indi_AO.mqh | 2 +- Indicators/Indi_ASI.mqh | 2 +- Indicators/Indi_ATR.mqh | 2 +- Indicators/Indi_Alligator.mqh | 2 +- Indicators/Indi_AppliedPrice.mqh | 2 +- Indicators/Indi_BWMFI.mqh | 2 +- Indicators/Indi_BWZT.mqh | 2 +- Indicators/Indi_Bands.mqh | 2 +- Indicators/Indi_BearsPower.mqh | 2 +- Indicators/Indi_BullsPower.mqh | 2 +- Indicators/Indi_CCI.mqh | 2 +- Indicators/Indi_CHO.mqh | 2 +- Indicators/Indi_CHV.mqh | 2 +- Indicators/Indi_ColorBars.mqh | 2 +- Indicators/Indi_ColorCandlesDaily.mqh | 2 +- Indicators/Indi_ColorLine.mqh | 2 +- Indicators/Indi_CustomMovingAverage.mqh | 2 +- Indicators/Indi_DEMA.mqh | 2 +- Indicators/Indi_DeMarker.mqh | 2 +- Indicators/Indi_Demo.mqh | 2 +- Indicators/Indi_DetrendedPrice.mqh | 2 +- Indicators/Indi_Drawer.mqh | 2 +- Indicators/Indi_Envelopes.mqh | 2 +- Indicators/Indi_Force.mqh | 2 +- Indicators/Indi_FractalAdaptiveMA.mqh | 2 +- Indicators/Indi_Fractals.mqh | 2 +- Indicators/Indi_Gator.mqh | 2 +- Indicators/Indi_HeikenAshi.mqh | 2 +- Indicators/Indi_Ichimoku.mqh | 6 +- Indicators/Indi_MA.mqh | 2 +- Indicators/Indi_MACD.mqh | 2 +- Indicators/Indi_MFI.mqh | 2 +- Indicators/Indi_MassIndex.mqh | 2 +- Indicators/Indi_Momentum.mqh | 2 +- Indicators/Indi_OBV.mqh | 2 +- Indicators/Indi_OsMA.mqh | 2 +- Indicators/Indi_Pivot.mqh | 12 +- Indicators/Indi_PriceChannel.mqh | 2 +- Indicators/Indi_PriceFeeder.mqh | 2 +- Indicators/Indi_PriceVolumeTrend.mqh | 2 +- Indicators/Indi_RS.mqh | 7 +- Indicators/Indi_RSI.mqh | 6 +- Indicators/Indi_RVI.mqh | 2 +- Indicators/Indi_RateOfChange.mqh | 2 +- Indicators/Indi_SAR.mqh | 2 +- Indicators/Indi_StdDev.mqh | 2 +- Indicators/Indi_Stochastic.mqh | 2 +- Indicators/Indi_TEMA.mqh | 2 +- Indicators/Indi_TRIX.mqh | 2 +- Indicators/Indi_UltimateOscillator.mqh | 2 +- Indicators/Indi_VIDYA.mqh | 2 +- Indicators/Indi_VROC.mqh | 2 +- Indicators/Indi_Volumes.mqh | 2 +- Indicators/Indi_WPR.mqh | 2 +- Indicators/Indi_WilliamsAD.mqh | 2 +- Indicators/Indi_ZigZag.mqh | 2 +- Indicators/Indi_ZigZagColor.mqh | 2 +- Indicators/OHLC/Indi_OHLC.mqh | 2 +- Indicators/Price/Indi_Price.mqh | 2 +- Indicators/Special/Indi_Math.mqh | 2 +- tests/IndicatorsTest.mq5 | 10 +- 71 files changed, 250 insertions(+), 212 deletions(-) diff --git a/Indicator.struct.h b/Indicator.struct.h index 0ca53f0b9..e63f82c05 100644 --- a/Indicator.struct.h +++ b/Indicator.struct.h @@ -45,109 +45,147 @@ struct ChartParams; #include "SerializerNode.enum.h" #include "Storage/ValueStorage.indicator.h" +// Type-less value for IndicatorDataEntryValue structure. +union IndicatorDataEntryTypelessValue { + double vdbl; + float vflt; + int vint; + long vlong; +}; + +// Type-aware value for IndicatorDataEntry class. +struct IndicatorDataEntryValue { + unsigned char flags; + IndicatorDataEntryTypelessValue value; + + // Returns type of the value. + ENUM_DATATYPE GetDataType() { return (ENUM_DATATYPE)((flags & 0xF0) >> 4); } + + // Sets type of the value. + void SetDataType(ENUM_DATATYPE _type) { + // CLearing type. + flags &= 0x0F; + + // Setting type. + flags |= (unsigned char)_type << 4; + } + + // Union operators. + template + T operator*(const T _value) { + return Get() * _value; + } + template + T operator+(const T _value) { + return Get() + _value; + } + template + T operator-(const T _value) { + return Get() - _value; + } + template + T operator/(const T _value) { + return Get() / _value; + } + template + bool operator!=(const T _value) { + return Get() != _value; + } + template + bool operator<(const T _value) { + return Get() < _value; + } + template + bool operator<=(const T _value) { + return Get() <= _value; + } + template + bool operator==(const T _value) { + return Get() == _value; + } + template + bool operator>(const T _value) { + return Get() > _value; + } + template + bool operator>=(const T _value) { + return Get() >= _value; + } + template + void operator=(const T _value) { + Set(_value); + } + // Checkers. + template + bool IsGt(T _value) { + return Get() > _value; + } + template + bool IsLt(T _value) { + return Get() < _value; + } + // Getters. + double GetDbl() { return value.vdbl; } + float GetFloat() { return value.vflt; } + int GetInt() { return value.vint; } + long GetLong() { return value.vlong; } + template + void Get(T &_out) { + _out = Get(); + } + template + T Get() { + T _v; + Get(_v); + return _v; + } + void Get(double &_out) { _out = value.vdbl; } + void Get(float &_out) { _out = value.vflt; } + void Get(int &_out) { _out = value.vint; } + void Get(long &_out) { _out = value.vlong; } + // Setters. + template + void Set(T _value) { + Set(_value); + } + void Set(double _value) { + value.vdbl = _value; + SetDataType(TYPE_DOUBLE); + } + void Set(float _value) { + value.vflt = _value; + SetDataType(TYPE_FLOAT); + } + void Set(int _value) { + value.vint = _value; + SetDataType(TYPE_INT); + } + void Set(unsigned int _value) { + value.vint = (int)_value; + SetDataType(TYPE_UINT); + } + void Set(long _value) { + value.vlong = _value; + SetDataType(TYPE_LONG); + } + void Set(unsigned long _value) { + value.vlong = (long)_value; + SetDataType(TYPE_ULONG); + } + // Serializers. + // SERIALIZER_EMPTY_STUB + SerializerNodeType Serialize(Serializer &_s); + // To string + template + string ToString() { + return (string)Get(); + } +}; + /* Structure for indicator data entry. */ struct IndicatorDataEntry { long timestamp; // Timestamp of the entry's bar. unsigned short flags; // Indicator entry flags. - union IndicatorDataEntryValue { - double vdbl; - float vflt; - int vint; - long vlong; - // Union operators. - template - T operator*(const T _value) { - return Get() * _value; - } - template - T operator+(const T _value) { - return Get() + _value; - } - template - T operator-(const T _value) { - return Get() - _value; - } - template - T operator/(const T _value) { - return Get() / _value; - } - template - bool operator!=(const T _value) { - return Get() != _value; - } - template - bool operator<(const T _value) { - return Get() < _value; - } - template - bool operator<=(const T _value) { - return Get() <= _value; - } - template - bool operator==(const T _value) { - return Get() == _value; - } - template - bool operator>(const T _value) { - return Get() > _value; - } - template - bool operator>=(const T _value) { - return Get() >= _value; - } - template - void operator=(const T _value) { - Set(_value); - } - // Checkers. - template - bool IsGt(T _value) { - return Get() > _value; - } - template - bool IsLt(T _value) { - return Get() < _value; - } - // Getters. - double GetDbl() { return vdbl; } - float GetFloat() { return vflt; } - int GetInt() { return vint; } - long GetLong() { return vlong; } - template - void Get(T &_out) { - _out = Get(); - } - template - T Get() { - T _v; - Get(_v); - return _v; - } - void Get(double &_out) { _out = vdbl; } - void Get(float &_out) { _out = vflt; } - void Get(int &_out) { _out = vint; } - void Get(long &_out) { _out = vlong; } - // Setters. - template - void Set(T _value) { - Set(_value); - } - void Set(double _value) { vdbl = _value; } - void Set(float _value) { vflt = _value; } - void Set(int _value) { vint = _value; } - void Set(unsigned int _value) { vint = (int)_value; } - void Set(long _value) { vlong = _value; } - void Set(unsigned long _value) { vlong = (long)_value; } - // Serializers. - // SERIALIZER_EMPTY_STUB - SerializerNodeType Serialize(Serializer &_s); - // To string - template - string ToString() { - return (string)Get(); - } - }; - ARRAY(IndicatorDataEntryValue, values); // Constructors. @@ -288,17 +326,7 @@ struct IndicatorDataEntry { int GetMonth() { return DateTimeStatic::Month(timestamp); } int GetYear() { return DateTimeStatic::Year(timestamp); } long GetTime() { return timestamp; }; - ENUM_DATATYPE GetDataType() { - if (CheckFlags(INDI_ENTRY_FLAG_IS_REAL)) { - return CheckFlags(INDI_ENTRY_FLAG_IS_DOUBLED) ? TYPE_DOUBLE : TYPE_FLOAT; - } else { - if (CheckFlags(INDI_ENTRY_FLAG_IS_DOUBLED)) { - return CheckFlags(INDI_ENTRY_FLAG_IS_UNSIGNED) ? TYPE_ULONG : TYPE_LONG; - } else { - return CheckFlags(INDI_ENTRY_FLAG_IS_UNSIGNED) ? TYPE_UINT : TYPE_INT; - } - } - } + ENUM_DATATYPE GetDataType(int _mode) { return values[_mode].GetDataType(); } ushort GetDataTypeFlags(ENUM_DATATYPE _dt) { switch (_dt) { case TYPE_BOOL: diff --git a/Indicator.struct.serialize.h b/Indicator.struct.serialize.h index 18718e62b..98e262c60 100644 --- a/Indicator.struct.serialize.h +++ b/Indicator.struct.serialize.h @@ -40,23 +40,26 @@ SerializerNodeType IndicatorDataEntry::Serialize(Serializer &_s) { // this work? _s.Pass(THIS_REF, (string)i, GetEntry(i), SERIALIZER_FIELD_FLAG_DYNAMIC | // SERIALIZER_FIELD_FLAG_FEATURE); // Can this work? - switch (GetDataType()) { + switch (values[i].GetDataType()) { case TYPE_DOUBLE: - _s.Pass(THIS_REF, (string)i, values[i].vdbl, SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); + _s.Pass(THIS_REF, (string)i, values[i].value.vdbl, + SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); break; case TYPE_FLOAT: - _s.Pass(THIS_REF, (string)i, values[i].vflt, SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); + _s.Pass(THIS_REF, (string)i, values[i].value.vflt, + SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); break; case TYPE_INT: case TYPE_UINT: if (CheckFlags(INDI_ENTRY_FLAG_IS_BITWISE)) { // Split for each bit and pass 0 or 1. for (int j = 0; j < sizeof(int) * 8; ++j) { - int _value = (values[i].vint & (1 << j)) != 0; + int _value = (values[i].value.vint & (1 << j)) != 0; _s.Pass(THIS_REF, StringFormat("%d@%d", i, j), _value, SERIALIZER_FIELD_FLAG_FEATURE); } } else { - _s.Pass(THIS_REF, (string)i, values[i].vint, SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); + _s.Pass(THIS_REF, (string)i, values[i].value.vint, + SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); } break; case TYPE_LONG: @@ -71,7 +74,8 @@ SerializerNodeType IndicatorDataEntry::Serialize(Serializer &_s) { */ SetUserError(ERR_INVALID_PARAMETER); } else { - _s.Pass(THIS_REF, (string)i, values[i].vlong, SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); + _s.Pass(THIS_REF, (string)i, values[i].value.vlong, + SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); } break; default: @@ -83,11 +87,12 @@ SerializerNodeType IndicatorDataEntry::Serialize(Serializer &_s) { } /* Method to serialize IndicatorDataEntry's IndicatorDataEntryValue union. */ -SerializerNodeType IndicatorDataEntry::IndicatorDataEntryValue::Serialize(Serializer &_s) { - _s.Pass(THIS_REF, "vdbl", vdbl); - _s.Pass(THIS_REF, "vflt", vflt); - _s.Pass(THIS_REF, "vint", vint); - _s.Pass(THIS_REF, "vlong", vlong); +SerializerNodeType IndicatorDataEntryValue::Serialize(Serializer &_s) { + _s.Pass(THIS_REF, "flags", flags); + _s.Pass(THIS_REF, "vdbl", value.vdbl); + _s.Pass(THIS_REF, "vflt", value.vflt); + _s.Pass(THIS_REF, "vint", value.vint); + _s.Pass(THIS_REF, "vlong", value.vlong); return SerializerNodeObject; }; diff --git a/IndicatorBase.h b/IndicatorBase.h index 42df064ad..7e3477722 100644 --- a/IndicatorBase.h +++ b/IndicatorBase.h @@ -45,7 +45,6 @@ class Chart; #include "Indicator.struct.h" #include "Indicator.struct.serialize.h" #include "Indicator.struct.signal.h" -#include "Math.h" #include "Object.mqh" #include "Refs.mqh" #include "Serializer.mqh" @@ -835,18 +834,15 @@ class IndicatorBase : public Chart { return value_storages[_mode]; } - /** - * Returns indicator value for a given shift and mode. - */ template - T GetValue(int _shift = 0, int _mode = -1) { - T _result; - int _index = _mode != -1 ? _mode : GetDataSourceMode(); - GetEntry(_shift).values[_index].Get(_result); - ResetLastError(); - return _result; + T GetValue(int _shift = 0, int _mode = 0) { + T _out; + GetMixedValue(_shift, _mode).Get(_out); + return _out; } + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) = NULL; + /** * Returns price corresponding to indicator value for a given shift and mode. * diff --git a/Indicators/Bitwise/Indi_Candle.mqh b/Indicators/Bitwise/Indi_Candle.mqh index 4c5f9f086..8880970c3 100644 --- a/Indicators/Bitwise/Indi_Candle.mqh +++ b/Indicators/Bitwise/Indi_Candle.mqh @@ -66,7 +66,7 @@ class Indi_Candle : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; BarOHLC _ohlcs[1]; diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 6e89b0c53..8a1327df2 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -57,7 +57,7 @@ class Indi_Pattern : public Indicator { /** * Returns the indicator's value. */ - virtual uint GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { int i; BarOHLC _ohlcs[8]; diff --git a/Indicators/Indi_AC.mqh b/Indicators/Indi_AC.mqh index 2ce43dad3..8e6a2ca23 100644 --- a/Indicators/Indi_AC.mqh +++ b/Indicators/Indi_AC.mqh @@ -33,6 +33,7 @@ double iAC(string _symbol, int _tf, int _shift) { return Indi_AC::iAC(_symbol, ( struct IndiACParams : IndicatorParams { // Struct constructor. IndiACParams(int _shift = 0) : IndicatorParams(INDI_AC, 1, TYPE_DOUBLE) { + SetDataSourceType(IDATA_ICUSTOM); SetDataValueRange(IDATA_RANGE_MIXED); SetCustomIndicatorName("Examples\\Accelerator"); shift = _shift; @@ -97,8 +98,8 @@ class Indi_AC : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { - double _value = EMPTY_VALUE; + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { + IndicatorDataEntryValue _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle; diff --git a/Indicators/Indi_AD.mqh b/Indicators/Indi_AD.mqh index a4422f983..1e3e853c2 100644 --- a/Indicators/Indi_AD.mqh +++ b/Indicators/Indi_AD.mqh @@ -34,6 +34,7 @@ struct IndiADParams : IndicatorParams { IndiADParams(int _shift = 0) : IndicatorParams(INDI_AD, 1, TYPE_DOUBLE) { SetDataValueRange(IDATA_RANGE_MIXED); SetCustomIndicatorName("Examples\\AD"); + SetDataSourceType(IDATA_ICUSTOM); shift = _shift; }; IndiADParams(IndiADParams &_params, ENUM_TIMEFRAMES _tf) { @@ -96,7 +97,7 @@ class Indi_AD : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ADX.mqh b/Indicators/Indi_ADX.mqh index 41ba460dc..bc20fd824 100644 --- a/Indicators/Indi_ADX.mqh +++ b/Indicators/Indi_ADX.mqh @@ -114,7 +114,7 @@ class Indi_ADX : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ADXW.mqh b/Indicators/Indi_ADXW.mqh index 373cdf742..52873bf82 100644 --- a/Indicators/Indi_ADXW.mqh +++ b/Indicators/Indi_ADXW.mqh @@ -215,7 +215,7 @@ class Indi_ADXW : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN_ADX, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_AMA.mqh b/Indicators/Indi_AMA.mqh index dcd840b1b..d5d5e3137 100644 --- a/Indicators/Indi_AMA.mqh +++ b/Indicators/Indi_AMA.mqh @@ -199,7 +199,7 @@ class Indi_AMA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_AO.mqh b/Indicators/Indi_AO.mqh index 1dbe5927c..fb29de8af 100644 --- a/Indicators/Indi_AO.mqh +++ b/Indicators/Indi_AO.mqh @@ -100,7 +100,7 @@ class Indi_AO : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ASI.mqh b/Indicators/Indi_ASI.mqh index efc813c42..f018085b4 100644 --- a/Indicators/Indi_ASI.mqh +++ b/Indicators/Indi_ASI.mqh @@ -155,7 +155,7 @@ class Indi_ASI : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_ICUSTOM: diff --git a/Indicators/Indi_ATR.mqh b/Indicators/Indi_ATR.mqh index f3bfa57b1..0ccc99855 100644 --- a/Indicators/Indi_ATR.mqh +++ b/Indicators/Indi_ATR.mqh @@ -102,7 +102,7 @@ class Indi_ATR : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Alligator.mqh b/Indicators/Indi_Alligator.mqh index a44faa5ab..a8b8ea71c 100644 --- a/Indicators/Indi_Alligator.mqh +++ b/Indicators/Indi_Alligator.mqh @@ -161,7 +161,7 @@ class Indi_Alligator : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode, int _shift = 0) { #ifdef __MQL4__ if (_mode == 0) { // In MQL4 mode 0 should be treated as mode 1 as Alligator buffers starts from index 1. diff --git a/Indicators/Indi_AppliedPrice.mqh b/Indicators/Indi_AppliedPrice.mqh index 30514d924..f7bb5911c 100644 --- a/Indicators/Indi_AppliedPrice.mqh +++ b/Indicators/Indi_AppliedPrice.mqh @@ -72,7 +72,7 @@ class Indi_AppliedPrice : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_INDICATOR: diff --git a/Indicators/Indi_BWMFI.mqh b/Indicators/Indi_BWMFI.mqh index b0d91124f..58057f52e 100644 --- a/Indicators/Indi_BWMFI.mqh +++ b/Indicators/Indi_BWMFI.mqh @@ -111,7 +111,7 @@ class Indi_BWMFI : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = BWMFI_BUFFER, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = BWMFI_BUFFER, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_BWZT.mqh b/Indicators/Indi_BWZT.mqh index 9f5f0bd53..d2b932378 100644 --- a/Indicators/Indi_BWZT.mqh +++ b/Indicators/Indi_BWZT.mqh @@ -172,7 +172,7 @@ class Indi_BWZT : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Bands.mqh b/Indicators/Indi_Bands.mqh index ad80f2472..07623c77d 100644 --- a/Indicators/Indi_Bands.mqh +++ b/Indicators/Indi_Bands.mqh @@ -237,7 +237,7 @@ class Indi_Bands : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual double GetValue(int _mode = BAND_BASE, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = BAND_BASE, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_BearsPower.mqh b/Indicators/Indi_BearsPower.mqh index 420deaad7..c57530b90 100644 --- a/Indicators/Indi_BearsPower.mqh +++ b/Indicators/Indi_BearsPower.mqh @@ -103,7 +103,7 @@ class Indi_BearsPower : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_BullsPower.mqh b/Indicators/Indi_BullsPower.mqh index ffe777e95..7af5ea215 100644 --- a/Indicators/Indi_BullsPower.mqh +++ b/Indicators/Indi_BullsPower.mqh @@ -103,7 +103,7 @@ class Indi_BullsPower : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index ea9f16318..6887afb80 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -145,7 +145,7 @@ class Indi_CCI : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_CHO.mqh b/Indicators/Indi_CHO.mqh index f89b05081..f86691934 100644 --- a/Indicators/Indi_CHO.mqh +++ b/Indicators/Indi_CHO.mqh @@ -166,7 +166,7 @@ class Indi_CHO : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_CHV.mqh b/Indicators/Indi_CHV.mqh index 616a9570d..f7cba3d14 100644 --- a/Indicators/Indi_CHV.mqh +++ b/Indicators/Indi_CHV.mqh @@ -162,7 +162,7 @@ class Indi_CHV : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ColorBars.mqh b/Indicators/Indi_ColorBars.mqh index b319494e3..4f63a21b6 100644 --- a/Indicators/Indi_ColorBars.mqh +++ b/Indicators/Indi_ColorBars.mqh @@ -113,7 +113,7 @@ class Indi_ColorBars : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ColorCandlesDaily.mqh b/Indicators/Indi_ColorCandlesDaily.mqh index bf46d7cba..1872d25ce 100644 --- a/Indicators/Indi_ColorCandlesDaily.mqh +++ b/Indicators/Indi_ColorCandlesDaily.mqh @@ -109,7 +109,7 @@ class Indi_ColorCandlesDaily : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ColorLine.mqh b/Indicators/Indi_ColorLine.mqh index bde254e25..87a65b243 100644 --- a/Indicators/Indi_ColorLine.mqh +++ b/Indicators/Indi_ColorLine.mqh @@ -172,7 +172,7 @@ class Indi_ColorLine : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_CustomMovingAverage.mqh b/Indicators/Indi_CustomMovingAverage.mqh index 2cd2556b6..5309fd554 100644 --- a/Indicators/Indi_CustomMovingAverage.mqh +++ b/Indicators/Indi_CustomMovingAverage.mqh @@ -66,7 +66,7 @@ class Indi_CustomMovingAverage : public Indicator /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_ICUSTOM: diff --git a/Indicators/Indi_DEMA.mqh b/Indicators/Indi_DEMA.mqh index 9d1c7d6af..1400ffd6c 100644 --- a/Indicators/Indi_DEMA.mqh +++ b/Indicators/Indi_DEMA.mqh @@ -166,7 +166,7 @@ class Indi_DEMA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { diff --git a/Indicators/Indi_DeMarker.mqh b/Indicators/Indi_DeMarker.mqh index f6cfdbc49..f173a8217 100644 --- a/Indicators/Indi_DeMarker.mqh +++ b/Indicators/Indi_DeMarker.mqh @@ -101,7 +101,7 @@ class Indi_DeMarker : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Demo.mqh b/Indicators/Indi_Demo.mqh index 4edc68cd1..d9f66f828 100644 --- a/Indicators/Indi_Demo.mqh +++ b/Indicators/Indi_Demo.mqh @@ -72,7 +72,7 @@ class Indi_Demo : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = Indi_Demo::iDemo(GetSymbol(), GetTf(), _shift, THIS_PTR); if (iparams.is_draw) { draw.DrawLineTo(GetName(), GetBarTime(_shift), _value); diff --git a/Indicators/Indi_DetrendedPrice.mqh b/Indicators/Indi_DetrendedPrice.mqh index 6c07a1996..898cdb791 100644 --- a/Indicators/Indi_DetrendedPrice.mqh +++ b/Indicators/Indi_DetrendedPrice.mqh @@ -115,7 +115,7 @@ class Indi_DetrendedPrice : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index 964a3ab75..e65d11fea 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -170,7 +170,7 @@ class Indi_Drawer : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Envelopes.mqh b/Indicators/Indi_Envelopes.mqh index b67367e5d..04b26d892 100644 --- a/Indicators/Indi_Envelopes.mqh +++ b/Indicators/Indi_Envelopes.mqh @@ -195,7 +195,7 @@ class Indi_Envelopes : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index df130437c..e59968786 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -116,7 +116,7 @@ class Indi_Force : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_FractalAdaptiveMA.mqh b/Indicators/Indi_FractalAdaptiveMA.mqh index 74523b2b5..284866b17 100644 --- a/Indicators/Indi_FractalAdaptiveMA.mqh +++ b/Indicators/Indi_FractalAdaptiveMA.mqh @@ -134,7 +134,7 @@ class Indi_FrAMA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Fractals.mqh b/Indicators/Indi_Fractals.mqh index 6a7c7c263..e23b23c37 100644 --- a/Indicators/Indi_Fractals.mqh +++ b/Indicators/Indi_Fractals.mqh @@ -101,7 +101,7 @@ class Indi_Fractals : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Gator.mqh b/Indicators/Indi_Gator.mqh index 8c1147d9d..60cb4f812 100644 --- a/Indicators/Indi_Gator.mqh +++ b/Indicators/Indi_Gator.mqh @@ -168,7 +168,7 @@ class Indi_Gator : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_HeikenAshi.mqh b/Indicators/Indi_HeikenAshi.mqh index 79bea8f4e..fa5277a17 100644 --- a/Indicators/Indi_HeikenAshi.mqh +++ b/Indicators/Indi_HeikenAshi.mqh @@ -195,7 +195,7 @@ class Indi_HeikenAshi : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = HA_OPEN, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = HA_OPEN, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Ichimoku.mqh b/Indicators/Indi_Ichimoku.mqh index 7f7b0e1e7..43a3daa48 100644 --- a/Indicators/Indi_Ichimoku.mqh +++ b/Indicators/Indi_Ichimoku.mqh @@ -141,7 +141,7 @@ class Indi_Ichimoku : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: @@ -167,9 +167,9 @@ class Indi_Ichimoku : public Indicator { #ifdef __MQL4__ // In MQL4 value of LINE_TENKANSEN is 1 (not 0 as in MQL5), // so we are duplicating it. - _entry.values[0] = GetValue(LINE_TENKANSEN, _shift); + _entry.values[0] = GetMixedValue(LINE_TENKANSEN, _shift); #endif - _entry.values[LINE_CHIKOUSPAN] = GetValue(LINE_CHIKOUSPAN, _shift + 26); + _entry.values[LINE_CHIKOUSPAN] = GetMixedValue(LINE_CHIKOUSPAN, _shift + 26); } /** diff --git a/Indicators/Indi_MA.mqh b/Indicators/Indi_MA.mqh index 770d77a12..133d7e306 100644 --- a/Indicators/Indi_MA.mqh +++ b/Indicators/Indi_MA.mqh @@ -625,7 +625,7 @@ class Indi_MA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_MACD.mqh b/Indicators/Indi_MACD.mqh index 273a0cb82..1af133239 100644 --- a/Indicators/Indi_MACD.mqh +++ b/Indicators/Indi_MACD.mqh @@ -113,7 +113,7 @@ class Indi_MACD : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_MFI.mqh b/Indicators/Indi_MFI.mqh index 2853da83f..93b437faa 100644 --- a/Indicators/Indi_MFI.mqh +++ b/Indicators/Indi_MFI.mqh @@ -110,7 +110,7 @@ class Indi_MFI : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_MassIndex.mqh b/Indicators/Indi_MassIndex.mqh index 534d66154..e27105e14 100644 --- a/Indicators/Indi_MassIndex.mqh +++ b/Indicators/Indi_MassIndex.mqh @@ -153,7 +153,7 @@ class Indi_MassIndex : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index 7118eadcd..9778530f3 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -140,7 +140,7 @@ class Indi_Momentum : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_OBV.mqh b/Indicators/Indi_OBV.mqh index 485988a3d..d5bfe8b71 100644 --- a/Indicators/Indi_OBV.mqh +++ b/Indicators/Indi_OBV.mqh @@ -117,7 +117,7 @@ class Indi_OBV : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_OsMA.mqh b/Indicators/Indi_OsMA.mqh index f269a8a90..0bb1302e2 100644 --- a/Indicators/Indi_OsMA.mqh +++ b/Indicators/Indi_OsMA.mqh @@ -110,7 +110,7 @@ class Indi_OsMA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Pivot.mqh b/Indicators/Indi_Pivot.mqh index daa69e196..dc3711dbd 100644 --- a/Indicators/Indi_Pivot.mqh +++ b/Indicators/Indi_Pivot.mqh @@ -70,9 +70,13 @@ class Indi_Pivot : public Indicator { _entry.timestamp = GetBarTime(_ishift); if (_ohlc.IsValid()) { _entry.Resize(iparams.GetMaxModes()); - _ohlc.GetPivots(GetMethod(), _entry.values[0].vflt, _entry.values[1].vflt, _entry.values[2].vflt, - _entry.values[3].vflt, _entry.values[4].vflt, _entry.values[5].vflt, _entry.values[6].vflt, - _entry.values[7].vflt, _entry.values[8].vflt); + _ohlc.GetPivots(GetMethod(), _entry.values[0].value.vflt, _entry.values[1].value.vflt, + _entry.values[2].value.vflt, _entry.values[3].value.vflt, _entry.values[4].value.vflt, + _entry.values[5].value.vflt, _entry.values[6].value.vflt, _entry.values[7].value.vflt, + _entry.values[8].value.vflt); + for (int i = 0; i <= 8; ++i) { + _entry.values[i].SetDataType(TYPE_FLOAT); + } } GetEntryAlter(_entry, _ishift); _entry.SetFlag(INDI_ENTRY_FLAG_IS_VALID, IsValidEntry(_entry)); @@ -94,7 +98,7 @@ class Indi_Pivot : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { return GetEntry(_shift)[_mode]; } + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { return GetEntry(_shift)[_mode]; } /** * Checks if indicator entry values are valid. diff --git a/Indicators/Indi_PriceChannel.mqh b/Indicators/Indi_PriceChannel.mqh index e35c4be06..bb60bfaa8 100644 --- a/Indicators/Indi_PriceChannel.mqh +++ b/Indicators/Indi_PriceChannel.mqh @@ -105,7 +105,7 @@ class Indi_PriceChannel : public Indicator { /** * Returns the indicator's value. */ - double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { ResetLastError(); double _value = EMPTY_VALUE; switch (iparams.idstype) { diff --git a/Indicators/Indi_PriceFeeder.mqh b/Indicators/Indi_PriceFeeder.mqh index 1db799bdc..24e35c8b1 100644 --- a/Indicators/Indi_PriceFeeder.mqh +++ b/Indicators/Indi_PriceFeeder.mqh @@ -75,7 +75,7 @@ class Indi_PriceFeeder : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(ENUM_APPLIED_PRICE _ap, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { int data_size = ArraySize(iparams.price_data); if (_shift >= data_size || _shift < 0) return DBL_MIN; diff --git a/Indicators/Indi_PriceVolumeTrend.mqh b/Indicators/Indi_PriceVolumeTrend.mqh index 47502b7dc..eca779fe3 100644 --- a/Indicators/Indi_PriceVolumeTrend.mqh +++ b/Indicators/Indi_PriceVolumeTrend.mqh @@ -120,7 +120,7 @@ class Indi_PriceVolumeTrend : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_RS.mqh b/Indicators/Indi_RS.mqh index d78e54aea..50746a0b1 100644 --- a/Indicators/Indi_RS.mqh +++ b/Indicators/Indi_RS.mqh @@ -78,17 +78,16 @@ class Indi_RS : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { - double _value = EMPTY_VALUE; + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { switch (iparams.idstype) { case IDATA_MATH: - _value = imath[_mode].Ptr().GetValue(); + return imath[_mode].Ptr().GetMixedValue(); break; default: SetUserError(ERR_INVALID_PARAMETER); break; } - return _value; + return EMPTY_VALUE; } /** diff --git a/Indicators/Indi_RSI.mqh b/Indicators/Indi_RSI.mqh index 50fa4662c..f6441d8fd 100644 --- a/Indicators/Indi_RSI.mqh +++ b/Indicators/Indi_RSI.mqh @@ -52,6 +52,7 @@ struct IndiRSIParams : IndicatorParams { : applied_price(_ap), IndicatorParams(INDI_RSI, 1, TYPE_DOUBLE) { shift = _shift; SetDataValueRange(IDATA_RANGE_RANGE); + // SetDataSourceType(IDATA_ICUSTOM); SetCustomIndicatorName("Examples\\RSI"); SetPeriod(_period); }; @@ -286,8 +287,10 @@ class Indi_RSI : public Indicator { * Note that in MQL5 Applied Price must be passed as the last parameter * (before mode and shift). */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; + int _bars_calc; + double _res[]; switch (iparams.idstype) { case IDATA_BUILTIN: istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle; @@ -297,6 +300,7 @@ class Indi_RSI : public Indicator { istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle; _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ iparams.GetPeriod(), iparams.GetAppliedPrice() /* ] */, 0, _shift); + Print(_value); break; case IDATA_INDICATOR: _value = Indi_RSI::iRSIOnIndicator(GetDataSource(), THIS_PTR, GetSymbol(), GetTf(), iparams.GetPeriod(), diff --git a/Indicators/Indi_RVI.mqh b/Indicators/Indi_RVI.mqh index e99f76a80..535668610 100644 --- a/Indicators/Indi_RVI.mqh +++ b/Indicators/Indi_RVI.mqh @@ -102,7 +102,7 @@ class Indi_RVI : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_RateOfChange.mqh b/Indicators/Indi_RateOfChange.mqh index 9abef6869..f8eddcbf2 100644 --- a/Indicators/Indi_RateOfChange.mqh +++ b/Indicators/Indi_RateOfChange.mqh @@ -109,7 +109,7 @@ class Indi_RateOfChange : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_SAR.mqh b/Indicators/Indi_SAR.mqh index c86f2c47d..3a9c59f26 100644 --- a/Indicators/Indi_SAR.mqh +++ b/Indicators/Indi_SAR.mqh @@ -101,7 +101,7 @@ class Indi_SAR : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 3d468e2cc..1d582e028 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -224,7 +224,7 @@ class Indi_StdDev : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Stochastic.mqh b/Indicators/Indi_Stochastic.mqh index b472f0510..8fbbaafba 100644 --- a/Indicators/Indi_Stochastic.mqh +++ b/Indicators/Indi_Stochastic.mqh @@ -118,7 +118,7 @@ class Indi_Stochastic : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = LINE_MAIN, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_TEMA.mqh b/Indicators/Indi_TEMA.mqh index b47e46a3f..005d6dc98 100644 --- a/Indicators/Indi_TEMA.mqh +++ b/Indicators/Indi_TEMA.mqh @@ -126,7 +126,7 @@ class Indi_TEMA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_TRIX.mqh b/Indicators/Indi_TRIX.mqh index 5b83bc38d..8b5518c98 100644 --- a/Indicators/Indi_TRIX.mqh +++ b/Indicators/Indi_TRIX.mqh @@ -127,7 +127,7 @@ class Indi_TRIX : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_UltimateOscillator.mqh b/Indicators/Indi_UltimateOscillator.mqh index 634e5cbee..4b3dedc19 100644 --- a/Indicators/Indi_UltimateOscillator.mqh +++ b/Indicators/Indi_UltimateOscillator.mqh @@ -208,7 +208,7 @@ class Indi_UltimateOscillator : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_VIDYA.mqh b/Indicators/Indi_VIDYA.mqh index 34742ae39..f2410a0b9 100644 --- a/Indicators/Indi_VIDYA.mqh +++ b/Indicators/Indi_VIDYA.mqh @@ -147,7 +147,7 @@ class Indi_VIDYA : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_VROC.mqh b/Indicators/Indi_VROC.mqh index 159e43a28..65349c501 100644 --- a/Indicators/Indi_VROC.mqh +++ b/Indicators/Indi_VROC.mqh @@ -130,7 +130,7 @@ class Indi_VROC : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_Volumes.mqh b/Indicators/Indi_Volumes.mqh index 104f0890a..8b3e6bb98 100644 --- a/Indicators/Indi_Volumes.mqh +++ b/Indicators/Indi_Volumes.mqh @@ -124,7 +124,7 @@ class Indi_Volumes : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_WPR.mqh b/Indicators/Indi_WPR.mqh index 1327c4e5b..6d20ecc27 100644 --- a/Indicators/Indi_WPR.mqh +++ b/Indicators/Indi_WPR.mqh @@ -100,7 +100,7 @@ class Indi_WPR : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_WilliamsAD.mqh b/Indicators/Indi_WilliamsAD.mqh index 982bd6beb..5c883fbdc 100644 --- a/Indicators/Indi_WilliamsAD.mqh +++ b/Indicators/Indi_WilliamsAD.mqh @@ -124,7 +124,7 @@ class Indi_WilliamsAD : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ZigZag.mqh b/Indicators/Indi_ZigZag.mqh index d36bd4267..0e9c059bc 100644 --- a/Indicators/Indi_ZigZag.mqh +++ b/Indicators/Indi_ZigZag.mqh @@ -334,7 +334,7 @@ class Indi_ZigZag : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_BUILTIN: diff --git a/Indicators/Indi_ZigZagColor.mqh b/Indicators/Indi_ZigZagColor.mqh index 91a26b49d..def4e54eb 100644 --- a/Indicators/Indi_ZigZagColor.mqh +++ b/Indicators/Indi_ZigZagColor.mqh @@ -268,7 +268,7 @@ class Indi_ZigZagColor : public Indicator { /** * Returns the indicator's value. */ - double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { ResetLastError(); double _value = EMPTY_VALUE; switch (iparams.idstype) { diff --git a/Indicators/OHLC/Indi_OHLC.mqh b/Indicators/OHLC/Indi_OHLC.mqh index 2765da935..8fcef14bf 100644 --- a/Indicators/OHLC/Indi_OHLC.mqh +++ b/Indicators/OHLC/Indi_OHLC.mqh @@ -60,7 +60,7 @@ class Indi_OHLC : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { ENUM_APPLIED_PRICE _ap = PRICE_OPEN; switch (_mode) { case INDI_OHLC_CLOSE: diff --git a/Indicators/Price/Indi_Price.mqh b/Indicators/Price/Indi_Price.mqh index 804c64664..622edf907 100644 --- a/Indicators/Price/Indi_Price.mqh +++ b/Indicators/Price/Indi_Price.mqh @@ -62,7 +62,7 @@ class Indi_Price : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { return ChartStatic::iPrice(iparams.GetAppliedPrice(), GetSymbol(), GetTf(), _shift); } diff --git a/Indicators/Special/Indi_Math.mqh b/Indicators/Special/Indi_Math.mqh index 66fa5e021..175bde0bc 100644 --- a/Indicators/Special/Indi_Math.mqh +++ b/Indicators/Special/Indi_Math.mqh @@ -93,7 +93,7 @@ class Indi_Math : public Indicator { /** * Returns the indicator's value. */ - virtual double GetValue(int _mode = 0, int _shift = 0) { + virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) { double _value = EMPTY_VALUE; switch (iparams.idstype) { case IDATA_INDICATOR: diff --git a/tests/IndicatorsTest.mq5 b/tests/IndicatorsTest.mq5 index e66d8abef..72fb277be 100644 --- a/tests/IndicatorsTest.mq5 +++ b/tests/IndicatorsTest.mq5 @@ -70,7 +70,7 @@ int OnInit() { assertEqualOrFail(_LastError, ERR_NO_ERROR, StringFormat("Error: %d", GetLastError())); ResetLastError(); // Print indicator values. - _result &= PrintIndicators(__FUNCTION__); + //_result &= PrintIndicators(__FUNCTION__); assertEqualOrFail(_LastError, ERR_NO_ERROR, StringFormat("Error: %d", GetLastError())); ResetLastError(); bar_processed = 0; @@ -107,8 +107,8 @@ void OnTick() { IndicatorDataEntry _entry(_indi.GetEntry()); if (_indi.Get(STRUCT_ENUM(IndicatorState, INDICATOR_STATE_PROP_IS_READY)) && _entry.IsValid()) { PrintFormat("%s: bar %d: %s", _indi.GetFullName(), bar_processed, _indi.ToString()); - tested.Set(iter.Key(), true); // Mark as tested. - indis.Unset(iter.Key()); + // tested.Set(iter.Key(), true); // Mark as tested. + // indis.Unset(iter.Key()); } } } @@ -250,7 +250,7 @@ bool InitIndicators() { // Relative Strength Index (RSI). IndiRSIParams rsi_params(14, PRICE_OPEN); - indis.Push(new Indi_RSI(rsi_params)); + indis.Push(_indi_test = new Indi_RSI(rsi_params)); // Relative Strength Index (RSI). IndiRSIParams rsi_over_blt_stddev_params(); @@ -516,7 +516,7 @@ bool InitIndicators() { // Pattern Detector. IndiPatternParams pattern_params(); - indis.Push(_indi_test = new Indi_Pattern(pattern_params)); + indis.Push(new Indi_Pattern(pattern_params)); // Pivot. IndiPivotParams pivot_params();