OPEN-SOURCE SCRIPT

ORB Strategy: Extensions & Custom SL (EOD & Live Lines)

60
That's a great request. Since you've now built a complex Pine Script Strategy with several user-configurable risk management, targeting, and exit options, the description should focus on the systematic rules used for entering, managing, and exiting trades.

Here is a clear, written description of the trading strategy you have built:

Trading Strategy Description: ORB Extension Breakout with Custom Stop, Live Tracking, and EOD Exit
This strategy is a systematic, momentum-based system designed for intraday trading. It operates on the principle of an Opening Range Breakout (ORB), utilizing the initial market consolidation to project high-probability targets, while offering multiple methods for managing risk and enforcing a mandatory end-of-day closure.

1. Market Identification (The Opening Range)
The strategy first defines the market's initial boundaries and volatility:

Session Window: The strategy calculates the Opening Range (OR) over a user-defined time period (default: 9:30 AM to 10:30 AM New York Time).

ORB Levels: Two key price levels are established and locked once the time window closes:

Wick High/Low: The absolute highest and lowest prices of the session. These serve as the entry trigger lines.

Body High/Low (Shaded Range): The highest and lowest open/close prices of the session. The height of this range is used as the basis for calculating all targets and stops.

2. Entry Rule (The Breakout)
The strategy waits passively for a breakout that confirms direction and ensures the move has not yet reached its immediate target.

Trigger Condition: A trade is signaled when a candle closes either:

Above the Wick High (for a Long entry).

Below the Wick Low (for a Short entry).

Constraint (Fresh Breakout): The entry is invalidated if the breakout candle's price action (High for Long, Low for Short) has already touched or surpassed the projected Take Profit (0.5 Extension) level before the candle closes.

Execution: The entry is a Market Order executed on the candle that meets the trigger conditions, subject to a user-defined Entry Delay (default 0 bars).

Direction Control: The user can select to trade Long Only, Short Only, or Both.

3. Exit and Risk Management
All trades are placed with simultaneous Take Profit and Stop Loss orders (a bracket order) upon entry.

A. Take Profit (TP)
The Take Profit is set at the 0.5 Extension of the Shaded Range (Body Range).

Calculation: The distance from the Body High/Low to the TP level is exactly 50% of the total height of the Shaded Range.

B. Stop Loss (SL)
The Stop Loss is dynamically calculated based on a user-selected method for risk control:

Range 0.5 (Body Range): The SL is placed an equal distance (0.5 times the Body Range height) outside the opposite side of the Body Range.

ATR Multiple: The Stop Loss distance is calculated as a user-defined Multiplier times the Average True Range (ATR).

Recent Swing Low/High: The Stop Loss is placed based on a structural low (for Long) or high (for Short) within a user-defined lookback period.

C. End-of-Day (EOD) Exit
Any open position is forced closed at the market price if it is still open when the user-defined closing time (default: 16:00 HHMM) is reached. This prevents carrying intraday risk overnight.

4. Visualization
The strategy includes comprehensive visual cues for analysis:

ORB Drawing: Displays the Wick High/Low and the shaded Body Range.

Breakout Signals: Highlights the specific bar where the validated entry signal occurs.

Closed Trades: Draws persistent lines for the Entry and Exit prices of the last few closed trades.

Live Open Trades: Draws persistent lines for the current Entry Price, active Take Profit Level, and active Stop Loss Level for any open position.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.