# Quiet Hours Trend

> Quiet Hours Trend is a strategy that trades USDJPY on 15-minute bars. It holds at most 2 open trades (1 per side) and never risks more than 2% across 

Source: https://algobarsx.com/docs/ex-18-quiet-hours-trend/

```algobarsx
strategy "Quiet Hours Trend"
    market: USDJPY
    bars: 15m
    max_open: 2
    max_open_per_side: 1
    max_total_risk: 2%

input risk = 0.5%

fast_line = ema(close, 9)
slow_line = ema(close, 34)

when crosses_above(fast_line, slow_line) from 01:00 to 11:00 UTC skip first 1 max 3 per session cooldown 30m:
    buy risk: risk, stop: 20 pips, target: 1.8R

when crosses_below(fast_line, slow_line) from 01:00 to 11:00 UTC skip first 1 max 3 per session cooldown 30m:
    sell risk: risk, stop: 20 pips, target: 1.8R

when hour >= 20:
    close_all
```
What this script says

Quiet Hours Trend is a strategy that trades USDJPY on 15-minute bars. It holds at most 2 open trades (1 per side) and never risks more than 2% across open trades.

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

It calculates `fast_line` as the 9-bar EMA of the close and `slow_line` as the 34-bar EMA of the close.

When `fast_line` crosses above `slow_line` (between 01:00 and 11:00 UTC, ignoring the first time, at most 3 times per session and waiting at least 30 minutes between actions), it buys at market, risking `risk` of the balance, with a stop 20 pips from the entry and with a target 1.8R from the entry.

When `fast_line` crosses below `slow_line` (between 01:00 and 11:00 UTC, ignoring the first time, at most 3 times per session and waiting at least 30 minutes between actions), it sells at market, risking `risk` of the balance, with a stop 20 pips from the entry and with a target 1.8R from the entry.

When the hour is at or above 20, it closes all trades.
