diff --git a/Buffer/BufferTick.h b/Buffer/BufferTick.h index 8e6ac9093..70965dcfe 100644 --- a/Buffer/BufferTick.h +++ b/Buffer/BufferTick.h @@ -56,6 +56,22 @@ class BufferTick : public BufferStruct> { Init(); } + /* Grouping methods */ + + /** + * Group ticks by seconds. + */ + DictStruct>> GroupBySecs(uint _spc) { + // DictStruct>> _result; + // @todo: for each iter + // for (DictStructIterator>> iter(Begin()); iter.IsValid(); ++iter) { + // Load timestamp from key, TickAB from value + // foreach some timestamp mod % _spc - calculate shift + // _result.Push(_shift, TickAB) + // Convert to OHLC in upper method + return NULL; + } + /* Callback methods */ /** diff --git a/Chart.struct.tf.h b/Chart.struct.tf.h index 49c7c88f3..7074f67e8 100644 --- a/Chart.struct.tf.h +++ b/Chart.struct.tf.h @@ -32,6 +32,7 @@ // Includes. #include "Chart.enum.h" +#include "Serializer.mqh" /* Defines struct for chart timeframe. */ struct ChartTf { @@ -346,8 +347,6 @@ struct ChartTf { SerializerNodeType Serialize(Serializer& s); }; -#include "Serializer.mqh" - /* Method to serialize ChartTf structure. */ SerializerNodeType ChartTf::Serialize(Serializer& s) { s.PassEnum(THIS_REF, "tf", tf); diff --git a/Indicator/IndicatorTf.h b/Indicator/IndicatorTf.h index a64d22338..956fb2b45 100644 --- a/Indicator/IndicatorTf.h +++ b/Indicator/IndicatorTf.h @@ -30,6 +30,7 @@ #endif // Includes. +#include "../Chart.struct.tf.h" #include "IndicatorCandle.h" #include "IndicatorTf.struct.h" @@ -51,14 +52,28 @@ class IndicatorTf : public IndicatorCandle { /* Special methods */ /** - * Class constructor. + * Class constructor with timeframe enum. */ - IndicatorTf(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) { Init(); } + IndicatorTf(uint _spc) { + icparams.SetSecsPerCandle(_spc); + Init(); + } /** - * Class constructor. + * Class constructor with timeframe enum. */ - IndicatorTf(ENUM_TIMEFRAMES_INDEX _tfi = 0) { Init(); } + IndicatorTf(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) { + icparams.SetSecsPerCandle(ChartTf::TfToSeconds(_tf)); + Init(); + } + + /** + * Class constructor with timeframe index. + */ + IndicatorTf(ENUM_TIMEFRAMES_INDEX _tfi = 0) { + icparams.SetSecsPerCandle(ChartTf::TfToSeconds(ChartTf::IndexToTf(_tfi))); + Init(); + } /** * Class constructor with parameters. diff --git a/Indicator/IndicatorTf.struct.h b/Indicator/IndicatorTf.struct.h index 8e82a67bd..5feae87e4 100644 --- a/Indicator/IndicatorTf.struct.h +++ b/Indicator/IndicatorTf.struct.h @@ -30,10 +30,18 @@ #pragma once #endif +// Includes. +#include "../Indicator.struct.h" + /* Structure for IndicatorTf class parameters. */ struct IndicatorTfParams : IndicatorParams { + uint spc; // Seconds per candle. // Struct constructor. - IndicatorTfParams() {} + IndicatorTfParams(uint _spc = 60) : spc(_spc) {} + // Getters. + uint GetSecsPerCandle() { return spc; } + // Setters. + void SetSecsPerCandle(uint _spc) { spc = _spc; } // Copy constructor. IndicatorTfParams(const IndicatorTfParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) { THIS_REF = _params;