# LEAN traps

## 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.

> **Trap.** A session written as 09:30 to 16:00 in LEAN is New York time. In Forge, name the zone or the window is off by hours.

## 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.

```python
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)
```

> **Trap.** A loop over past bars inside `compute` is slow and usually unnecessary. Write it as an array operation.

## 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.

> **Trap.** An algorithm that trades on its first bar in LEAN may trade on nothing in Forge, because its indicators are still in warm-up.

## 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.

> **Trap.** A consolidated bar that is used before it has closed is look-ahead. Forge will not show it early.

## 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.
