# ATR stop and target

The stop sits `stop_mult` times the average true range from the entry. The target is `target_r` times the distance to the stop, so a target of 2 risks one to make two.

> **Trap.** A stop measured in a fixed number of points is too tight in a quiet market and too wide in a busy one. Measure it from the market's own range.

## atr_stop_and_target.py

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

FORGE_API = 1


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

    period = param.Int(50, min=10, max=200, step=10, group="Entry")
    stop_mult = param.Float(2.0, min=1.0, max=4.0, step=0.5, group="Risk")
    target_r = param.Float(2.0, min=1.0, max=4.0, step=0.5, group="Risk")

    def compute(self, d) -> fg.Signals:
        average = ta.sma(d.close, self.period)
        return fg.Signals(
            long_entry=ta.crossover(d.close, average),
            long_exit=d.close < average,
            stop=fg.Stop.atr(mult=self.stop_mult, length=14),
            target=fg.Target.r(value=self.target_r),
        )
```
