# Six-Confirmation Momentum

> Six-Confirmation Momentum is a strategy that trades XAUUSD on 5-minute bars. It holds at most 1 open trade and stops for the day after losing 3%.

Source: https://algobarsx.com/docs/ex-02-six-confirmation-momentum/

```algobarsx
strategy "Six-Confirmation Momentum"
    market: XAUUSD
    bars: 5m
    max_open: 1
    max_daily_loss: 3%

use indicator "Trend Ribbon" v3 as ribbon (fast: 10, slow: 30)

input risk = 0.5%

confirmations long_setup:
    trend: ema(close, 50) > ema(close, 200)
    higher_tf: bars(bars: 1h).close > ema(bars(bars: 1h).close, 50)
    momentum: rsi(close, 14) between 55 and 70
    volume: volume > sma(volume, 20) * 1.5
    structure: break_of_structure(direction: up)
    ribbon: ribbon.up and ribbon.strength > 0.5
    require: all

when long_setup.passed as long_entry every 4th within sessions london, new_york:
    buy risk: risk, stop: lowest(low, 10) - 5 points, target: 3R, tag: "momentum":
        breakeven at: 1R
        partial 50% at: 2R
        trail by: atr(14) * 1.5, after: 2R
        exit after: 60 bars

on exit(trade):
    log "{trade.tag} closed at {trade.r:0.00}R after {long_entry.triggers} triggers"
```
What this script says

Six-Confirmation Momentum is a strategy that trades XAUUSD on 5-minute bars. It holds at most 1 open trade and stops for the day after losing 3%.

It uses the indicator "Trend Ribbon" (version 3) as `ribbon`, with `fast` set to 10 and `slow` set to 30.

You can change one input: `risk` (default 0.5%).

`long_setup` passes when all of these 6 conditions are true: `trend` (the 50-bar EMA of the close is above the 200-bar EMA of the close); `higher_tf` (the close of 1-hour bars is above the 50-bar EMA of the close of 1-hour bars); `momentum` (the 14-bar RSI is between 55 and 70); `volume` (volume is above 1.5 × the 20-bar SMA of volume); `structure` (a bullish break of structure); `ribbon` (`ribbon.up` and `ribbon.strength` is above 0.5).

When `long_setup` passes (on every 4th time and during the London and New York sessions), it buys at market, risking `risk` of the balance, with a stop at the lowest low of the last 10 bars minus 5 points, with a target 3R from the entry and tagged "momentum"; once open, it moves the stop to breakeven at 1R, closes 50% at 2R, trails the stop by 1.5 × the 14-bar ATR once the trade reaches 2R and exits after 60 bars.

When a trade closes, it logs "{trade.tag} closed at {trade.r:0.00}R after {long_entry.triggers} triggers".

This description may be incomplete because the script has errors.
