OPEN-SOURCE SCRIPT

Body Close Outside Prior Body - BOS Filtered (MTF) by JK

814
Strategy: MTF Market Structure & Body Breakout (BOS Filtered)
Overview
This Pine Script strategy identifies high-probability trade entries by combining Price Action Engulfing/Breakout patterns with Multi-Timeframe Market Structure (BOS). It is designed for traders who want to follow the "Path of Least Resistance" by ensuring entries on a lower timeframe align with the trend of a higher timeframe.

Key Features
Multi-Timeframe (MTF) Filter: Automatically detects Break of Structure (BOS) on a higher timeframe (e.g., 15m) using Pivot Highs/Lows to determine the overall market bias.

Body-Close Logic: Unlike standard engulfing patterns, this entry triggers specifically when a candle body closes entirely outside the price action of the prior candle's body, signaling strong momentum.

Dynamic Risk Management: * Calculates position size automatically based on a fixed dollar amount ($200 by default) per trade.

Adjustable Stop Loss source (Wick-based for safety or Body-based for tighter entries).

Institutional Safeguards: * Daily Loss/Profit Limits: Stops trading once a specific dollar target or loss threshold is hit for the day.

Loss Streak Protection: Automatically halts trading after a user-defined number of consecutive losses to prevent revenge trading.

Post-Trade Cooldown: Forces a "wait period" (candle count) after an exit before a new entry can be taken.

Session Filtering: Restricts trading to specific hours (e.g., NYSE Open) to avoid low-liquidity chop.

Technical Logic
Market Bias: The script tracks PivotHigh and PivotLow on the BOS Timeframe. A close above the last Pivot High sets a Bullish bias; a close below the last Pivot Low sets a Bearish bias.

The Entry:

Long: Market Bias is Bullish + Prior candle was Bearish + Current candle is Bullish + Current Close is higher than the prior candle's Body High.

Short: Market Bias is Bearish + Prior candle was Bullish + Current candle is Bearish + Current Close is lower than the prior candle's Body Low.

Exit Strategy: Uses a fixed Risk:Reward ratio (Default 1:2). The Stop Loss is dynamically placed at the recent swing (wick) or the candle open.

Visual Dashboard
The strategy includes a real-time HUD (Heads-Up Display) in the top-right corner of the chart, tracking:

Current Trend Direction (MTF)

Current Daily P&L (USD)

Current Loss Streak vs. Maximum allowed.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.