# DMI Trend Filter

> DMI Trend Filter is a strategy that trades EURJPY on 1-hour bars. It holds at most 1 open trade and reverses on an opposite signal.

Source: https://algobarsx.com/docs/ex-32-dmi-trend-filter/

```algobarsx
strategy "DMI Trend Filter"
    market: EURJPY
    bars: 1h
    max_open: 1
    opposite: reverse

input adx_floor = 25

d = dmi(14)
trending = d.adx > adx_floor

when trending and crosses_above(d.plus, d.minus):
    buy risk: 1%, stop: psar(), target: 3R

when trending and crosses_above(d.minus, d.plus):
    sell risk: 1%, stop: psar(), target: 3R

plot psar(), style: circles, color: yellow
```
What this script says

DMI Trend Filter is a strategy that trades EURJPY on 1-hour bars. It holds at most 1 open trade and reverses on an opposite signal.

You can change one input: `adx_floor` (default 25).

It calculates `d` as the directional movement (length 14) and `trending` as whether `d.adx` is above `adx_floor`.

When `trending` and `d.plus` crosses above `d.minus`, it buys at market, risking 1% of the balance, with a stop at the parabolic SAR and with a target 3R from the entry.

When `trending` and `d.minus` crosses above `d.plus`, it sells at market, risking 1% of the balance, with a stop at the parabolic SAR and with a target 3R from the entry.

On the chart, it plots the parabolic SAR.
