-
Notifications
You must be signed in to change notification settings - Fork 7
/
EMA.cpp
executable file
·50 lines (38 loc) · 1.27 KB
/
EMA.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/***************************************************************************
* (c) 2008-2011 Aleksandar Topuzović *
* <aleksandar.topuzovic@fer.hr>, <aleksandar.topuzovic@gmail.com> *
***************************************************************************/
#include "beagle/GP.hpp"
#include "EMA.hpp"
#include "ta.hpp"
#include "util.hpp"
#include <sstream>
#include <cmath>
#include <fstream>
using namespace Beagle;
// Primitive name: EMA
EMA::EMA() : Beagle::GP::Primitive(1, "EMA")
{ }
#ifdef BEAGLE_HAVE_RTTI
// Arguments: 1 integer
const std::type_info* EMA::getArgType(unsigned int inN, Beagle::GP::Context& ioContext) const
{
Beagle_AssertM(inN < 1);
return &typeid(UInt);
}
// Return value
const std::type_info* EMA::getReturnType(Beagle::GP::Context& ioContext) const
{
return &typeid(Double);
}
#endif // BEAGLE_HAVE_RTTI
// Exponential Moving Average (EMA)
void EMA::execute(GP::Datum& outDatum, GP::Context& ioContext)
{
Double& lResult = castObjectT<Double&>(outDatum);
UInt lArg;
get1stArgument(lArg, ioContext);
trading::Context& aContext = castObjectT<trading::Context&>(ioContext);
lResult = ema(aContext.database, aContext.dionica, aContext.datum, lArg );
//std::cout << "EMA: " << lResult << std::endl;
}