Skip to content

Commit

Permalink
Fixes ZigZag and ZigZagColor value validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Jun 16, 2023
1 parent 78d8634 commit 94d2da4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Indicators/Indi_ZigZag.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ class Indi_ZigZag : public Indicator<IndiZigZagParams> {
/**
* Checks if indicator entry values are valid.
*/
virtual bool IsValidEntry(IndicatorDataEntry &_entry) { return !_entry.HasValue<double>(EMPTY_VALUE); }
virtual bool IsValidEntry(IndicatorDataEntry &_entry) {
return _entry.values[0].Get<double>() != DBL_MAX && _entry.values[0].Get<double>() != EMPTY_VALUE;
}

/* Getters */

Expand Down
8 changes: 5 additions & 3 deletions Indicators/Indi_ZigZagColor.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class Indi_ZigZagColor : public Indicator<IndiZigZagColorParams> {
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.
*/
Expand Down Expand Up @@ -321,7 +321,9 @@ class Indi_ZigZagColor : public Indicator<IndiZigZagColorParams> {
/**
* Checks if indicator entry values are valid.
*/
virtual bool IsValidEntry(IndicatorDataEntry &_entry) { return _entry.values[0].Get<double>() != EMPTY_VALUE; }
virtual bool IsValidEntry(IndicatorDataEntry &_entry) {
return _entry.values[0].Get<double>() != DBL_MAX && _entry.values[0].Get<double>() != EMPTY_VALUE;
}

/* Getters */

Expand Down
2 changes: 1 addition & 1 deletion Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ datetime StructToTime(MqlDateTime &dt_struct) {
IndicatorDataEntry _entry = indi REF_DEREF GetEntry(); \
bool _is_ready = indi REF_DEREF Get<bool>(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!"); \
Expand Down

0 comments on commit 94d2da4

Please sign in to comment.