OPEN-SOURCE SCRIPT

Inside Candle Positional Strategy

144
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.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.