Pine Script v6 strategy for NQ (Nasdaq Futures) NY Session breakout trading with configurable filters and risk management.
This strategy identifies the Opening Price Range (OPR) during a configurable time window and trades breakouts above/below that range during the NY trading session.
- Configurable Range Window: Define the start time and duration for calculating the high/low range
- Session-Based Trading: Trade entries only during a specified time window
- RSI Filter (optional): Filter entries based on RSI overbought/oversold conditions
- EMA Filter (optional): Require price to be above/below EMA for entries
- Swing-Based Stop Loss: Uses recent swing highs/lows for dynamic stop placement
- Flexible Risk:Reward: Common R:R or separate values for long/short positions
- Automatic Position Close: Force-close all positions at a specified time
- Visual Indicators: Range boxes, breakout lines, SL/TP levels on chart
- One Trade Per Day: Prevents overtrading
| Parameter | Description |
|---|---|
| Range Start HH:MM | Start time for range calculation |
| Range Duration | Duration in minutes for range accumulation |
| Trade Open HH:MM | Start of entry window |
| Trade Stop HH:MM | End of entry window |
| Trade Close HH:MM | Force close all positions |
| Timezone | Timezone for all time parameters |
| Parameter | Description |
|---|---|
| RSI Filter | Enable/disable RSI-based entry filtering |
| RSI Overbought | Threshold for long entries |
| RSI Oversold | Threshold for short entries |
| EMA Filter | Enable/disable EMA trend filter |
| EMA Period | EMA length for trend determination |
| Parameter | Description |
|---|---|
| R:R Common | Risk:Reward ratio (when using common value) |
| R:R Long | Risk:Reward for long positions (when separate) |
| R:R Short | Risk:Reward for short positions (when separate) |
Long Entry:
- Price closes above range high
- Within trading session window
- RSI conditions met (if enabled)
- Price above EMA (if enabled)
- No trade taken today
Short Entry:
- Price closes below range low
- Within trading session window
- RSI conditions met (if enabled)
- Price below EMA (if enabled)
- No trade taken today
- Open TradingView and go to Pine Editor
- Create a new script
- Copy and paste the content of
Strategy_OPR_Breakout.pine - Save and add to chart
This code is subject to the terms of the Mozilla Public License 2.0.

