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.

smoothingSMA

returns the curve X smoothed with the Simple Moving Average (SMA) method, with Y as the number of consecutive points to average

smoothingCMA

returns the curve X smoothed with the Cumulative Moving Average (CMA) method

numericalDerivative

returns the numerical derivatives of the list X for each couple of consecutive points

avg

returns a scalar number, the computation of the average of the points in the list X

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

overallTrendCMA

returns the average over the numerical derivatives of the smoothed curve (with CMA) of X

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).

Example
@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").
Expected results
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.

Example
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:smoothingCMA(Y).
@output("result").
Expected results
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.

Example
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:numericalDerivative(Y).
@output("result").
Expected results
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.

Example
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:avg(Y).
@output("result").
Expected results
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).

Example
@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").
Expected results
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.

Example
@library("trend:","trend").
timeseries([1.0, 2.0, 3.0, 4.0, 5.0]).
result(X) :- timeseries(Y), X = trend:overallTrendCMA(Y).
@output("result").
Expected results
result(1.0)