Coming from TradingView

Forge API 1Updated 1 Oct 2026

What is the same

A Pine indicator maps to an fg.Indicator and a Pine strategy to an fg.Strategy. The names differ more than the ideas: outputs replace plot, settings replace input, and the ta module carries the indicators you know.

What is different

  • Forge works on whole arrays. A Pine script runs once per bar and close[1] is the previous bar. A Forge calculate fills arrays, and a strategy's compute returns signals for every bar at once.
  • Closed bars only. Pine recalculates the forming bar on every tick, so a value can change before the bar ends. Forge decides on closed bars.
  • No look-ahead switch. A higher-timeframe series is visible only after its own bar has closed.
  • Missing values are NaN, and fg.nz and fg.isna replace nz and na.

The traps page lists the mistakes that cost the most.

Where to start

Read From Pine first, then repainting and look-ahead, which names repainting as Pine does. Then write your first indicator.

Pine names, in Forge

  • //@version=6 becomes FORGE_API = 1 on the first lines
  • strategy("Name") becomes class Name(fg.Strategy) with meta = fg.Meta(title="Name")
  • strategy(calc_on_order_fills=) becomes on_fill(self, ctx, fill) runs after each fill
  • var becomes An attribute set in setup(self, ctx)
  • barstate.isfirst becomes setup(self, ctx) and on_end(self, ctx, reason)

All 37 names

10 things in Pine have no Forge form. See the list.