Minimal indicator

Forge API 1Updated 1 Oct 2026

Indicator

One setting, one output and a calculate method: the smallest file that draws a line. Start here and change the formula.

moving_average.pypythonOpen in the editor
import forge as fg
from forge import param, ta

FORGE_API = 1


class MovingAverage(fg.Indicator):
    name = "Moving average"
    short_name = "MA"
    pane = "price"

    period = param.Int(20, min=2, max=200)

    average = fg.Output.line("Average")
    warmup = lambda self: self.period

    def calculate(self, bars, start) -> None:
        self.out.average[start:] = ta.sma(bars.close, self.period)[start:]
Open in the editor

Was this page helpful?