From 94d2da46e83dd7bad64be2b94c4f907c44e01808 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Fri, 16 Jun 2023 14:36:16 +0200 Subject: [PATCH] Fixes ZigZag and ZigZagColor value validation. --- Indicators/Indi_ZigZag.mqh | 4 +++- Indicators/Indi_ZigZagColor.mqh | 8 +++++--- Platform.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Indicators/Indi_ZigZag.mqh b/Indicators/Indi_ZigZag.mqh index fcb56a4d2..3242fd352 100644 --- a/Indicators/Indi_ZigZag.mqh +++ b/Indicators/Indi_ZigZag.mqh @@ -404,7 +404,9 @@ class Indi_ZigZag : public Indicator { /** * Checks if indicator entry values are valid. */ - virtual bool IsValidEntry(IndicatorDataEntry &_entry) { return !_entry.HasValue(EMPTY_VALUE); } + virtual bool IsValidEntry(IndicatorDataEntry &_entry) { + return _entry.values[0].Get() != DBL_MAX && _entry.values[0].Get() != EMPTY_VALUE; + } /* Getters */ diff --git a/Indicators/Indi_ZigZagColor.mqh b/Indicators/Indi_ZigZagColor.mqh index d0fcc7925..187bf02f3 100644 --- a/Indicators/Indi_ZigZagColor.mqh +++ b/Indicators/Indi_ZigZagColor.mqh @@ -61,13 +61,13 @@ class Indi_ZigZagColor : public Indicator { IndicatorData *_indi_src = NULL, int _indi_src_mode = 0) : Indicator( _p, IndicatorDataParams::GetInstance(3, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE_ON_SIGNAL, _indi_src_mode), - _indi_src){}; + _indi_src) {} Indi_ZigZagColor(int _shift = 0, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN, IndicatorData *_indi_src = NULL, int _indi_src_mode = 0) : Indicator( IndiZigZagColorParams(), IndicatorDataParams::GetInstance(3, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE_ON_SIGNAL, _indi_src_mode), - _indi_src){}; + _indi_src) {} /** * Returns possible data source types. It is a bit mask of ENUM_INDI_SUITABLE_DS_TYPE. */ @@ -321,7 +321,9 @@ class Indi_ZigZagColor : public Indicator { /** * Checks if indicator entry values are valid. */ - virtual bool IsValidEntry(IndicatorDataEntry &_entry) { return _entry.values[0].Get() != EMPTY_VALUE; } + virtual bool IsValidEntry(IndicatorDataEntry &_entry) { + return _entry.values[0].Get() != DBL_MAX && _entry.values[0].Get() != EMPTY_VALUE; + } /* Getters */ diff --git a/Platform.h b/Platform.h index 041d239fd..b5f5a3828 100644 --- a/Platform.h +++ b/Platform.h @@ -844,7 +844,7 @@ datetime StructToTime(MqlDateTime &dt_struct) { IndicatorDataEntry _entry = indi REF_DEREF GetEntry(); \ bool _is_ready = indi REF_DEREF Get(STRUCT_ENUM(IndicatorState, INDICATOR_STATE_PROP_IS_READY)); \ bool _is_valid = _entry.IsValid(); \ - Print(indi REF_DEREF ToString(), _is_ready ? "" : " (Not yet ready)"); \ + Print(indi REF_DEREF ToString(), _is_ready ? " (Ready)" : " (Not yet ready)"); \ if (_is_ready && !_is_valid) { \ Print(indi REF_DEREF ToString(), " (Invalid entry!)"); \ assertTrueOrExit(_entry.IsValid(), "Invalid entry!"); \