Bollinger Keltner Squeeze Script

← All 56 scripts

  • Volatility
  • On price
  • Intermediate

Marks the first candle after a Bollinger-inside-Keltner squeeze of at least 6 candles ends, with Momentum showing which side price is leaning. The squeeze shows quiet volatility; Momentum adds a direction.

  • File iqow-bollinger-keltner-squeeze.lua
  • Version 1.0.0
  • Size 160 lines · 5 KB
  • Timeframes 1-minute to 15-minute candles
  • License MIT
Bollinger Keltner Squeeze drawn on synthetic candles
How the script draws, shown on synthetic candles generated for testing. It is an illustration of the markers and lines, not real market data or a result.

The rules

HIGHER marker

After Bollinger Bands (20, 2) have stayed inside the Keltner Channel (20, 1.5 x ATR) for at least 6 candles, the first candle where they are no longer inside, with Momentum(12) above zero, is marked HIGHER.

LOWER marker

On the same squeeze release candle, with Momentum(12) below zero, the candle is marked LOWER.

A marker appears after the next candle opens and is drawn on the candle that completed the setup. It is a chart observation, not an instruction to trade.

How to read it

Blue lines are the Bollinger Bands and orange lines are the Keltner Channel. When the blue lines sit inside the orange ones the market is in a squeeze. A green HIGHER or red LOWER marker appears on the candle where the squeeze released, coloured by the Momentum side.

Indicators used

  • Bollinger Bands (20, 2)
  • Keltner Channel (20, 1.5 ATR)
  • Momentum (12)

Same view with built-in indicators: Add Bollinger Bands (20, 2), Keltner Channels (20, multiplier 1.5) and Momentum (12), and watch for the bands leaving the channel.

Default settings

Bollinger period20
Bollinger deviation2
Keltner period20
Keltner ATR multiplier1.5
Minimum squeeze length6
Momentum period12

Every value is an input in the script settings. Platform advice is off by default.

Key points

  1. Bollinger Bands widen with volatility; the Keltner Channel is built from ATR.
  2. When the Bollinger Bands slip inside the Keltner Channel, the market is in a squeeze.
  3. We wait for a squeeze of at least six candles, then watch for the first candle where it ends.
  4. Momentum above zero marks HIGHER, below zero marks LOWER.
  5. The marker confirms on a completed candle, so it does not repaint.
  6. Practise on the Practice balance and note how often a release fails.

Limitations. The release candle can be a false start, and price may move sideways or reverse after it, so the direction from Momentum is only a lean. The article describes breakouts from support and resistance in general terms; the squeeze rule and its defaults are this library's own adaptation. Test on the Practice balance before risking real funds.

Learn the strategy: read the full guide on IQOptionWiki →

Install it in four steps

  1. Download and inspectDownload one .lua file and open it in a plain-text editor if you want to read it first. If you downloaded the ZIP, extract it.
  2. Open Chart Analysis → ScriptsIn the IQ Option traderoom, choose the Practice balance, open the chart analysis panel, select Scripts and choose Import script.
  3. Save and add to chartSelect the downloaded file, review the imported code, choose Save, then use the + control to add it to the chart.
  4. Change one input at a timeConfirm the default view first. Then adjust periods, levels or colours one setting at a time and note what changes.

Complete source code

The download and this preview resolve to the same reviewed file. SHA-256: 4deb04daecb528411537dba07e3403e5876c43bd9ea0886c9f4590796f66f2a6

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Bollinger Keltner Squeeze v1.0.0
--
-- A squeeze is a quiet period in which the Bollinger Bands sit inside the
-- Keltner Channel (standard deviation is smaller than ATR). Long squeezes
-- are often followed by a breakout, so the script waits for the squeeze to
-- end and uses Momentum to show the side price is leaning towards.
--
-- HIGHER: the squeeze lasted at least N candles, this is the first candle
--         after it ended, and Momentum (close - close N bars ago) is above 0.
-- LOWER:  same release candle, and Momentum is below 0.
--
-- Markers use the previous completed candle: they appear after the next candle
-- opens and are shifted back one bar onto the candle that qualified.
-- Educational chart tool only. It does not place trades, choose an expiry,
-- predict outcomes, or guarantee results. Test on a Practice balance first.

instrument {
    name = "IQOW Bollinger Keltner Squeeze",
    short_name = "IQOW SQUEEZE",
    overlay = true
}

input_group {
    "1. Bollinger Bands",
    bb_period = input (20, "Bollinger period", input.integer, 2, 200),
    bb_deviation = input (2, "Standard deviation", input.double, 0.5, 5, 0.1, false)
}

input_group {
    "2. Keltner Channel",
    kc_period = input (20, "Keltner period", input.integer, 2, 200),
    kc_multiplier = input (1.5, "ATR multiplier", input.double, 0.5, 5, 0.1, false)
}

input_group {
    "3. Squeeze and momentum",
    min_squeeze_bars = input (6, "Minimum squeeze length (candles)", input.integer, 1, 50),
    momentum_period = input (12, "Momentum period", input.integer, 2, 100)
}

