#ifndef __CandleModels_h_ #define __CandleModels_h_ #include #include struct CandleModelPoint { double x; double y; }; typedef std::vector< CandleModelPoint > CandleModelPoints; typedef std::vector< double > Prices; struct Print { double price; unsigned int volume; time_t time; }; typedef std::vector< Print > Prints; class CandleModel { private: double _open, _high, _low, _close; time_t _fromTime, _toTime; unsigned int _volume; CandleModelPoints _upperBand, _lowerBand; double priceAt(const double position, const CandleModelPoints &points); Prices pricesAt(const double position, const unsigned int count); time_t timeAt(const double position); Prints printsInRegion(const double fromPosition, const double toPosition, const int xCount, const int yCount); void volumeFromRight(unsigned int &startingVolumeInCandle, unsigned int &volumeToConsume, Prints &prints); friend class CandleModelList; public: unsigned int getVolume() { return _volume; } CandleModel() {} CandleModel(double open, double high, double low, double close, unsigned int volume, time_t fromTime, time_t toTime); }; class CandleModelList { private: std::vector< CandleModel > _candles; int _currentCandle; unsigned int _startingVolumeInCurrentCandle; void resetPointer(); public: CandleModelList(); void addCandle(const CandleModel &candle); void extractVolume(unsigned int volume, Prints &prints); bool done(); int count(); }; #endif