Comprehensive documentation for TradingView Pine Script indicators and trading strategies
Inside candle patterns identify consolidation periods where one candle is completely contained within the previous candle’s range. These patterns often precede significant price moves and are valuable for identifying potential breakout setups.
Condition: Previous week’s high is lower than 2 weeks ago high, AND previous week’s low is higher than 2 weeks ago low
Formula:
isInsideWeekCandle = (prior_week_high < twoPriorWeekHigh and
prior_week_low > twoPriorWeekLow)
Visual: Purple background in top-right table Display: Shows week high/low range when detected
Condition: 2 bars ago high/low contains previous bar’s high/low
Formula:
isInsideCandle = (twoPriorthirtyMinHigh >= prevThirtyMinHigh and
twoPriorthirtyMinLow <= prevThirtyMinLow)
Default Timeframe: 30-min (configurable) Visual: Shows in top-right table with timeframe label
insideCandleTimeframe (default: ‘30’)// Weekly data
[prior_week_high, prior_week_low, twoPriorWeekHigh, twoPriorWeekLow] =
request.security(syminfo.tickerid, 'W',
[high[1], low[1], high[2], low[2]],
lookahead=barmerge.lookahead_on)
// Configurable timeframe data
twoPriorthirtyMinHigh = request.security(syminfo.tickerid,
insideCandleTimeframe, high[2])
twoPriorthirtyMinLow = request.security(syminfo.tickerid,
insideCandleTimeframe, low[2])
prevThirtyMinHigh = request.security(syminfo.tickerid,
insideCandleTimeframe, high[1])
prevThirtyMinLow = request.security(syminfo.tickerid,
insideCandleTimeframe, low[1])