iqow-kdj-cross.lua 5 KB · Free, MIT license
On assets priced above about 100 (such as JPY pairs) this script's panel can hide its markers, so import the markers file too: it draws them on the price chart.
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
- Own panel
- Intermediate
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.
In the indicator panel the markers are drawn at the candle's price, so on assets priced above about 100 (for example JPY pairs) they fall outside the panel. Load kdj-cross-markers to see the same markers on the price chart.
The rules
HIGHER marker
%K crosses above %D on a candle where %J is below 20.
LOWER marker
%K crosses below %D on a candle where %J is above 80.
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
Orange is %K, green is %D and purple is %J in a separate panel with levels at 20 and 80. A green HIGHER triangle at the bottom of the panel marks %K crossing above %D with %J below 20; a red LOWER triangle at the top marks %K crossing below %D with %J above 80.
Indicators used
- KDJ (9, 3, 3)
Same view with built-in indicators: Add KDJ (9, 3, 3) with levels 20 and 80 from the IQ Option indicator list.
Default settings
| Stochastic period | 9 |
|---|---|
| K smoothing | 3 |
| D period | 3 |
| Low level (J) | 20 |
| High level (J) | 80 |
Every value is an input in the script settings. Platform advice is off by default.
Key points
- KDJ is a stochastic oscillator with a third, faster line called J.
- K is the smoothed stochastic, D is its average, and J exaggerates the gap between them.
- When J is below 20 or above 80, the market is stretched in that direction.
- We wait for K to cross D: above it with J below 20 is HIGHER, below it with J above 80 is LOWER.
- The markers sit in the indicator panel and confirm on a completed candle.
- Use a Practice balance to see how it behaves in trending versus sideways markets.
Limitations. The J line can stay beyond 20 or 80 for a long time in a strong trend, so a K/D cross there may be an early or a short-lived turn. The settings here are the official 9, 3 and 3; shorter periods give more markers and more noise. 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: 2fcb90b6bdea0c1741d574817eb1dc44fb0df0c8df46bd871c30402ad5cee0b4
-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW KDJ Cross v1.0.1
--
-- KDJ extends the stochastic oscillator: K is the smoothed stochastic, D is
-- its moving average and J = 3K - 2D reacts faster than both. A K/D cross
-- with J already stretched marks a possible turn. K follows the KDJ panel
-- IQ Option draws. Drawn in its own panel.
--
-- The Stochastic follows IQ Option's built-in Stochastic Oscillator: the close
-- against the highest high and the lowest low of the %K period. Version 1.0.1
-- (9 October 2026) changed this from the highest and lowest close; the inputs,
-- periods and levels are unchanged.
--
-- HIGHER: K crosses above D while J is below 20.
-- LOWER: K crosses below D while J is above 80.
--
-- 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 KDJ Cross",
short_name = "IQOW KDJ",
overlay = false
}
input_group {
"1. KDJ settings",
k_period = input (9, "Stochastic period", input.integer, 2, 100),
k_smooth = input (3, "K smoothing", input.integer, 1, 50),
d_period = input (3, "D period", input.integer, 1, 50)
}
input_group {
"2. Levels",
low_level = input (20, "Low level (J)", input.double, 0, 45, 1, false),
high_level = input (80, "High level (J)", input.double, 55, 100, 1, false)
}
input_group {
"Display and advice",
lines_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",
k_color = input { default = "#FF7700", type = input.color },
d_color = input { default = "#25E154", type = input.color },
j_color = input { default = "#B42EFF", type = input.color },
level_low_color = input { default = rgba(255, 108, 88, 0.5), type = input.color },
level_high_color = input { default = rgba(37, 225, 84, 0.5), 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 }
}
-- KDJ: K = smoothed stochastic (0-100), D = SMA of K, J = 3K - 2D.
-- Stochastic as IQ Option's KDJ panel draws it: the close against the
-- highest high and lowest low of the %K period (not the highest and lowest
-- close), 50 when that range is zero. %K is that value smoothed with an SMA and
-- multiplied by 100; %D is an SMA of %K.
kdj_low = lowest (low, k_period)
kdj_range = highest (high, k_period) - kdj_low
kdj_raw = iff (kdj_range > 0, (close - kdj_low) / kdj_range, kdj_range + 0.5)
k_line = sma (kdj_raw, k_smooth) * 100
d_line = sma (k_line, d_period)
j_line = 3 * k_line - 2 * d_line
-- Current-bar scalars for the Lua rule logic.
local k_now = get_value (k_line, nil)
local k_before = get_value (k_line [1], nil)
local d_now = get_value (d_line, nil)
local d_before = get_value (d_line [1], nil)
local j_now = get_value (j_line, nil)
local data_is_ready =
low_level < high_level and
k_now ~= nil and
k_before ~= nil and
d_now ~= nil and
d_before ~= nil and
j_now ~= nil and
get_value (d_line [k_period + k_smooth], nil) ~= nil
-- Event: K crosses D on this candle while J is stretched.
higher_setup = conditional (
data_is_ready and k_before <= d_before and k_now > d_now and j_now < low_level
)
lower_setup = conditional (
data_is_ready and k_before >= d_before and k_now < d_now and j_now > high_level
)
-- 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)
)
hline { value = high_level, color = level_high_color, width = 1 }
hline { value = low_level, color = level_low_color, width = 1 }
if lines_visible then
plot (k_line, "%K", k_color, line_width)
plot (d_line, "%D", d_color, line_width)
plot (j_line, "%J", j_color, line_width)
end
if signals_visible then
plot_shape (
confirmed_higher,
"KDJ HIGHER",
shape_style.triangleup,
shape_size.small,
higher_color,
shape_location.bottom,
-1,
"HIGHER",
signal_text_color
)
plot_shape (
confirmed_lower,
"KDJ LOWER",
shape_style.triangledown,
shape_size.small,
lower_color,
shape_location.top,
-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
- On price
- Beginner
Bollinger RSI Reversal
Marks the first candle that closes back inside the Bollinger Bands after a close outside a band with RSI in its oversold or overbought zone. The bands show how stretched price is and RSI adds a second view of the same stretch.
Indicators: Bollinger Bands (20, 2) · RSI (14, 30/70)
- Reversal
- Own panel
- Beginner
DeMarker 30 70 Cross
Marks the candle where DeMarker closes back out of its oversold or overbought zone. The 30 and 70 levels are the ones used in the related guide.
Indicators: DeMarker (14, levels 30/70)
- Reversal
- On price
- Beginner
Donchian RSI Reversal
Marks the moment RSI leaves its oversold or overbought zone after price touched the matching Donchian band in the same excursion. The channel shows where price is stretched; RSI shows when momentum starts to turn.
Indicators: Donchian Channel (20) · RSI (14, 30/70)
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.