diff --git a/.github/workflows/test-indicators.yml b/.github/workflows/test-indicators.yml index 923378dfa..b8ee9e5c1 100644 --- a/.github/workflows/test-indicators.yml +++ b/.github/workflows/test-indicators.yml @@ -66,7 +66,6 @@ jobs: - Indi_CCI.test - Indi_CHO.test - Indi_CHV.test - - Indi_CustomMovingAverage.test - Indi_DeMarker.test - Indi_Demo.test - Indi_DetrendedPrice.test diff --git a/Indicators/Indi_CustomMovingAverage.mqh b/Indicators/Indi_CustomMovingAverage.mqh deleted file mode 100644 index b0cc0fb4e..000000000 --- a/Indicators/Indi_CustomMovingAverage.mqh +++ /dev/null @@ -1,137 +0,0 @@ -//+------------------------------------------------------------------+ -//| EA31337 framework | -//| Copyright 2016-2023, EA31337 Ltd | -//| https://ea31337.github.io | -//+------------------------------------------------------------------+ - -/* - * This file is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -// Includes. -#include "../Indicator/Indicator.h" -#include "../Storage/Dict/Buffer/BufferStruct.h" - -// Structs. -struct IndiCustomMovingAverageParams : IndicatorParams { - unsigned int smooth_period; - unsigned int smooth_shift; - ENUM_MA_METHOD smooth_method; - // Struct constructor. - IndiCustomMovingAverageParams(int _smooth_period = 13, int _smooth_shift = 0, - ENUM_MA_METHOD _smooth_method = MODE_SMMA, int _shift = 0) - : IndicatorParams(INDI_CUSTOM_MOVING_AVG) { - if (custom_indi_name == "") { -#ifdef __MQL5__ - SetCustomIndicatorName("Examples\\Custom Moving Average"); -#else - SetCustomIndicatorName("Custom Moving Averages"); -#endif - } - shift = _shift; - smooth_method = _smooth_method; - smooth_period = _smooth_period; - smooth_shift = _smooth_shift; - }; - IndiCustomMovingAverageParams(IndiCustomMovingAverageParams& _params) { THIS_REF = _params; }; -}; - -/** - * Implements the Custom Moving Average indicator. - */ -class Indi_CustomMovingAverage : public Indicator { - public: - /** - * Class constructor. - */ - Indi_CustomMovingAverage(IndiCustomMovingAverageParams& _p, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_ICUSTOM, - IndicatorData* _indi_src = NULL, int _indi_src_mode = 0) - : Indicator(_p, IndicatorDataParams::GetInstance(1, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE, _indi_src_mode), - _indi_src){}; - Indi_CustomMovingAverage(int _shift = 0, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_ICUSTOM, - IndicatorData* _indi_src = NULL, int _indi_src_mode = 0) - : Indicator(IndiCustomMovingAverageParams(), - IndicatorDataParams::GetInstance(1, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE, _indi_src_mode), - _indi_src){}; - - /** - * Returns possible data source types. It is a bit mask of ENUM_INDI_SUITABLE_DS_TYPE. - */ - unsigned int GetSuitableDataSourceTypes() override { return INDI_SUITABLE_DS_TYPE_EXPECT_NONE; } - - /** - * Returns possible data source modes. It is a bit mask of ENUM_IDATA_SOURCE_TYPE. - */ - unsigned int GetPossibleDataModes() override { return IDATA_ICUSTOM; } - - /** - * Returns the indicator's value. - */ - virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) { - double _value = EMPTY_VALUE; - switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { - case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetSmoothPeriod(), - GetSmoothShift(), GetSmoothMethod() /*]*/, 0, ToRelShift(_abs_shift)); - break; - default: - SetUserError(ERR_INVALID_PARAMETER); - } - return _value; - } - - /* Getters */ - - /** - * Get smooth period. - */ - unsigned int GetSmoothPeriod() { return iparams.smooth_period; } - - /** - * Get smooth shift. - */ - unsigned int GetSmoothShift() { return iparams.smooth_shift; } - - /** - * Get smooth method. - */ - ENUM_MA_METHOD GetSmoothMethod() { return iparams.smooth_method; } - - /* Setters */ - - /** - * Set smooth period. - */ - void SetSmoothPeriod(unsigned int _smooth_period) { - istate.is_changed = true; - iparams.smooth_period = _smooth_period; - } - - /** - * Set smooth shift. - */ - void SetSmoothShift(unsigned int _smooth_shift) { - istate.is_changed = true; - iparams.smooth_shift = _smooth_shift; - } - - /** - * Set smooth method. - */ - void SetSmoothMethod(ENUM_MA_METHOD _smooth_method) { - istate.is_changed = true; - iparams.smooth_method = _smooth_method; - } -}; diff --git a/Indicators/Price/Indi_MA.h b/Indicators/Price/Indi_MA.h index 16dcd6f57..2c9b4ef0a 100644 --- a/Indicators/Price/Indi_MA.h +++ b/Indicators/Price/Indi_MA.h @@ -76,8 +76,14 @@ struct IndiMAParams : IndicatorParams { IndiMAParams(unsigned int _period = 13, int _ma_shift = 0, ENUM_MA_METHOD _ma_method = MODE_SMA, ENUM_APPLIED_PRICE _ap = PRICE_OPEN, int _shift = 10) : period(_period), ma_shift(_ma_shift), ma_method(_ma_method), applied_array(_ap), IndicatorParams(INDI_MA) { + if (custom_indi_name == "") { +#ifdef __MQL5__ + SetCustomIndicatorName("Examples\\Custom Moving Average"); +#else + SetCustomIndicatorName("Custom Moving Averages"); +#endif + } shift = _shift; - SetCustomIndicatorName("Examples\\Moving Average"); }; IndiMAParams(IndiMAParams &_params) { THIS_REF = _params; }; }; @@ -674,13 +680,15 @@ class Indi_MA : public Indicator { break; case IDATA_ICUSTOM: _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.custom_indi_name, /* [ */ GetPeriod(), - GetMAShift(), GetMAMethod(), GetAppliedPrice() /* ] */, 0, ToRelShift(_abs_shift)); + GetMAShift(), GetMAMethod() /* ] */, 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(), ToRelShift(_abs_shift)); break; + default: + SetUserError(ERR_INVALID_PARAMETER); } return _value; diff --git a/Indicators/includes.h b/Indicators/includes.h index d2a0ab967..0026f30cd 100644 --- a/Indicators/includes.h +++ b/Indicators/includes.h @@ -41,7 +41,6 @@ #include "Indi_CCI.mqh" #include "Indi_CHO.mqh" #include "Indi_CHV.mqh" -#include "Indi_CustomMovingAverage.mqh" #include "Indi_DEMA.mqh" #include "Indi_DeMarker.mqh" #include "Indi_Demo.mqh" diff --git a/Indicators/tests/Indi_CustomMovingAverage.test.mq4 b/Indicators/tests/Indi_CustomMovingAverage.test.mq4 deleted file mode 100644 index ea53110f7..000000000 --- a/Indicators/tests/Indi_CustomMovingAverage.test.mq4 +++ /dev/null @@ -1,27 +0,0 @@ -//+------------------------------------------------------------------+ -//| EA31337 framework | -//| Copyright 2016-2023, EA31337 Ltd | -//| https://ea31337.github.io | -//+------------------------------------------------------------------+ - -/* - * This file is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * @file - * Test functionality of Indi_CustomMovingAverage indicator class. - */ - -#include "Indi_CustomMovingAverage.test.mq5" diff --git a/Indicators/tests/Indi_CustomMovingAverage.test.mq5 b/Indicators/tests/Indi_CustomMovingAverage.test.mq5 deleted file mode 100644 index 703ad75fc..000000000 --- a/Indicators/tests/Indi_CustomMovingAverage.test.mq5 +++ /dev/null @@ -1,31 +0,0 @@ -//+------------------------------------------------------------------+ -//| EA31337 framework | -//| Copyright 2016-2023, EA31337 Ltd | -//| https://ea31337.github.io | -//+------------------------------------------------------------------+ - -/* - * This file is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Includes. -#include "../../Platform/Platform.h" -#include "../../Test.mqh" -#include "../Indi_CustomMovingAverage.mqh" - -/** - * @file - * Test functionality of Indi_CustomMovingAverage indicator class. - */ -TEST_INDICATOR_DEFAULT_BINDINGS(Indi_CustomMovingAverage); diff --git a/tests/IndicatorsTest.mq5 b/tests/IndicatorsTest.mq5 index 270da95bd..726151b27 100644 --- a/tests/IndicatorsTest.mq5 +++ b/tests/IndicatorsTest.mq5 @@ -517,10 +517,6 @@ bool InitIndicators() { IndiZigZagColorParams zigzag_color_params(); indis.Add(new Indi_ZigZagColor(zigzag_color_params)); - // Custom Moving Average. - IndiCustomMovingAverageParams cma_params(); - indis.Add(new Indi_CustomMovingAverage(cma_params)); - // Math (specialized indicator). IndiMathParams math_params(MATH_OP_SUB, BAND_UPPER, BAND_LOWER, 0, 0); // math_params.SetPlot(clrBlue); // @fixme