trend
The library trend
implements functions for basic computation of trends in time-series (technical analysis). Time-series in this case are regular and are represented as lists of doubles.
returns the curve |
|
returns the curve |
|
returns the numerical derivatives of the list |
|
returns a scalar number, the computation of the average of the points in the list |
|
returns the average over the numerical derivatives of the smoothed curve (with SMA) of |
|
returns the average over the numerical derivatives of the smoothed curve (with CMA) of |
smoothingSMA
Returns the curve X
smoothed with the Simple Moving Average (SMA) method, with Y
as the number of consecutive points to average (min 2, max list size).
smoothingSMA(X, Y)
Where:
-
X
is the list of doubles representing the time-series to be smoothed. -
Y
is the number of consecutive points to average (min 2, max list size).
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:smoothingSMA(Y, 3).
@output("result").
result([2.0, 3.0, 4.0])
smoothingCMA
Returns the curve X
smoothed with the Cumulative Moving Average (CMA) method.
smoothingCMA(X)
Where:
-
X
is the list of doubles representing the time-series to be smoothed.
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:smoothingCMA(Y).
@output("result").
result([1.0, 1.5, 2.0, 2.5, 3.0])
numericalDerivative
Returns the numerical derivatives of the list X
for each couple of consecutive points.
numericalDerivative(X)
Where:
-
X
is the list of doubles representing the time-series.
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:numericalDerivative(Y).
@output("result").
result([1.0, 1.0, 1.0, 1.0])
avg
Returns a scalar number, the computation of the average of the points in the list X
.
avg(X)
Where:
-
X
is the list of doubles representing the time-series.
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:avg(Y).
@output("result").
result(3.0)
overallTrendSMA
Returns the average over the numerical derivatives of the smoothed curve (with SMA) of X
, with Y
as the number of consecutive points to average (min 2, max list size).
overallTrendSMA(X, Y)
Where:
-
X
is the list of doubles representing the time-series. -
Y
is the number of consecutive points to average (min 2, max list size).
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:overallTrendSMA(Y, 3).
@output("result").
result(1.0)
overallTrendCMA
Returns the average over the numerical derivatives of the smoothed curve (with CMA) of X
.
overallTrendCMA(X)
Where:
-
X
is the list of doubles representing the time-series.
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:overallTrendCMA(Y).
@output("result").
result(1.0)