iqow-keltner-reentry.lua 5 KB · Free, MIT license
For the IQ Option web traderoom. Quadcode does not draw HIGHER and LOWER markers on mobile.
Add it to IQ Option in 3 steps
- Get the file. Press Get the script. Your browser saves a .lua file.
- Import it in IQ Option. Open the web traderoom on the Practice balance. Click the wave icon at the bottom left of the chart, open the Scripts tab, press Import script and pick the file.
- Add it to the chart. The code opens in an editor. Click the plus button under it (Add to chart). Save is only needed after you edit the code.
Full illustrated guide, with screenshots →
Risk. Trading can lose money. A marker is a chart observation, not a prediction, and this script is checked on test data, not proven in live trading. Try it on the Practice balance first.
- Reversal
- On price
- Beginner
Marks the candle that closes back inside the Keltner Channel after the previous candle closed outside it. The channel width follows volatility, so a close outside it shows an unusually stretched move.
The rules
HIGHER marker
The previous close was below the lower Keltner band (EMA 20 of hlc3, 2 x ATR) and the current close is back inside the channel.
LOWER marker
The previous close was above the upper Keltner band and the current close is back inside the channel.
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 green lines are the upper and lower Keltner bands with the EMA in the middle. A green HIGHER triangle under a candle means price closed below the lower band and then closed back inside; a red LOWER triangle above a candle is the mirror case at the upper band.
Indicators used
- Keltner Channel (EMA 20, 2 x ATR)
Same view with built-in indicators: Add IQ Option's Keltner Channels with period 20, offset 2 and the Exponential Moving Average as the average type.
Default settings
| Period | 20 |
|---|---|
| ATR multiplier | 2 |
Every value is an input in the script settings. Platform advice is off by default.
Key points
- The Keltner Channel is an EMA with two bands set at a multiple of the average true range.
- A close outside a band means price moved further than the channel's normal range.
- We do not trade the break itself. We wait for the next close back inside the channel.
- A close below the lower band followed by a close back inside is marked HIGHER; the upper band gives LOWER.
- The marker is drawn after the candle closes and does not repaint.
- Watch on the Practice balance how it behaves when price trends along the band.
Limitations. In a strong trend price can close outside the band several times in a row and re-enter only briefly before pushing out again, so a re-entry is not a reversal by itself. The center line also lags in fast markets. Test on the Practice balance before risking real funds.
Complete source code
The download and this preview resolve to the same reviewed file. SHA-256: b1d5cae25ace0e895bcff4df6ebf07695a696496750f5df5b461986d9232a117
-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Keltner Re-entry v1.0.0
--
-- Keltner Channel: EMA of the typical price (hlc3) in the middle, with bands
-- set a multiple of ATR (RMA of the true range) above and below, as in the
-- official Quadcode Keltner Channels script. A close outside a band shows
-- stretched price; the next close back inside is the marked event.
--
-- HIGHER: the previous close was below the lower band and the current close
-- is back inside the channel.
-- LOWER: the previous close was above the upper band and the current close
-- is back inside the channel.
--
-- 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 Keltner Re-entry",
short_name = "IQOW KC REENT",
overlay = true
}
input_group {
"1. Keltner Channel",
channel_period = input (20, "Period (EMA and ATR)", input.integer, 2, 200),
channel_multiplier = input (2, "ATR multiplier", input.double, 0.1, 10, 0.1)
}
input_group {
"Display and advice",
channel_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",
channel_color = input { default = "#21B190", type = input.color },
middle_color = input { default = rgba(33, 177, 144, 0.6), type = input.color },
channel_fill_color = input { default = rgba(33, 177, 144, 0.08), type = input.color },
channel_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 }
}
-- Keltner Channel as in the official library script.
middle_line = ema (hlc3, channel_period)
band_offset = rma (tr, channel_period) * channel_multiplier
upper_band = middle_line + band_offset
lower_band = middle_line - band_offset
-- Current-bar scalars for the Lua rule logic.
local close_now = get_value (close, nil)
local close_previous = get_value (close [1], nil)
local upper_now = get_value (upper_band, nil)
local lower_now = get_value (lower_band, nil)
local upper_previous = get_value (upper_band [1], nil)
local lower_previous = get_value (lower_band [1], nil)
local has_history = get_value (close [channel_period], nil) ~= nil
local data_is_ready =
has_history and
close_now ~= nil and
close_previous ~= nil and
upper_now ~= nil and
lower_now ~= nil and
upper_previous ~= nil and
lower_previous ~= nil
-- "Back inside": the current close is between the two bands.
local closes_inside = data_is_ready and close_now > lower_now and close_now < upper_now
-- Event: previous close outside one band, this close back inside.
higher_setup = conditional (
closes_inside and close_previous < lower_previous
)
lower_setup = conditional (
closes_inside and close_previous > upper_previous
)
-- 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 channel_visible then
fill (upper_band, lower_band, "Keltner area", channel_fill_color)
plot (upper_band, "Upper Keltner", channel_color, channel_width)
plot (lower_band, "Lower Keltner", channel_color, channel_width)
end
if middle_visible then
plot (middle_line, "Keltner middle", middle_color, 1)
end
if signals_visible then
plot_shape (
confirmed_higher,
"KC REENT HIGHER",
shape_style.triangleup,
shape_size.small,
higher_color,
shape_location.belowbar,
-1,
"HIGHER",
signal_text_color
)
plot_shape (
confirmed_lower,
"KC REENT 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 reversal scripts
- Reversal
- Own panel
- Intermediate
Fisher Transform Reversal
Marks a Fisher Transform cross of its trigger line while the indicator is in an extreme zone. This is the extreme-then-cross confirmation the related article describes.
Indicators: Ehlers Fisher Transform (10)
- Reversal
- On price
- Beginner
Harami RSI
Marks bullish and bearish harami candle pairs when RSI is in a low or high zone. RSI helps check that the pair follows a push in the opposite direction.
Indicators: Harami candle pair · RSI (14, 40/60)
- Reversal
- Own panel
- Intermediate
KDJ Cross
Marks K/D crosses that happen while the faster J line is already stretched below 20 or above 80. J reaches the extremes first, so the cross after it is used as the timing event.
Indicators: KDJ (9, 3, 3)
Download all 70 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.