Overview
This prompt aims to generate a TradingView Pine Script strategy for a specific trading setup. Programmers and traders seeking to automate their trading strategies will benefit from this detailed implementation.
Prompt Overview
Purpose: This script implements a 5-minute Opening Range Breakout trading strategy.
Audience: It is designed for traders using TradingView who want to automate their trading strategies.
Distinctive Feature: The strategy incorporates Fair Value Gap detection and engulfing candle confirmation for entries.
Outcome: Users can effectively trade breakouts with defined risk and reward parameters.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Cryptocurrency & Blockchain, Data & Analysis
- Techniques: Zero-Shot Prompting
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
Generate a TradingView Pine Script strategy implementing a 5-minute Opening Range Breakout (ORB) trading setup with the following details:
– Identify the Opening Range (OR):
– Use the high and low of the first 5-minute candle of the trading session.
– Breakout Signal:
– Wait for a candle to close outside the OR, indicating a breakout:
– Bullish: Close above OR high.
– Bearish: Close below OR low.
– Fair Value Gap (FVG) Detection:
– Detect an FVG formed after the breakout; this gap must be retested before entry.
– Entry Trigger:
– Entry is activated on the closure of an engulfing candle in the direction of the breakout that retests the FVG.
– Stop Loss Placement:
– Set stop loss at the low of the breakout candle (for bullish breakout) or the high (for bearish breakout).
– Take Profit Setting:
– Establish take profit at a 3:1 risk-to-reward ratio based on the distance between entry and stop loss.
The script should accurately:
– Detect the session start to define the OR.
– Identify breakouts.
– Detect and confirm retests of the FVG.
– Determine engulfing candles.
– Manage trades with precise stops and targets according to the described rules.
# Steps
1. Define Session Start:
– Set the timeframe to capture the first 5-minute candle’s high and low as the OR.
2. Monitor Subsequent Candles:
– Find a candle that closes outside the OR (breakout).
3. Detect Fair Value Gap:
– Identify the presence of an FVG (a gap between candles where price did not trade).
4. Wait for FVG Retest:
– Ensure price retests the FVG zone.
5. Confirm Entry:
– Confirm entry upon the close of an engulfing candle aligned with breakout direction on the retest.
6. Place Stop Loss:
– Set stop loss at the low of the breakout candle (if bullish) or the high (if bearish).
7. Calculate Take Profit:
– Calculate take profit at 3 times the risk (entry price minus stop loss distance).
8. Execute Entry and Manage Trade:
– Execute entry and manage the trade accordingly.
# Output Format
Provide a complete, well-commented Pine Script (version 5) strategy script that implements the entire described 5-minute Opening Range Breakout with Fair Value Gap retest and engulfing candle entry. Include detailed comments explaining each part of the logic for clarity and maintainability.
Screenshot Examples
How to Use This Prompt
- Copy the prompt as-is for TradingView Pine Script.
- Paste the prompt into your preferred coding environment.
- Adjust any specific parameters if necessary for your strategy.
- Run the script to test its functionality on TradingView.
- Review the output and make modifications as needed.
- Save and document your final script for future reference.
Tips for Best Results
- Define Opening Range: Capture the high and low of the first 5-minute candle to establish the OR.
- Monitor Breakouts: Look for candles closing above the OR high for bullish or below the OR low for bearish signals.
- Detect Fair Value Gaps: Identify gaps between candles post-breakout that need to be retested before entering trades.
- Confirm Entry with Engulfing Candles: Enter trades on the closure of an engulfing candle that retests the FVG in the direction of the breakout.
FAQ
- What is the Opening Range in trading?
The Opening Range is the high and low of the first few minutes of trading. - How do you identify a bullish breakout?
A bullish breakout occurs when the price closes above the Opening Range high. - What is a Fair Value Gap (FVG)?
An FVG is a price gap between candles where no trading occurred, indicating potential support or resistance. - How is the stop loss determined in this strategy?
The stop loss is set at the low of the breakout candle for bullish trades, and the high for bearish trades.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


