//+------------------------------------------------------------------+ //| Series.mqh | //| Copyright 2016, Vasiliy Sokolov, St-Petersburg, Russia | //| https://www.mql5.com/ru/users/c-4 | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, Vasiliy Sokolov." #property link "https://www.mql5.com/ru/users/c-4" //+------------------------------------------------------------------+ //| Доступ к котировкам необходимомого инструмента и таймфрейма. | //+------------------------------------------------------------------+ class CBaseRates { protected: string m_symbol; ENUM_TIMEFRAMES m_timeframe; CBaseRates(void); public: string Symbol(void); ENUM_TIMEFRAMES Timeframe(void); void Symbol(string symbol); void Timeframe(ENUM_TIMEFRAMES tf); int Total(void); }; //+------------------------------------------------------------------+ //| Конструктор по умолчанию. | //+------------------------------------------------------------------+ CBaseRates::CBaseRates(void) { } //+------------------------------------------------------------------+ //| Возвращает символ серии. | //+------------------------------------------------------------------+ string CBaseRates::Symbol(void) { return m_symbol; } //+------------------------------------------------------------------+ //| Устанавливает символ серии. | //+------------------------------------------------------------------+ void CBaseRates::Symbol(string symbol) { m_symbol=symbol; } //+------------------------------------------------------------------+ //| Возвращает таймфрейм инструмента. | //+------------------------------------------------------------------+ ENUM_TIMEFRAMES CBaseRates::Timeframe(void) { return m_timeframe; } //+------------------------------------------------------------------+ //| Устанавливает таймфрейм инструмента. | //+------------------------------------------------------------------+ void CBaseRates::Timeframe(ENUM_TIMEFRAMES tf) { m_timeframe=tf; } //+------------------------------------------------------------------+ //| Возвращает доступное количество баров. | //+------------------------------------------------------------------+ int CBaseRates::Total(void) { return Bars(m_symbol, m_timeframe); } //+------------------------------------------------------------------+ //| Доступ к ценам открытия необходимомого инструмента и таймфрейма. | //+------------------------------------------------------------------+ class COpen : public CBaseRates { public: double operator[](int index) { double value[]; if(CopyOpen(m_symbol, m_timeframe, index, 1, value) == 0)return 0.0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к максимальным ценам бара инструмента. | //+------------------------------------------------------------------+ class CHigh : public CBaseRates { public: double operator[](int index) { double value[]; if(CopyHigh(m_symbol, m_timeframe, index, 1, value) == 0)return 0.0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к минимальным ценам бара инструмента. | //+------------------------------------------------------------------+ class CLow : public CBaseRates { public: double operator[](int index) { double value[]; if(CopyLow(m_symbol, m_timeframe, index, 1, value) == 0)return 0.0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к ценам закрытия бара инструмента. | //+------------------------------------------------------------------+ class CClose : public CBaseRates { public: double operator[](int index) { double value[]; if(CopyClose(m_symbol, m_timeframe, index, 1, value) == 0)return 0.0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к реальным объемам бара инструмента. | //+------------------------------------------------------------------+ class CVolume : public CBaseRates { public: long operator[](int index) { long value[]; if(CopyRealVolume(m_symbol, m_timeframe, index, 1, value) == 0)return 0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к тиковым объемам бара инструмента. | //+------------------------------------------------------------------+ class CTickVolume : public CBaseRates { public: long operator[](int index) { long value[]; if(CopyTickVolume(m_symbol, m_timeframe, index, 1, value) == 0)return 0; return value[0]; } }; //+------------------------------------------------------------------+ //| Доступ к времени открытия баров. | //+------------------------------------------------------------------+ class CTime : public CBaseRates { public: datetime operator[](int index) { datetime value[]; if(CopyTime(m_symbol, m_timeframe, index, 1, value) == 0)return 0; return value[0]; } };