# Minimal strategy

A strategy needs a class, its bars and a `compute` method that returns signals. This one buys while the close is above its average and leaves when it is below.

> **Trap.** `compute` must be pure. It reads `d` and the settings and nothing else, so it has no clock and no account.

## above_average.py

```python
import forge as fg
from forge import param, ta

FORGE_API = 1


class AboveAverage(fg.Strategy):
    bars = fg.bars.Time("H1")
    direction = "long"

    period = param.Int(50, min=10, max=200, step=10)

    def compute(self, d) -> fg.Signals:
        average = ta.sma(d.close, self.period)
        return fg.Signals(long_entry=d.close > average, long_exit=d.close < average)
```