input_group {
    "Display and advice",
    bands_visible = input { default = true, type = input.plot_visibility },
    keltner_visible = input { default = true, type = input.plot_visibility },
    signals_visible = input { default = true, type = input.plot_visibility },
    advice_enabled = input { default = false, name = "Enable platform advice", type = input.boolean }
}

input_group {
    "Colors",
    bb_color = input { default = "#56CEFF", type = input.color },
    kc_color = input { default = "#FFB800", type = input.color },
    line_width = input { default = 1, type = input.line_width },
    higher_color = input { default = "#25E154", type = input.color },
    lower_color = input { default = "#FF6C58", type = input.color },
    signal_text_color = input { default = "#FFFFFF", type = input.color }
}

-- Bollinger Bands (SMA of close, sample standard deviation).
bb_middle = sma (close, bb_period)
bb_upper = bb_middle + bb_deviation * stdev (close, bb_period)
bb_lower = bb_middle - bb_deviation * stdev (close, bb_period)

-- Keltner Channel (EMA of typical price, ATR offset), as in the official library.
kc_middle = ema (hlc3, kc_period)
kc_upper = kc_middle + kc_multiplier * rma (tr, kc_period)
kc_lower = kc_middle - kc_multiplier * rma (tr, kc_period)

momentum_value = close - close [momentum_period]

local bb_upper_now = get_value (bb_upper, nil)
local bb_lower_now = get_value (bb_lower, nil)
local kc_upper_now = get_value (kc_upper, nil)
local kc_lower_now = get_value (kc_lower, nil)
local momentum_now = get_value (momentum_value, nil)

local data_is_ready =
    bb_upper_now ~= nil and
    bb_lower_now ~= nil and
    kc_upper_now ~= nil and
    kc_lower_now ~= nil and
    momentum_now ~= nil

-- Squeeze: both Bollinger bands are inside the Keltner Channel.
local squeeze_is_on =
    data_is_ready and bb_upper_now < kc_upper_now and bb_lower_now > kc_lower_now

-- Length of the current squeeze in candles (0 when there is no squeeze).
squeeze_length = iff (squeeze_is_on, nz (squeeze_length [1]) + 1, 0)

-- Release: no squeeze now, but the previous candle ended a long enough one.
local squeeze_released =
    data_is_ready and
    not squeeze_is_on and
    nz (squeeze_length [1]) >= min_squeeze_bars

higher_setup = conditional (squeeze_released and momentum_now > 0)
lower_setup = conditional (squeeze_released and momentum_now < 0)

-- Confirm only a new setup on the previous completed candle.
confirmed_higher = conditional (
    get_value (higher_setup [1], false) and
    not get_value (higher_setup [2], false)
)

confirmed_lower = conditional (
    get_value (lower_setup [1], false) and
    not get_value (lower_setup [2], false)
)

if bands_visible then
    plot (bb_upper, "Bollinger upper", bb_color, line_width)
    plot (bb_lower, "Bollinger lower", bb_color, line_width)
end

if keltner_visible then
    plot (kc_upper, "Keltner upper", kc_color, line_width)
    plot (kc_lower, "Keltner lower", kc_color, line_width)
end

if signals_visible then
    plot_shape (
        confirmed_higher,
        "Squeeze HIGHER",
        shape_style.triangleup,
        shape_size.small,
        higher_color,
        shape_location.belowbar,
        -1,
        "HIGHER",
        signal_text_color
    )

    plot_shape (
        confirmed_lower,
        "Squeeze LOWER",
        shape_style.triangledown,
        shape_size.small,
        lower_color,
        shape_location.abovebar,
        -1,
        "LOWER",
        signal_text_color
    )
end

-- QCS advice is a platform notification state only; it does not place trades.
if advice_enabled and
    get_value (confirmed_higher, false) and
    not get_value (confirmed_lower, false) then
    advise (advice.buy)
elseif advice_enabled and
    get_value (confirmed_lower, false) and
    not get_value (confirmed_higher, false) then
    advise (advice.sell)
else
    advise (advice.neutral)
end

More volatility scripts

  • Volatility
  • Context indicator
  • Own panel
  • Beginner

Normalized ATR Percent

Expresses Average True Range as a percentage of the current close. Normalizing the value makes volatility readings easier to compare across instruments with different price levels.

Indicators: ATR (14) as % of close

Download all 56 scripts as one ZIP · MIT License, provided “as is”, without warranty. IQOptionWiki is independent of the IQ Option platform operator. Nothing here is investment advice or a guarantee of results.

GENERAL RISK WARNING

The financial products offered by the company carry a high level of risk and can result in the loss of all your funds. You should never invest money that you cannot afford to lose.
Kindly note that this article does not provide any investment advice. The information presented regarding past events or potential future developments is solely an opinion and cannot be guaranteed as factual, including the provided examples. We caution readers accordingly.