74 lines
2.4 KiB
MQL5
74 lines
2.4 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| TfBarSeries.mqh |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2025, MetaQuotes Ltd."
| |||
#property link "https://www.mql5.com"
| |||
#property version "1.00"
| |||
| |||
#include <Collection/DynamicArrayList.mqh>
| |||
#include "../Configs/IndicatorConfig.mqh"
| |||
#include "../Market/IndicatorSeries.mqh"
| |||
#include "../Market/BarSeries.mqh"
| |||
//+------------------------------------------------------------------+
| |||
//| Data structure for one symbol/timeframe |
| |||
//+------------------------------------------------------------------+
| |||
class TfBarSeries
| |||
{
| |||
public:
| |||
string symbol;
| |||
ENUM_TIMEFRAMES tf;
| |||
ENUM_TIMEFRAMES tradeTf;
| |||
| |||
BarSeries* bar;
| |||
| |||
CArrayList<IndicatorSeries*>* indicators;
| |||
| |||
ENUM_TIME_FETCH_TYPE fetchType;
| |||
int fetchCount;
| |||
bool relaunchOnNewPeriod;
| |||
datetime nextRelaunchTime;
| |||
| |||
TfBarSeries() : bar(NULL), relaunchOnNewPeriod(false), nextRelaunchTime(0) { indicators = new CArrayList<IndicatorSeries*>();}
| |||
| |||
// Update all underlying data
| |||
bool Update(int count =3)
| |||
{
| |||
if(bar == NULL || indicators == NULL)
| |||
return false;
| |||
if(!bar.Update(count))
| |||
return false;
| |||
for(int i = 0; i < indicators.Size(); i++)
| |||
indicators.At(i).Update(count);
| |||
return true;
| |||
}
| |||
| |||
int TotalBars() const { return bar.Size(); }
| |||
double Close(int pShift) { return bar.Close(pShift); }
| |||
double High(int pShift) { return bar.High(pShift); }
| |||
double Low(int pShift) { return bar.Low(pShift); }
| |||
double Open(int pShift) { return bar.Open(pShift); }
| |||
datetime Time(int pShift) { return bar.Time(pShift); }
| |||
| |||
int IndicatorCount() { return indicators.Size(); }
| |||
IndicatorSeries* GetIndicator(int idx) { return indicators.At(idx); }
| |||
| |||
void AddIndicator(IndicatorSeries* ind)
| |||
{
| |||
indicators.Add(ind);
| |||
}void ClearIndicators()
| |||
{
| |||
if(indicators == NULL)
| |||
return;
| |||
| |||
for(int i = 0; i < indicators.Size(); i++)
| |||
{
| |||
IndicatorSeries* ind = indicators.At(i);
| |||
| |||
if(ind != NULL)
| |||
delete ind;
| |||
}
| |||
| |||
indicators.Clear();
| |||
}
| |||
};
| |||
//+------------------------------------------------------------------+
|