# Your first strategy

> Write it, read it back, run it.

Source: https://algobarsx.com/docs/first-strategy/

> **Would you rather describe it?** Type what you want in plain English in the editor. When the text reads as a description and not as code, a **Convert to AlgoBarsX** button appears and writes the script for you.

1. Open the **Terminal** in AlgoBars and start a new strategy. You get a working starter script, not a blank page.
2. Replace it with the script below. It buys when a fast average crosses above a slow one, risks 1% of the balance with a 25-pip stop and a target of twice the risk, and closes everything on the opposite cross.

```algobarsx
strategy "EMA Cross"
    market: EURUSD
    bars: 15m

input fast = 20
input slow = 50

when crosses_above(ema(close, fast), ema(close, slow)):
    buy risk: 1%, stop: 25 pips, target: 2R

when crosses_below(ema(close, fast), ema(close, slow)):
    close_all
```

1. Open the **description** tab. The compiler reads the script back to you:
 What this script says

EMA Cross is a strategy that trades EURUSD on 15-minute bars.

You can change 2 inputs: `fast` (default 20) and `slow` (default 50).

When the EMA of the close over `fast` bars crosses above the EMA of the close over `slow` bars, it buys at market, risking 1% of the balance, with a stop 25 pips from the entry and with a target 2R from the entry.

When the EMA of the close over `fast` bars crosses below the EMA of the close over `slow` bars, it closes all trades.

1. Press **Run**. A small panel asks what to test on: market, bars, bar type, how far back (1 week to 1 year), lot size and starting balance. The market and bars come filled in from your script, so you are confirming, not retyping.
2. You get results, a report, a chart and a **replay**. The replay plays the finished test back so you can watch each trade open and close and the balance move. Every run is kept under **versions** with the code that produced it, so you can always go back.
3. Change `fast` or the stop and run again. Nothing is lost by trying.

> **About the numbers.** Backtest results are hypothetical. Fills carry no spread, commission, fees, swaps or slippage (execution rule [E12](https://algobarsx.com/docs/rules-prices-distances-and-size/#E12)), so live results will differ. Past performance does not guarantee future results.
