Skip to content

Average Price

AVGPRICE calculates the average price over a specified period.

Method

tm.ta.avgprice(source_open, source_high, source_low, source_close)

Inputs

ParameterArgument typeDescriptionDefault Value
source_openpd.SeriesOpen prices series-
source_highpd.SeriesHigh prices series-
source_lowpd.SeriesLow prices series-
source_closepd.SeriesClose prices series-

Outputs

OutputType
avgpricenp.ndarray

Example usage

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