Pin Bar Bollinger Script

← All 56 scripts

  • Price action
  • On price
  • Intermediate

Marks a pin bar whose long wick reaches an outer Bollinger Band and whose body closes back inside. The band shows where price is stretched; the pin bar shows that the stretch was rejected.

  • File iqow-pin-bar-bollinger.lua
  • Version 1.0.0
  • Size 159 lines · 5 KB
  • Timeframes 1-minute to 5-minute candles
  • License MIT
Pin Bar Bollinger 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

A candle has a lower wick of at least 2x its body and at least 60% of its range, its low touches or pierces the lower Bollinger Band (20, 2), and it closes above that band.

LOWER marker

A candle has an upper wick of at least 2x its body and at least 60% of its range, its high touches or pierces the upper Bollinger Band (20, 2), and it closes below that band.

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

The blue lines are the Bollinger Bands. A green HIGHER triangle under a candle marks a bullish pin bar rejecting the lower band; a red LOWER triangle above a candle marks a shooting-star pin bar rejecting the upper band.

Indicators used

  • Bollinger Bands (20, 2)
  • Pin bar candle geometry

Same view with built-in indicators: Add Bollinger Bands (20, 2) and look for candles with a long wick at the outer band and a small body that closes inside it.

Default settings

Bollinger period20
Deviation2
Wick to body ratio2
Wick share of range0.6

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

Key points

  1. A pin bar is a candle with a long wick and a small body. The wick shows price pushed out and was pushed back.
  2. In this script the wick must be at least twice the body and at least 60 percent of the candle's range.
  3. The pin bar only counts when the wick reaches a Bollinger Band, so the rejection happens at a stretched price.
  4. The candle must also close back inside the band.
  5. Long lower wick at the lower band is marked HIGHER, long upper wick at the upper band is marked LOWER.
  6. Zero-range candles are ignored, and markers use completed candles.

Limitations. In a strong trend price can walk along the band and a rejection wick may be followed by another push in the same direction. The ratios are a strict reading of the pin bar; the article describes the pattern only in general terms, so the exact thresholds are this script's choice. 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: a66363eeb58a38afa215602611647c29a86e89f68950d98fb9ab293246459871

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Pin Bar Bollinger v1.0.0
--
-- A pin bar is a candle with a long wick and a small body: price pushed out and
-- was rejected. Here the rejection must happen at the outer Bollinger Band.
-- Geometry (inputs): the wick must be at least 2x the body and at least 60% of
-- the whole candle range. Zero-range candles are ignored.
--
-- HIGHER: bullish pin bar (long lower wick) whose low touches or pierces the
--         lower Bollinger Band (20, 2) and which closes back inside the band.
-- LOWER:  shooting-star pin bar (long upper wick) whose high touches or pierces
--         the upper band and which closes back inside the band.
--
-- 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 Pin Bar Bollinger",
    short_name = "IQOW PIN BB",
    overlay = true
}

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

input_group {
    "2. Pin bar geometry",
    wick_to_body = input (2, "Wick at least X times the body", input.double, 1, 10, 0.5, false),
    wick_share = input (0.6, "Wick at least this share of the range", input.double, 0.4, 0.95, 0.05, false)
}

input_group {
    "Display and advice",
    lines_visible = input { default = true, type = input.plot_visibility },
    middle_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",
    band_color = input { default = "#56CEFF", type = input.color },
    band_fill_color = input { default = rgba(86, 206, 255, 0.06), type = input.color },
    middle_color = input { default = rgba(255, 255, 255, 0.35), 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 }
}

-- Candle geometry. A pin bar has a long wick on one side and a small body.
local open_now = get_value (open, nil)
local high_now = get_value (high, nil)
local low_now = get_value (low, nil)
local close_now = get_value (close, nil)

middle_band = sma (close, bb_period)
band_offset = stdev (close, bb_period) * bb_deviation
upper_band = middle_band + band_offset
lower_band = middle_band - band_offset

local upper_now = get_value (upper_band, nil)
local lower_now = get_value (lower_band, nil)

local data_is_ready =
    open_now ~= nil and high_now ~= nil and low_now ~= nil and close_now ~= nil and
    upper_now ~= nil and lower_now ~= nil

local candle_range = 0
local body_size = 0
local lower_wick = 0
local upper_wick = 0
if data_is_ready then
    candle_range = high_now - low_now
    body_size = math.abs (close_now - open_now)
    lower_wick = math.min (open_now, close_now) - low_now
    upper_wick = high_now - math.max (open_now, close_now)
end
local has_range = candle_range > 1e-10

local bullish_pin =
    data_is_ready and has_range and
    lower_wick >= wick_to_body * body_size and
    lower_wick >= wick_share * candle_range

local bearish_pin =
    data_is_ready and has_range and
    upper_wick >= wick_to_body * body_size and
    upper_wick >= wick_share * candle_range

-- The rejection wick reaches the band, and the candle closes back inside it.
higher_setup = conditional (bullish_pin and low_now <= lower_now and close_now > lower_now)
lower_setup = conditional (bearish_pin and high_now >= upper_now and close_now < upper_now)

-- 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 lines_visible then
    fill (upper_band, lower_band, "Bollinger area", band_fill_color)
    plot (upper_band, "Upper band", band_color, line_width)
    plot (lower_band, "Lower band", band_color, line_width)
end

if middle_visible then
    plot (middle_band, "Middle band (SMA)", middle_color, 1)
end

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

    plot_shape (
        confirmed_lower,
        "PIN BB 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 price action scripts

  • Price action
  • On price
  • Beginner

Inside Bar Breakout

Marks the first close beyond the mother bar after an inside bar, within 3 candles and in the direction of EMA 50. The inside bar shows a pause; the breakout shows which way it resolved.

Indicators: Inside bar pattern · EMA (50)

  • Price action
  • On price
  • Intermediate

Pin Bar Inside Bar

Finds the pin bar and inside bar combo from the related article: a rejection candle followed by a candle that stays inside its range. The marker appears when price then closes beyond the pin bar in the direction of its wick.

Indicators: Pin bar candle geometry · Inside bar pattern

  • Price action
  • On price
  • Intermediate

RSI EMA200 Engulfing

Marks an engulfing candle that agrees with the long-term EMA 200 side and the RSI 50 midline. The EMA and RSI filter out engulfing candles that go against the broader direction.

Indicators: EMA (200) · RSI (14, midline 50) · Engulfing candle

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.