ta

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ta holds the series of the technical analysis shared by the entry filters (agents/internal/entryfilter) and the features of the meta-labeling (agents/metalabel), following the conventions of Pine Script, as the helpers of the strategies do (agents/strategies/pine.go, unexported there): a missing value is NaN, the counterpart of Pine's na, comparisons involving NaN are false, and the recursive averages (EMA, RMA and everything built on them: ATR, RSI, DMI) are seeded with the SMA of their first length values, so they are NaN until then, like the built-ins. Every function reads its inputs only, never past their last value.

Index

Constants

This section is empty.

Variables

View Source
var NaN = math.NaN()

NaN is a missing value, Pine's na.

Functions

func ATR

func ATR(high, low, close []float64, length int) []float64

ATR is ta.atr: the RMA of ta.tr(true) (Wilder, "New Concepts in Technical Trading Systems", 1978).

func DMI

func DMI(high, low, close []float64, diLength, adxSmoothing int) (plusDI, minusDI, adx []float64)

DMI is ta.dmi (Wilder 1978): +DI, -DI and the ADX. A bar whose average true range is zero keeps the previous DI values, as fixnan does in the reference script. The ADX of length n is known from the bar 2n-1 on.

func EMA

func EMA(src []float64, length int) []float64

EMA is ta.ema: alpha = 2/(length+1).

func EfficiencyRatio

func EfficiencyRatio(close []float64, n int) []float64

EfficiencyRatio is Kaufman's efficiency ratio of length n (Perry Kaufman, "Trading Systems and Methods", the ratio of the adaptive moving average): the net move of the close over n bars over the sum of the absolute moves of each bar, |C[t]-C[t-n]| / Σ|C[i]-C[i-1]| for i from t-n+1 to t, from 0 (all noise) to 1 (a straight line); 0 for a close that didn't move at all, NaN for the first n bars.

func Missing

func Missing(n int) []float64

Missing returns n missing values.

func RMA

func RMA(src []float64, length int) []float64

RMA is ta.rma, Wilder's moving average: alpha = 1/length.

func RSI

func RSI(src []float64, length int) []float64

RSI is ta.rsi (Wilder 1978): 100 while the average loss is zero, 0 while the average gain is.

func SMA

func SMA(src []float64, length int) []float64

SMA is ta.sma: the mean of the last length values, NaN until the window is full and while it holds a NaN.

func Stdev

func Stdev(src []float64, length int) []float64

Stdev is ta.stdev(biased = true): the population standard deviation of the last length values, NaN until the window is full and while it holds a NaN.

func TrueRange

func TrueRange(high, low, close []float64, handleNa bool) []float64

TrueRange is ta.tr(handleNa). The first bar has no previous close: its true range is high-low when handleNa is set, NaN otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL