LEAN traps

Forge API 1Updated 1 Oct 2026

The algorithm's clock

LEAN's algorithm time zone is New York unless the algorithm sets another. A time of day written against it means New York time. Forge stores and reads UTC, and a named zone is written out.

Slices and arrays

OnData sees one bar at a time. Code that keeps a rolling list of past values by hand is an array operation in Forge.

import forge as fg
from forge import ta

FORGE_API = 1


def above_average(close, period):
    # The average of the last `period` closes, for every bar at once.
    return close > ta.sma(close, period)

Warm-up

LEAN's SetWarmUp feeds history before the algorithm starts. A Forge indicator declares its warm-up, and its first bars are NaN. A condition on a NaN value is false, so nothing fires until the values exist.

Consolidators

A LEAN consolidator builds bars of another size from the data the algorithm already receives. In Forge a slower series is declared, and it follows one rule: it becomes visible only after its own bar has closed.

Scheduled events

LEAN's schedule calls a function at a time of day. Forge has fg.schedule.every and fg.schedule.on, and the day boundary comes from the broker facts, not from the algorithm's clock.