OPEN-SOURCE SCRIPT
Inside Candle Positional Strategy

Introduction
This strategy implements a structured Inside Candle breakout model designed to capture expansion moves following short-term price compression.
An inside candle represents a temporary contraction in volatility, where the entire range of the current bar is contained within the previous bar. The preceding bar becomes the Mother Candle, and its range defines the potential breakout boundaries.
The model focuses purely on price structure and predefined risk parameters rather than trend-following overlays or momentum filters.
Core Logic and Structure
Inside Candle Detection
An inside candle is defined as:
Current High < Previous High
Current Low > Previous Low
When this condition occurs, the previous bar is marked as the Mother Candle. Only one breakout attempt is allowed per identified structure to prevent repeated entries within the same consolidation phase.
Trade Entry Rules
Entries are executed at market on confirmed bar close.
Long Position
Close > Mother Candle High
No active position
Short Position
Close < Mother Candle Low
No active position
This ensures breakout confirmation rather than anticipatory positioning.
Risk Management Framework
Risk control is fully rule-based and determined at the moment of entry.
For each trade:
Initial Stop Loss = Opposite boundary of the Mother Candle
Risk = Distance between entry price and initial stop
Target = Entry ± (Risk × Risk-Reward Ratio)
The Risk-Reward Ratio is user configurable.
Only one position is active at any time (pyramiding disabled).
Optional ATR-Based Trailing Stop
An optional trailing mechanism may be enabled:
Trailing Stop updates on every confirmed bar.
Calculated using ATR × Multiplier.
Moves only in the direction of profit.
Never worsens beyond the initial stop level.
If disabled, exits rely solely on the fixed stop and target.
Execution Model
All signals are calculated on confirmed bar closes.
Entries are market orders.
Stop and target levels are evaluated using bar OHLC values.
No repainting logic is used.
No intrabar order sequencing assumptions are applied.
Backtest performance may differ from live execution due to slippage, spread, liquidity, and market conditions.
Visual Components
Inside candles are highlighted (default: yellow).
Entry, Initial Stop, Trailing Stop (if enabled), and Target levels are displayed using line-break formatting for clarity.
Designed to maintain structural visibility without excessive chart clutter.
Strategy Defaults
Initial Capital: $1000
Commission: 0.05%
Position Size: 1 (fixed quantity)
Pyramiding: Disabled
These defaults can be adjusted in the Strategy Properties panel.
Intended Application
This strategy is suited for studying breakout behavior after short-term consolidation phases.
Performance characteristics will vary depending on instrument volatility, timeframe, and market regime.
It is presented as a structural breakout framework and should be tested and adapted according to individual risk tolerance and trading objectives.
Disclaimer
Trading involves significant risk. This script is provided for educational and research purposes only and does not constitute financial advice. Users are responsible for evaluating its suitability for their own trading decisions.
This strategy implements a structured Inside Candle breakout model designed to capture expansion moves following short-term price compression.
An inside candle represents a temporary contraction in volatility, where the entire range of the current bar is contained within the previous bar. The preceding bar becomes the Mother Candle, and its range defines the potential breakout boundaries.
The model focuses purely on price structure and predefined risk parameters rather than trend-following overlays or momentum filters.
Core Logic and Structure
Inside Candle Detection
An inside candle is defined as:
Current High < Previous High
Current Low > Previous Low
When this condition occurs, the previous bar is marked as the Mother Candle. Only one breakout attempt is allowed per identified structure to prevent repeated entries within the same consolidation phase.
Trade Entry Rules
Entries are executed at market on confirmed bar close.
Long Position
Close > Mother Candle High
No active position
Short Position
Close < Mother Candle Low
No active position
This ensures breakout confirmation rather than anticipatory positioning.
Risk Management Framework
Risk control is fully rule-based and determined at the moment of entry.
For each trade:
Initial Stop Loss = Opposite boundary of the Mother Candle
Risk = Distance between entry price and initial stop
Target = Entry ± (Risk × Risk-Reward Ratio)
The Risk-Reward Ratio is user configurable.
Only one position is active at any time (pyramiding disabled).
Optional ATR-Based Trailing Stop
An optional trailing mechanism may be enabled:
Trailing Stop updates on every confirmed bar.
Calculated using ATR × Multiplier.
Moves only in the direction of profit.
Never worsens beyond the initial stop level.
If disabled, exits rely solely on the fixed stop and target.
Execution Model
All signals are calculated on confirmed bar closes.
Entries are market orders.
Stop and target levels are evaluated using bar OHLC values.
No repainting logic is used.
No intrabar order sequencing assumptions are applied.
Backtest performance may differ from live execution due to slippage, spread, liquidity, and market conditions.
Visual Components
Inside candles are highlighted (default: yellow).
Entry, Initial Stop, Trailing Stop (if enabled), and Target levels are displayed using line-break formatting for clarity.
Designed to maintain structural visibility without excessive chart clutter.
Strategy Defaults
Initial Capital: $1000
Commission: 0.05%
Position Size: 1 (fixed quantity)
Pyramiding: Disabled
These defaults can be adjusted in the Strategy Properties panel.
Intended Application
This strategy is suited for studying breakout behavior after short-term consolidation phases.
Performance characteristics will vary depending on instrument volatility, timeframe, and market regime.
It is presented as a structural breakout framework and should be tested and adapted according to individual risk tolerance and trading objectives.
Disclaimer
Trading involves significant risk. This script is provided for educational and research purposes only and does not constitute financial advice. Users are responsible for evaluating its suitability for their own trading decisions.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.