Skip to content

Triangular Moving Average

TRIMA is a moving average that places equal weight on all prices within the period.

Method

tm.ta.trima(source, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator30

Outputs

OutputType
trimanp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Triangular Moving Average
trima = tm.ta.trima(data.close, timeperiod=30)
# Get the last value and print
last_value = trima.iloc[-1]
tm.log(f"Last value of Triangular Moving Average is {last_value}")
# Plot the values of trima
tm.plot(trima, title="Triangular Moving Average", overlay=False)