Skip to content

Commit

Permalink
Merge branch 'dev-indis' into dev-indis-fixme
Browse files Browse the repository at this point in the history
* dev-indis:
  Fixes Indi_ATR test
  ValueStorage.all.h now includes ValueStorage class and all its sub-classes. Could be used in indicator class files.
  • Loading branch information
kenorb committed Sep 21, 2021
2 parents 380224d + edce34e commit 99f4784
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Indicator.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ struct IndicatorParams {
void SetName(string _name) { name = _name; };
void SetShift(int _shift) { shift = _shift; }
void SetSize(int _size) { max_buffers = _size; };
void SetTf(ENUM_TIMEFRAMES _tf) { tf.SetTf(_tf); }
// Serializers.
// SERIALIZER_EMPTY_STUB;
// template <>
Expand All @@ -513,11 +514,7 @@ struct IndicatorState {
IndicatorState() : handle(INVALID_HANDLE), is_changed(true), is_ready(false) {}
// Getters.
template <typename T>
#ifdef __MQL4__
T Get(ENUM_INDICATOR_STATE_PROP _prop){
#else
T Get(IndicatorState::ENUM_INDICATOR_STATE_PROP _prop) {
#endif
T Get(STRUCT_ENUM(IndicatorState, ENUM_INDICATOR_STATE_PROP) _prop) {
switch (_prop) {
case INDICATOR_STATE_PROP_HANDLE:
return (T)handle;
Expand Down
2 changes: 1 addition & 1 deletion Indicators/Indi_AC.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Indi_AC : public Indicator {
* Class constructor.
*/
Indi_AC(ACParams &_params) : Indicator((IndicatorParams)_params) { params = _params; };
Indi_AC(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : params(_tf), Indicator(INDI_AC, _tf){};
Indi_AC(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AC, _tf) { params.SetTf(_tf); };

/**
* Returns the indicator value.
Expand Down
2 changes: 1 addition & 1 deletion Indicators/Indi_AD.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Indi_AD : public Indicator {
* Class constructor.
*/
Indi_AD(ADParams &_p) : Indicator((IndicatorParams)_p) { params = _p; };
Indi_AD(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : params(_tf), Indicator(INDI_AD, _tf){};
Indi_AD(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AD, _tf) { params.SetTf(_tf); };

/**
* Returns the indicator value.
Expand Down
5 changes: 2 additions & 3 deletions Indicators/Indi_ADX.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ADXParams : IndicatorParams {
unsigned int period;
ENUM_APPLIED_PRICE applied_price;
// Struct constructors.
void ADXParams(unsigned int _period, int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT,
void ADXParams(unsigned int _period = 14, int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT,
ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN)
: period(_period), applied_price(PRICE_TYPICAL) {
itype = itype == INDI_NONE ? INDI_ADX : itype;
Expand Down Expand Up @@ -77,8 +77,7 @@ class Indi_ADX : public Indicator {
* Class constructor.
*/
Indi_ADX(ADXParams &_p) : params(_p.period, _p.applied_price), Indicator((IndicatorParams)_p) { params = _p; }
Indi_ADX(ADXParams &_p, ENUM_TIMEFRAMES _tf) : params(_p.period, _p.applied_price), Indicator(INDI_ADX, _tf) {}
Indi_ADX(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : params(_tf), Indicator(INDI_ADX, _tf){};
Indi_ADX(ENUM_TIMEFRAMES _tf) : Indicator(INDI_ADX, _tf) {}

/**
* Returns the indicator value.
Expand Down
1 change: 1 addition & 0 deletions Indicators/Indi_ASI.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// Includes.
#include "../BufferStruct.mqh"
#include "../Indicator.mqh"
#include "../ValueStorage.all.h"

// Structs.
struct ASIParams : IndicatorParams {
Expand Down
4 changes: 2 additions & 2 deletions Indicators/Indi_ATR.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ double iATR(string _symbol, int _tf, int _period, int _shift) {
struct ATRParams : IndicatorParams {
unsigned int period;
// Struct constructors.
void ATRParams(unsigned int _period, int _shift = 0) : period(_period) {
void ATRParams(unsigned int _period = 14, int _shift = 0) : period(_period) {
itype = INDI_ATR;
max_modes = 1;
shift = _shift;
Expand All @@ -61,7 +61,7 @@ class Indi_ATR : public Indicator {
* Class constructor.
*/
Indi_ATR(ATRParams &_p) : params(_p.period), Indicator((IndicatorParams)_p) { params = _p; }
Indi_ATR(ATRParams &_p, ENUM_TIMEFRAMES _tf) : params(_p.period), Indicator(INDI_ATR, _tf) { params = _p; }
Indi_ATR(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ATR, _tf) { params.SetTf(_tf); };

/**
* Returns the indicator value.
Expand Down
41 changes: 41 additions & 0 deletions ValueStorage.all.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

/*
* 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 <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Includes ValueStorage class and all its subclasses.
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "ValueStorage.h"
#include "ValueStorage.history.h"
#include "ValueStorage.indicator.h"
#include "ValueStorage.native.h"
#include "ValueStorage.price.h"
#include "ValueStorage.spread.h"
#include "ValueStorage.tick_volume.h"
#include "ValueStorage.time.h"
#include "ValueStorage.volume.h"

0 comments on commit 99f4784

Please sign in to comment.