20 lines
564 B
C++
20 lines
564 B
C++
#include <iterator>
|
|
#include "decider.h"
|
|
|
|
macd_decider::macd_decider(std::size_t limit)
|
|
: prices(limit, .0), macd(limit, .0), signal(limit, .0), limit(limit) {}
|
|
|
|
void macd_decider::process(double price)
|
|
{
|
|
prices.add(price);
|
|
macd.add(ema<double>(prices.begin(), prices.begin() + 12) - ema<double>(prices.begin(), prices.begin() + 26));
|
|
signal.add(ema<double>(macd.begin(), macd.begin() + 9));
|
|
}
|
|
|
|
void macd_decider::reset()
|
|
{
|
|
prices = buffer<double>(limit, .0);
|
|
signal = buffer<double>(limit, .0);
|
|
macd = buffer<double>(limit, .0);
|
|
}
|