#ifndef __IntradayEma_h_ #define __IntradayEma_h_ #include "GenericTosData.h" #include "StandardCandles.h" // This always works off the close of each bar. Like a normal chart on a // desktop application, this include the bar in progress when computing the // EMA. class IntradayEma : public DataNode { private: StandardCandles *_candleData; GenericTosDataNode *_tosData; int _bars; double _portionOfNewValue; StandardCandles::Epoch _lastEpoch; int _currentBarCount; double _accumulator; // This is the EMA at the end of the last bar. enum { wTos, wCandle }; void onWakeup(int msgId); void onTos(); void onCandle(); void makeCurrent(); void addValue(double value); double getValue(double last) const; IntradayEma(DataNodeArgument const &args); friend class DataNode; public: // This was the state an instant before the last candle was complete, and the // current candle was created. bool getLastValid(); double getLastValue(); // This is the state including the candle currently in progress. bool getCurrentValid(); double getCurrentValue(); static DataNodeLink *find(DataNodeListener *listener, int msgId, IntradayEma *&node, std::string const &symbol, int minutesPerBar, int bars); static DataNodeLink *find(IntradayEma *&node, std::string const &symbol, int minutesPerBar, int bars); }; #endif