- Trend
- On price
- Beginner
Marks the Williams %R cross back out of its oversold or overbought zone, but only when price is on the matching side of the EMA 50. The EMA turns the article's plain %R cross into a pullback-in-trend setup.
The rules
HIGHER marker
The close is above EMA 50 and Williams %R(14) closes above -80 after being at or below -80 on the previous candle.
LOWER marker
The close is below EMA 50 and Williams %R(14) closes below -20 after being at or above -20 on the previous candle.
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 orange line is the EMA 50 that sets the trend side. A green HIGHER triangle under a candle means %R has just left oversold while price is above the EMA; a red LOWER triangle above a candle is the mirror case below the EMA. Williams %R itself is not drawn, so add the native indicator below the chart if you want to see it.
Indicators used
- Williams %R (14, -80/-20)
- EMA (50)
Same view with built-in indicators: Add Williams Percent Range (14) with levels -80 and -20, plus an Exponential Moving Average (50) on the price chart.
Default settings
| Williams %R period | 14 |
|---|---|
| Oversold level | -80 |
| Overbought level | -20 |
| EMA period | 50 |
Every value is an input in the script settings. Platform advice is off by default.
Key points
- Williams %R measures where the close sits inside the recent high-to-low range.
- Below -80 is oversold and above -20 is overbought. The article trades the cross back out of those zones.
- This script adds a trend filter: the EMA 50 on the chart.
- HIGHER needs price above the EMA and %R closing back above -80, a pullback ending inside an uptrend.
- LOWER needs price below the EMA and %R closing back below -20.
- Markers use completed candles. Practise on a Practice balance first.
Limitations. The EMA filter is an addition to the article, which uses only the %R cross. In sideways markets price crosses the EMA often and the filter removes few false setups; in sharp reversals the EMA lags and the marker can come late. Test on the Practice balance before risking real funds.
Install it in four steps
- 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.
- Open Chart Analysis → ScriptsIn the IQ Option traderoom, choose the Practice balance, open the chart analysis panel, select Scripts and choose Import script.
- Save and add to chartSelect the downloaded file, review the imported code, choose Save, then use the + control to add it to the chart.
- 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: 41006c16f3f24a808e4af28a08cdcdcc39398a114cb47a78eafb707104345b13
-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Williams R EMA Pullback v1.0.0
--
-- Williams %R(14) shows when price closes near the top or bottom of its recent
-- range. A cross back out of the extreme zone, taken only in the direction of
-- the EMA 50 trend, marks the end of a pullback. The article's plain %R rule
-- (cross over -80 or under -20) is filtered by the EMA.
--
-- HIGHER: close is above EMA 50 and %R closes above -80 after being at or below it.
-- LOWER: close is below EMA 50 and %R closes below -20 after being at or above it.
--
-- 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 Williams R EMA Pullback",
short_name = "IQOW WR EMA",
overlay = true
}
input_group {
"1. Williams %R",
wpr_period = input (14, "Period", input.integer, 2, 100),
oversold_level = input (-80, "Oversold level", input.double, -99, -55, 1, false),
overbought_level = input (-20, "Overbought level", input.double, -45, -1, 1, false)
}
input_group {
"2. Trend filter",
ema_period = input (50, "EMA period", input.integer, 2, 400)
}
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",
ema_color = input { default = "#FFB800", type = input.color },
line_width = input { default = 2, 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 }
}
trend_ema = ema (close, ema_period)
-- Williams %R: 0 at the highest high, -100 at the lowest low of the period.
range_high = highest (high, wpr_period)
range_low = lowest (low, wpr_period)
wpr = 100 * (close - range_high) / max (range_high - range_low, 1e-10)
local close_now = get_value (close, nil)
local ema_now = get_value (trend_ema, nil)
local wpr_now = get_value (wpr, nil)
local wpr_before = get_value (wpr [1], nil)
local range_now = get_value (range_high - range_low, nil)
local levels_are_valid = oversold_level < overbought_level
local data_is_ready =
levels_are_valid and
close_now ~= nil and ema_now ~= nil and
wpr_now ~= nil and wpr_before ~= nil and
range_now ~= nil and range_now > 1e-10 and
get_value (trend_ema [ema_period], nil) ~= nil
-- Event: %R crosses back out of the zone on this candle, with the trend.
local wpr_leaves_oversold = data_is_ready and wpr_before <= oversold_level and wpr_now > oversold_level
local wpr_leaves_overbought = data_is_ready and wpr_before >= overbought_level and wpr_now < overbought_level
higher_setup = conditional (wpr_leaves_oversold and close_now > ema_now)
lower_setup = conditional (wpr_leaves_overbought and close_now < ema_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
plot (trend_ema, "EMA", ema_color, line_width)
end
if signals_visible then
plot_shape (
confirmed_higher,
"WR EMA HIGHER",
shape_style.triangleup,
shape_size.small,
higher_color,
shape_location.belowbar,
-1,
"HIGHER",
signal_text_color
)
plot_shape (
confirmed_lower,
"WR EMA 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 trend scripts
- Trend
- Own panel
- Beginner
Aroon Oscillator Zero Cross
Marks the candle where the Aroon Oscillator crosses its zero line. A cross up means the latest 25-candle high is now more recent than the latest low; a cross down means the opposite.
Indicators: Aroon Oscillator (25)
- Trend
- On price
- Beginner
EMA50 CCI 100
Marks the first CCI break beyond +100 or -100 shortly after price crossed the EMA 50 and stayed on that side. The EMA sets the direction and CCI times the entry, at most once per EMA cross.
Indicators: EMA (50) · CCI (14, levels +/-100)
- Trend
- On price
- Advanced
Fractal Alligator
Marks a close through the last confirmed fractal level when that level lies beyond the Alligator teeth. The Alligator gives the trend reference and the fractal gives the breakout level.
Indicators: Williams Fractals (5) · Alligator (13/8/5, shifted 8/5/3)
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.