#ifndef __IntradayStochastic_h_ #define __IntradayStochastic_h_ #include "CurrentCandles.h" #include "StochasticFormula.h" /* This computes the stocastics indicator based on intraday data. We are * looking at the close of each candle. We update with each print, rather than * waiting for the last candle to be complete. * * http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:stochastic_oscillator */ class IntradayStochastic : public DataNode { private: CurrentCandles *_candleData; // Cached results bool _valid; double _pK, _pD; CurrentCandles::Epoch _lastEpoch; double _lastPrice; StochasticFormula _formula; void onWakeup(int msgId); void makeCurrent(); IntradayStochastic(DataNodeArgument const &args); friend class DataNode; public: void get(bool &valid, double &pK, double &pD); static DataNodeLink *findFull(DataNodeListener *listener, int msgId, IntradayStochastic *&node, std::string const &symbol, int minutesPerBar, int rangeCount, int pKSmaCount, int pDSmaCount); // Internally we always compute the full stocastic formula. We do this for // simplicity. The following are provided for convenience. static DataNodeLink *findFast(DataNodeListener *listener, int msgId, IntradayStochastic *&node, std::string const &symbol, int minutesPerBar, int rangeCount, int pDSmaCount) { return findFull(listener, msgId, node, symbol, minutesPerBar, rangeCount, 1, pDSmaCount); } static DataNodeLink *findSlow(DataNodeListener *listener, int msgId, IntradayStochastic *&node, std::string const &symbol, int minutesPerBar, int rangeCount, int pDSmaCount) { return findFull(listener, msgId, node, symbol, minutesPerBar, rangeCount, 3, pDSmaCount); } }; #endif