Skip to content

Midpoint Price over period

Midpoint Price represents the average price over a specified period.

Method

tm.ta.midprice(source_high, source_low, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
source_highpd.SeriesHigh prices series-
source_lowpd.SeriesLow prices series-
timeperiodintNumber of periods for the indicator14

Outputs

OutputType
midpricenp.ndarray

Example usage

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