# Smart Money Pullback

> Smart Money Pullback is a strategy that trades GBPJPY on 15-minute bars. It holds at most 1 open trade and trades only during the London and New York 

Source: https://algobarsx.com/docs/ex-36-smart-money-pullback/

```algobarsx
strategy "Smart Money Pullback"
    market: GBPJPY
    bars: 15m
    max_open: 1
    trade_only: within sessions london, new_york

pd = premium_discount(80)
entry_zone = optimal_trade_entry(swing_length: 5)

confirmations smc_long:
    choch: was(change_of_character(direction: up), within: 20 bars)
    swept: was(liquidity_sweeps(30), within: 10 bars)
    in_discount: close < pd.equilibrium
    at_entry_zone: low <= entry_zone.top and close >= entry_zone.bottom
    require: all

when smc_long.passed cooldown 10 bars:
    buy risk: 0.75%, stop: entry_zone.bottom - atr(14) * 0.25, target: pd.premium.bottom:
        breakeven at: 1.5R

box id: "premium", from: (bar.index - 80, pd.premium.top), to: (bar.index, pd.premium.bottom), color: red.fade(90)
box id: "discount", from: (bar.index - 80, pd.discount.top), to: (bar.index, pd.discount.bottom), color: green.fade(90)
```
What this script says

Smart Money Pullback is a strategy that trades GBPJPY on 15-minute bars. It holds at most 1 open trade and trades only during the London and New York sessions.

It calculates `pd` as the premium and discount zones (length 80) and `entry_zone` as the optimal trade entry zone (swing length 5).

`smc_long` passes when all of these 4 conditions are true: `choch` (the change of character (direction `up`) at some point within the last 20 bars); `swept` (the liquidity sweeps (length 30) at some point within the last 10 bars); `in_discount` (the close is below `pd.equilibrium`); `at_entry_zone` (the low is at or below `entry_zone.top` and the close is at or above `entry_zone.bottom`).

When `smc_long` passes (waiting at least 10 bars between actions), it buys at market, risking 0.75% of the balance, with a stop at `entry_zone.bottom` minus 0.25 × the 14-bar ATR and with a target at `pd.premium.bottom`; once open, it moves the stop to breakeven at 1.5R.

On the chart, it draws a box and draws a box.
