Pin Bar Inside Bar Script

← All 56 scripts

  • Price action
  • On price
  • Intermediate

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.

  • File iqow-pin-bar-inside-bar.lua
  • Version 1.0.0
  • Size 182 lines · 6 KB
  • Timeframes 5-minute candles
  • License MIT
Pin Bar Inside Bar 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 bullish pin bar (lower wick at least 2x body and 50% of range) is followed by an inside bar, and within 4 further candles a candle closes above the pin bar's high.

LOWER marker

A bearish pin bar (upper wick at least 2x body and 50% of range) is followed by an inside bar, and within 4 further candles a candle closes below the pin bar's low.

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

Small green and red dots mark the high of bullish pin bars and the low of bearish pin bars; the dot is the level that must break. A HIGHER or LOWER triangle appears on the candle that closed beyond that level after the inside bar.

Indicators used

  • Pin bar candle geometry
  • Inside bar pattern

Same view with built-in indicators: No native indicator; spot the pattern manually: a pin bar, an inside bar within its range, then a close beyond the pin bar.

Default settings

Wick to body ratio2
Wick share of range0.5
Breakout window (candles)4

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

Key points

  1. The combo has three parts: a pin bar, an inside bar, then a breakout candle.
  2. The pin bar has a long wick and a small body. The wick points against the direction we want.
  3. The next candle is an inside bar: its high and low stay inside the pin bar's range.
  4. We then wait for a close beyond the pin bar's far side, up for a bullish pin, down for a bearish pin.
  5. The dots show the pin bars, so you can see which candle started the pattern.
  6. The article also checks support and resistance. Draw those levels yourself and test on a Practice balance.

Limitations. The article adds a support or resistance level to the combo, which this script does not draw, so many markers will sit in the middle of a range. The pin bar thresholds (wick at least half the range, looser than the 60% in the Pin Bar Bollinger script) and the 4-candle breakout window are this script's own precise reading of the article's general description, and the inside-pin continuation pattern is not covered. 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: 4ace6f79134ff934c916777ac6449a2e3d1cf5b171a9541f5a533a7296058661

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Pin Bar Inside Bar v1.0.0
--
-- Pin bar and inside bar combo. A pin bar (long wick, small body) shows price
-- rejection. The next candle is an inside bar: its whole range sits within the
-- pin bar's range, a pause before the move. The setup completes when a candle
-- closes beyond the pin bar's far side, in the direction of the pin.
-- Pin geometry (inputs): wick at least 2x the body and at least 50% of the range.
--
-- HIGHER: bullish pin bar (long lower wick), then an inside bar, then within
--         the breakout window a candle closes above the pin bar's high.
-- LOWER:  bearish pin bar (long upper wick), then an inside bar, then within
--         the breakout window a candle closes below the pin bar's low.
--
-- 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 Inside Bar",
    short_name = "IQOW PIN IB",
    overlay = true
}

input_group {
    "1. 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.5, "Wick at least this share of the range", input.double, 0.4, 0.95, 0.05, false)
}

input_group {
    "2. Combo timing",
    breakout_window = input (4, "Breakout window after the inside bar (candles)", input.integer, 1, 6)
}

input_group {
    "Display and advice",
    pins_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",
    bullish_pin_color = input { default = "#25E154", type = input.color },
    bearish_pin_color = input { default = "#FF6C58", type = input.color },
    pin_width = input { default = 3, 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)

local data_is_ready = open_now ~= nil and high_now ~= nil and low_now ~= nil and close_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

bullish_pin = conditional (
    data_is_ready and has_range and
    lower_wick >= wick_to_body * body_size and
    lower_wick >= wick_share * candle_range
)

bearish_pin = conditional (
    data_is_ready and has_range and
    upper_wick >= wick_to_body * body_size and
    upper_wick >= wick_share * candle_range
)

-- Look back for a pin bar followed by an inside bar. The pin bar sits "back"
-- candles ago, the inside bar right after it. No candle since the pin bar may
-- have closed beyond its far side already, so only the first breakout counts.
local bullish_combo = false
local bearish_combo = false

if data_is_ready then
    for back = 2, breakout_window + 1 do
        local pin_high = get_value (high [back], nil)
        local pin_low = get_value (low [back], nil)
        local inside_high = get_value (high [back - 1], nil)
        local inside_low = get_value (low [back - 1], nil)

        if pin_high ~= nil and pin_low ~= nil and inside_high ~= nil and inside_low ~= nil and
            inside_high <= pin_high and inside_low >= pin_low then
            local broke_up_before = false
            local broke_down_before = false
            for later = 1, back - 1 do
                local later_close = get_value (close [later], nil)
                if later_close == nil or later_close > pin_high then
                    broke_up_before = true
                end
                if later_close == nil or later_close < pin_low then
                    broke_down_before = true
                end
            end

            if get_value (bullish_pin [back], false) and not broke_up_before and close_now > pin_high then
                bullish_combo = true
            end
            if get_value (bearish_pin [back], false) and not broke_down_before and close_now < pin_low then
                bearish_combo = true
            end
        end
    end
end

higher_setup = conditional (bullish_combo)
lower_setup = conditional (bearish_combo)

-- 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)
)

-- Dots on the pin bars themselves (pin high for bullish, pin low for bearish),
-- so the chart shows which candle started the combo.
if pins_visible then
    plot (iff (bullish_pin, high, nil), "Bullish pin high", bullish_pin_color, pin_width, 0, style.points)
    plot (iff (bearish_pin, low, nil), "Bearish pin low", bearish_pin_color, pin_width, 0, style.points)
end

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

    plot_shape (
        confirmed_lower,
        "PIN IB 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

Three Candles Continuation

Marks the candle that completes three same-colour full-bodied candles with steady closes while price is on the matching side of EMA 20. An option flips the reading to the counter-trend idea described in the article.

Indicators: Three full candles · EMA (20)

  • 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 Bollinger

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.

Indicators: Bollinger Bands (20, 2) · Pin bar candle geometry

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.