# Candle Reversal

> Candle Reversal is a strategy that trades EURUSD on 1-hour bars. It holds at most 1 open trade.

Source: https://algobarsx.com/docs/ex-29-candle-reversal/

```algobarsx
strategy "Candle Reversal"
    market: EURUSD
    bars: 1h
    max_open: 1

confirmations reversal_long:
    pattern: hammer() or engulfing(direction: up) or pin_bar()
    oversold: rsi(close, 14) < 35
    support: low <= lowest(low, 50)[1] + atr(14) * 0.5
    require: at least 2

when reversal_long.passed:
    buy risk: 1%, stop: low - atr(14) * 0.5, target: 2.5R
```
What this script says

Candle Reversal is a strategy that trades EURUSD on 1-hour bars. It holds at most 1 open trade.

`reversal_long` passes when at least 2 of these 3 conditions are true: `pattern` (a hammer pattern or a bullish engulfing pattern or a pin bar pattern); `oversold` (the 14-bar RSI is below 35); `support` (the low is at or below the previous bar's lowest low of the last 50 bars plus 0.5 × the 14-bar ATR).

When `reversal_long` passes, it buys at market, risking 1% of the balance, with a stop at the low minus 0.5 × the 14-bar ATR and with a target 2.5R from the entry.
