Indicator with several outputs
Forge API 1Updated 1 Oct 2026
Indicator
This file shows the output kinds a strategy can read. A line and a histogram are numbers. A state is true or false on each bar. An event is 1, -1 or 0 on the bar it happens. A hidden output is computed and readable but not drawn.
h4 is a second series on four-hour bars. It follows the same rule as every other series: its values appear only after its own bar has closed.
trend_bands.pypythonOpen in the editor
import forge as fg
from forge import param, ta
FORGE_API = 1
class TrendBands(fg.Indicator):
name = "Trend bands"
short_name = "TB"
pane = "new"
precision = 2
format = "number"
period = param.Int(14, min=2, max=200)
h4 = fg.Data(timeframe="H4")
rsi = fg.Output.line("RSI")
momentum = fg.Output.histogram("Distance from 50")
overbought = fg.Output.state("Overbought")
cross_up = fg.Output.event("Crosses 50 upwards")
raw = fg.Output.hidden("raw_rsi")
levels = [fg.Level(70, "High"), fg.Level(50, "Mid"), fg.Level(30, "Low")]
warmup = lambda self: self.period
def calculate(self, bars, start) -> None:
value = ta.rsi(bars.close, self.period)
self.out.raw[start:] = value[start:]
self.out.rsi[start:] = value[start:]
self.out.momentum[start:] = (value - 50)[start:]
self.out.overbought[start:] = value[start:] > 70
self.out.cross_up[start:] = ta.crossover(value, 50)[start:].astype("int8")Was this page helpful?