# Write your first strategy

## What you need

1. An Oathra account. Creating one is free.
2. Price history for one symbol, exported from MetaTrader. Oathra ships no sample prices. [Bring your price history](https://oathra.dev/docs/how-to/bring-your-price-history)
3. A first test on your own price history needs storage, and the free plan includes none. Storage starts at 40 credits a month. Credit packs are coming soon.
4. Credits for the data check and the test. Both are charged by the minute, and Forge shows the cost of a test before it starts. A standard test uses about 13 credits an hour.
5. The numbers of a test are on both plans. The verdict is on the paid plan, \$29 a month.

## 1. Write the strategy

A strategy is one Python file with one `fg.Strategy` class. Its `compute` method gets the price arrays as `d` and returns the signals for every bar at once.

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

FORGE_API = 1


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

    period = param.Int(14, min=2, max=50, group="RSI")
    buy_level = param.Int(30, min=10, max=45, step=5, group="RSI")
    exit_level = param.Int(60, min=50, max=80, step=5, group="RSI")

    def compute(self, d) -> fg.Signals:
        rsi = ta.rsi(d.close, self.period)
        return fg.Signals(
            long_entry=ta.crossover(rsi, self.buy_level),
            long_exit=rsi > self.exit_level,
        )
```

The entry fires on the bar where the RSI crosses up through `buy_level`, not on every bar it stays above. The exit fires when it reaches `exit_level`.

> **Trap.** A level that the RSI is already above on the first bar after warm-up is not a cross. Nothing fires until the RSI has been below the level first.

`bars = fg.bars.Time("H1")` decides on one-hour bars. `compute` is pure: it reads `d` and the settings and nothing else, so it cannot look at the clock, the account or a random number.

## 2. Take it to Forge

Download the file. Testing is in Forge on oathra.app, on price history you upload.

[Test in Forge ↗](https://oathra.app/en/forge/tester?from=dev-guide-door\&section=data)

Opens oathra.app in a new tab. You need an Oathra account. A test needs price history, [storage and credits](https://oathra.dev/docs/get-started/get-a-verdict#what-you-need), and the verdict is on the paid plan.

> **You now have**
>
> A strategy file, ready to take to Forge.
