Doji Breakout (Close, Next 2 Candles, Single Signal + PNL)Here's a short description of the provided Pine Script "Doji Breakout (Close, Next 2 Candles, Single Signal + PNL)":
- Purpose: Detect Doji candles and generate breakout signals within the next two bars, plotting PNL-style visuals and optional labels/alerts.
- Doji detection: A candle is considered a Doji if the range (high-low) is positive and the body (absolute close-open) is less than or equal to a user-defined percentage of the range (default 10%).
- State tracking: Maintains the most recent Doji data (high, low, bar index) and flags whether a trade has been taken or if the Doji is active.
- Breakout logic: Checks the two bars after the Doji. If the close breaks above the Doji high, it’s a bullish/buy breakout; if it breaks below the Doji low, it’s a bearish/sell breakout. Only a single signal per Doji is considered (tradeTaken prevents multiple signals from the same Doji).
- PNL visualization (optional): When a breakout occurs and PNL is enabled, draws entry/stop-loss/take-profit lines and boxes for a defined horizon (PNL Length, default 6 bars) and computes targets using a Risk:Reward ratio (default 2:1).
- Visuals:
- Lines: entry, stop-loss, and target levels.
- Boxes: colored areas representing risk and reward zones.
- Labels (optional): “BUY” for long signals and “SELL” for short signals.
- Inputs:
- Doji body percentage threshold (dojiPct)
- Risk:Reward ratio (riskRewardRatio)
- PNL display toggle (showPNL) and length (pnlLength)
- Signal labels toggle (showLabels)
- Alerts: Generates_alerts for Doji breakout BUY and SELL signals.
Pine Script® インジケーター






















