Skip to content

Commit

Permalink
WIP. Getting rid of Chart as a base of IndicatorBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Mar 17, 2022
1 parent ce45e58 commit a97d43c
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 449 deletions.
72 changes: 38 additions & 34 deletions Account/AccountMt.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,42 +319,46 @@ class AccountMt {

/* Setters */

double UpdateStats(ENUM_ACC_STAT_VALUE _type, double _value) {
static datetime _last_check = TimeCurrent();
bool _stats_rotate = false;
for (unsigned int _pindex = 0; _pindex < FINAL_ENUM_ACC_STAT_PERIOD; _pindex++) {
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR] =
fmin(acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR], _value);
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR] =
fmin(acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR], _value);
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] =
(acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] + _value) / 2;
switch (_pindex) {
case ACC_DAILY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_D1);
break;
case ACC_WEEKLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_W1);
break;
case ACC_MONTHLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_MN1);
break;
}
if (_stats_rotate) {
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR] = _value;
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR] = _value;
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] = _value;
_last_check = TimeCurrent();
/*
@TODO Still used?
double UpdateStats(ENUM_ACC_STAT_VALUE _type, double _value) {
static datetime _last_check = TimeCurrent();
bool _stats_rotate = false;
for (unsigned int _pindex = 0; _pindex < FINAL_ENUM_ACC_STAT_PERIOD; _pindex++) {
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR] =
fmin(acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR], _value);
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR] =
fmin(acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR], _value);
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] =
(acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] + _value) / 2;
switch (_pindex) {
case ACC_DAILY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_D1);
break;
case ACC_WEEKLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_W1);
break;
case ACC_MONTHLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_MN1);
break;
}
if (_stats_rotate) {
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_PREV] =
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR];
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR] = _value;
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR] = _value;
acc_stats[_type][_pindex][ACC_VALUE_AVG][ACC_VALUE_CURR] = _value;
_last_check = TimeCurrent();
}
}
return _value;
}
return _value;
}
*/

/* Class getters */

Expand Down
56 changes: 0 additions & 56 deletions Chart.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,6 @@ class Chart : public Market {
int bar_index;

public:
/* Getters */

/**
* Gets a chart parameter value.
*/
template <typename T>
T Get(ENUM_CHART_PARAM _param) {
return cparams.Get<T>(_param);
}

/**
* Gets copy of params.
*
* @return
* Returns structure for Trade's params.
*/
ChartParams GetParams() const { return cparams; }

/* State checking */

/**
Expand Down Expand Up @@ -195,44 +177,6 @@ class Chart : public Market {
/* Conditions */

/* Printer methods */

/* Static methods */

/**
* Returns the price value given applied price type.
*/
static float GetAppliedPrice(ENUM_APPLIED_PRICE _ap, float _o, float _h, float _c, float _l) {
BarOHLC _bar(_o, _h, _c, _l);
return _bar.GetAppliedPrice(_ap);
}

/* Other methods */

/**
* Load stored BarOHLC values.
*
* @param
* _index unsigned int Index of the element in BarOHLC array.
* @return
* Returns BarOHLC struct element.
*/
ChartEntry LoadChartEntry(unsigned int _index = 0) { return chart_saves[_index]; }

/**
* Return size of BarOHLC array.
*/
unsigned long SizeChartEntry() { return ArraySize(chart_saves); }

/* Serializers */

/**
* Returns serialized representation of the object instance.
*/
SerializerNodeType Serialize(Serializer &_s) {
ChartEntry _centry = GetEntry();
_s.PassStruct(THIS_REF, "chart-entry", _centry, SERIALIZER_FIELD_FLAG_DYNAMIC);
return SerializerNodeObject;
}
};

#endif
7 changes: 5 additions & 2 deletions Chart.symboltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#pragma once
#endif

// Includes.
#include "Std.h"

/**
* Represents symbol and timeframe. To be used by IndicatorBase and ChartBase classes.
*/
Expand All @@ -38,8 +41,8 @@ struct SymbolTf {
const ENUM_TIMEFRAMES tf;
const string symbol_tf_key;

const string Key() const { return symbol_tf_key; }
const string Symbol() const { return symbol; }
CONST_REF_TO(string) Key() const { return symbol_tf_key; }
CONST_REF_TO(string) Symbol() const { return symbol; }
ENUM_TIMEFRAMES Tf() const { return tf; }

SymbolTf(string _symbol, ENUM_TIMEFRAMES _tf)
Expand Down
Loading

0 comments on commit a97d43c

Please sign in to comment.