From 1ece85323c8657d5544759efde0484243d47fb5b Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 25 Jun 2023 15:32:15 +0100 Subject: [PATCH] Removes Color Line indicator --- .github/workflows/test-indicators.yml | 1 - Indicators/Indi_ColorLine.mqh | 241 ----------------------- Indicators/includes.h | 1 - Indicators/tests/Indi_ColorLine.test.mq4 | 27 --- Indicators/tests/Indi_ColorLine.test.mq5 | 31 --- tests/IndicatorsTest.mq5 | 4 - 6 files changed, 305 deletions(-) delete mode 100644 Indicators/Indi_ColorLine.mqh delete mode 100644 Indicators/tests/Indi_ColorLine.test.mq4 delete mode 100644 Indicators/tests/Indi_ColorLine.test.mq5 diff --git a/.github/workflows/test-indicators.yml b/.github/workflows/test-indicators.yml index 83c05aca7..923378dfa 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_ColorLine.test - Indi_CustomMovingAverage.test - Indi_DeMarker.test - Indi_Demo.test diff --git a/Indicators/Indi_ColorLine.mqh b/Indicators/Indi_ColorLine.mqh deleted file mode 100644 index e5afbe3a7..000000000 --- a/Indicators/Indi_ColorLine.mqh +++ /dev/null @@ -1,241 +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" -#include "../Storage/ValueStorage.all.h" -#include "Price/Indi_MA.h" - -// Structs. -struct IndiColorLineParams : IndicatorParams { - IndicatorData *indi_ma; - // Struct constructor. - IndiColorLineParams(int _shift = 0) : IndicatorParams(INDI_COLOR_LINE) { - indi_ma = NULL; - SetCustomIndicatorName("Examples\\ColorLine"); - shift = _shift; - }; - IndiColorLineParams(IndiColorLineParams &_params) { THIS_REF = _params; }; -}; - -/** - * Implements Color Bars - */ -class Indi_ColorLine : public Indicator { - public: - /** - * Class constructor. - */ - Indi_ColorLine(IndiColorLineParams &_p, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN, - IndicatorData *_indi_src = NULL, int _indi_src_mode = 0) - : Indicator(_p, IndicatorDataParams::GetInstance(2, TYPE_DOUBLE, _idstype, IDATA_RANGE_MIXED, _indi_src_mode), - _indi_src){}; - Indi_ColorLine(int _shift = 0, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN, IndicatorData *_indi_src = NULL, - int _indi_src_mode = 0) - : Indicator(IndiColorLineParams(), - IndicatorDataParams::GetInstance(2, TYPE_DOUBLE, _idstype, IDATA_RANGE_MIXED, _indi_src_mode), - _indi_src){}; - /** - * Returns possible data source types. It is a bit mask of ENUM_INDI_SUITABLE_DS_TYPE. - * - * @fixit Should require Candle data source? - */ - unsigned int GetSuitableDataSourceTypes() override { return INDI_SUITABLE_DS_TYPE_CANDLE; } - - /** - * Returns possible data source modes. It is a bit mask of ENUM_IDATA_SOURCE_TYPE. - */ - unsigned int GetPossibleDataModes() override { return IDATA_ONCALCULATE | IDATA_ICUSTOM | IDATA_INDICATOR; } - - /** - * Checks whether given data source satisfies our requirements. - */ - bool OnCheckIfSuitableDataSource(IndicatorData *_ds) override { - if (Indicator::OnCheckIfSuitableDataSource(_ds)) { - return true; - } - - // Volume uses volume only. - return _ds PTR_DEREF HasSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME); - } - - /** - * OnCalculate-based version of Color Line as there is no built-in one. - */ - static double iColorLine(IndicatorData *_indi, int _mode = 0, int _rel_shift = 0) { - INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, ""); - // Will return Indi_MA with the same candles source as _indi's. - // @fixit There should be Candle attached to MA! - Indi_MA *_indi_ma = Indi_MA::GetCached(_indi, 10, 0, MODE_EMA, PRICE_CLOSE); - return iColorLineOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _mode, _indi PTR_DEREF ToAbsShift(_rel_shift), - _cache, _indi_ma); - } - - /** - * Calculates Color Line on the array of values. - */ - static double iColorLineOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, - IndiBufferCache *_cache, IndicatorData *_indi_ma, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); - - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 1); - } - - if (_recalculate) { - _cache.ResetPrevCalculated(); - } - - _cache.SetPrevCalculated(Indi_ColorLine::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _indi_ma)); - - return _cache.GetTailValue(_mode, _abs_shift); - } - - /** - * On-indicator version of Color Line. - */ - static double iColorLineOnIndicator(IndicatorData *_indi, int _mode, int _rel_shift, IndicatorData *_obj) { - INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, ""); - Indi_MA *_indi_ma = _obj.GetDataSource(INDI_MA); - return iColorLineOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _mode, _indi PTR_DEREF ToAbsShift(_rel_shift), - _cache, _indi_ma); - } - - /** - * Provides built-in indicators whose can be used as data source. - */ - virtual IndicatorData *FetchDataSource(ENUM_INDICATOR_TYPE _id) override { - switch (_id) { - case INDI_MA: - return iparams.indi_ma; - } - return NULL; - } - - /** - * OnCalculate() method for Color Line indicator. - */ - static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_LONG, ValueStorage &ExtColorLineBuffer, - ValueStorage &ExtColorsBuffer, IndicatorData *ExtMAHandle) { - static int ticks = 0, modified = 0; - // Check data. - int i, calculated = BarsCalculated(ExtMAHandle); - // @added History of 100 values should be enough for MA. - if (calculated < rates_total) { - // Not all data of ExtMAHandle is calculated. - return (0); - } - // First calculation or number of bars was changed. - if (prev_calculated == 0) { - // Copy values of MA into indicator buffer ExtColorLineBuffer. - if (CopyBuffer(ExtMAHandle, 0, 0, rates_total, ExtColorLineBuffer, rates_total) <= 0) return (0); - // Now set line color for every bar. - for (i = 0; i < rates_total && !IsStopped(); i++) ExtColorsBuffer[i] = GetIndexOfColor(i); - } else { - // We can copy not all data. - int to_copy; - if (prev_calculated > rates_total || prev_calculated < 0) - to_copy = rates_total; - else { - to_copy = rates_total - prev_calculated; - if (prev_calculated > 0) to_copy++; - } - // Copy values of MA into indicator buffer ExtColorLineBuffer. - int copied = CopyBuffer(ExtMAHandle, 0, 0, rates_total, ExtColorLineBuffer, rates_total); - if (copied <= 0) return (0); - - ticks++; - if (ticks >= 5) { - // Time to change color scheme. - ticks = 0; - // Counter of color changes. - modified++; - if (modified >= 3) modified = 0; - switch (modified) { - case 0: - // First color scheme. - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 0, Red); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 1, Blue); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 2, Green); - break; - case 1: - // Second color scheme. - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 0, Yellow); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 1, Pink); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 2, LightSlateGray); - break; - default: - // Third color scheme. - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 0, LightGoldenrod); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 1, Orchid); - ExtColorLineBuffer.PlotIndexSetInteger(PLOT_LINE_COLOR, 2, LimeGreen); - } - } else { - // Set start position. - int start = prev_calculated - 1; - // Now we set line color for every bar. - for (i = start; i < rates_total && !IsStopped(); i++) ExtColorsBuffer[i] = GetIndexOfColor(i); - } - } - // Return value of prev_calculated for next call. - return (rates_total); - } - - static int GetIndexOfColor(const int i) { - int j = i % 300; - if (j < 100) { - // First index. - return (0); - } - if (j < 200) { - // Second index. - return (1); - } - // Third index. - return (2); - } - - /** - * 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_BUILTIN: - case IDATA_ONCALCULATE: - _value = iColorLine(THIS_PTR, _mode, ToRelShift(_abs_shift)); - break; - case IDATA_ICUSTOM: - _value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, - ToRelShift(_abs_shift)); - break; - case IDATA_INDICATOR: - _value = iColorLine(THIS_PTR, _mode, ToRelShift(_abs_shift)); - break; - default: - SetUserError(ERR_INVALID_PARAMETER); - } - return _value; - } -}; diff --git a/Indicators/includes.h b/Indicators/includes.h index ecff4fcd4..d2a0ab967 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_ColorLine.mqh" #include "Indi_CustomMovingAverage.mqh" #include "Indi_DEMA.mqh" #include "Indi_DeMarker.mqh" diff --git a/Indicators/tests/Indi_ColorLine.test.mq4 b/Indicators/tests/Indi_ColorLine.test.mq4 deleted file mode 100644 index c48d4d6f1..000000000 --- a/Indicators/tests/Indi_ColorLine.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_ColorLine indicator class. - */ - -#include "Indi_ColorLine.test.mq5" diff --git a/Indicators/tests/Indi_ColorLine.test.mq5 b/Indicators/tests/Indi_ColorLine.test.mq5 deleted file mode 100644 index 204b15a67..000000000 --- a/Indicators/tests/Indi_ColorLine.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_ColorLine.mqh" - -/** - * @file - * Test functionality of Indi_ColorLine indicator class. - */ -TEST_INDICATOR_DEFAULT_BINDINGS(Indi_ColorLine); diff --git a/tests/IndicatorsTest.mq5 b/tests/IndicatorsTest.mq5 index f39ad6cb7..270da95bd 100644 --- a/tests/IndicatorsTest.mq5 +++ b/tests/IndicatorsTest.mq5 @@ -457,10 +457,6 @@ bool InitIndicators() { IndiCHVParams chv_params(); indis.Add(new Indi_CHV(chv_params)); - // Color Line. - IndiColorLineParams color_line_params(); - indis.Add(new Indi_ColorLine(color_line_params)); - // Detrended Price Oscillator. IndiDetrendedPriceParams detrended_params(); indis.Add(new Indi_DetrendedPrice(detrended_params));