iqow-supertrend-ema200.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.
- Trend
- On price
- Intermediate
Marks Supertrend direction flips only when the candle closes on the same side of the 200-period EMA. The EMA acts as a simple long-term bias filter for the Supertrend flip.
The rules
HIGHER marker
Supertrend(10, 3) flips from down to up on a candle that closes above EMA 200; the marker confirms on the previous completed candle.
LOWER marker
Supertrend(10, 3) flips from up to down on a candle that closes below EMA 200; the marker confirms on the previous completed 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 Supertrend line is green below price in an uptrend and red above price in a downtrend; the amber line is EMA 200. A green HIGHER triangle appears under the candle where the line turned green above the EMA, and a red LOWER triangle appears above the candle where it turned red below the EMA.
Indicators used
- Supertrend (10, 3)
- EMA (200)
Same view with built-in indicators: Add IQ Option's Supertrend (period 10, multiplier 3) and Exponential Moving Average (200).
Default settings
| ATR period | 10 |
|---|---|
| ATR multiplier | 3 |
| EMA period | 200 |
Every value is an input in the script settings. Platform advice is off by default.
Key points
- Supertrend draws a trailing line from the average true range: green under price in an uptrend, red above price in a downtrend.
- On its own it flips often, so we add a filter: the 200-period moving average.
- A HIGHER marker needs two things: the line just flipped to up, and the candle closes above EMA 200.
- A LOWER marker is the mirror: the line flipped to down, and the close is below EMA 200.
- Flips against the long-term side are ignored, which removes some noise but not all of it.
- Markers confirm on a completed candle; try them on a Practice balance first.
Limitations. Supertrend flips often in sideways markets, and the EMA 200 reacts slowly, so a flip can arrive late or be followed by an immediate reversal. EMA 200 needs 200 candles of history, so no markers appear on a freshly loaded short chart. The default ATR period is 10 (the official built-in indicator defaults to 7). 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: 7f3f7a25919d88dcc40dea1ef278d73f67086da7c44b1003ffdbeded94e0149b
-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Supertrend EMA 200 v1.0.0
--
-- Supertrend (ATR trailing line) shows when the short-term trend flips. An
-- EMA 200 filter keeps only the flips that agree with the longer-term side
-- of price. Supertrend uses the same formula as the official IQ Option one.
--
-- HIGHER: Supertrend flips from down to up on a candle that closes above EMA 200.
-- LOWER: Supertrend flips from up to down on a candle that closes below EMA 200.
--
-- 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 Supertrend EMA 200",
short_name = "IQOW ST EMA",
overlay = true
}
input_group {
"1. Supertrend",
atr_period = input (10, "ATR period", input.integer, 1, 100),
atr_multiplier = input (3, "ATR multiplier", input.double, 0.5, 10, 0.1, false)
}
input_group {
"2. Trend filter",
ema_period = input (200, "EMA period", input.integer, 2, 500)
}
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",
supertrend_up_color = input { default = "#25E154", type = input.color },
supertrend_down_color = input { default = "#FF6C58", type = input.color },
ema_color = input { default = "#FFB020", 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 }
}
-- Supertrend, same recursion as the official library indicator.
band_offset = rma (tr, atr_period) * atr_multiplier
raw_up = hl2 - band_offset
raw_down = hl2 + band_offset
trail_up = iff (not na (trail_up) and close [1] > trail_up [1], max (raw_up, trail_up [1]), raw_up)
trail_down = iff (not na (trail_down) and close [1] < trail_down [1], min (raw_down, trail_down [1]), raw_down)
-- true = uptrend, false = downtrend; it keeps its last value between flips.
trend_is_up = iff (close > trail_down [1], true, iff (close < trail_up [1], false, nz (trend_is_up [1], true)))
supertrend_line = iff (trend_is_up, trail_up, trail_down)
ema_filter = ema (close, ema_period)
-- Current-bar scalars for the Lua rule logic.
local trend_now = get_value (trend_is_up, nil)
local trend_before = get_value (trend_is_up [1], nil)
local close_now = get_value (close, nil)
local ema_now = get_value (ema_filter, nil)
local trail_before = get_value (trail_up [1], nil)
-- EMA needs its full length of history before the filter means anything.
local data_is_ready =
trend_now ~= nil and
trend_before ~= nil and
close_now ~= nil and
trail_before ~= nil and
get_value (ema_filter [ema_period], nil) ~= nil
-- Event: the trend flips on this candle, on the correct side of the EMA.
higher_setup = conditional (
data_is_ready and trend_now and not trend_before and close_now > ema_now
)
lower_setup = conditional (
data_is_ready and not trend_now and trend_before 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 (supertrend_line, "Supertrend", get_value (trend_is_up, true) and supertrend_up_color or supertrend_down_color, line_width)
plot (ema_filter, "EMA filter", ema_color, line_width)
end
if signals_visible then
plot_shape (
confirmed_higher,
"ST EMA HIGHER",
shape_style.triangleup,
shape_size.small,
higher_color,
shape_location.belowbar,
-1,
"HIGHER",
signal_text_color
)
plot_shape (
confirmed_lower,
"ST 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
- 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)
- Trend
- On price
- Beginner
Heikin Ashi EMA
Marks the first bullish or bearish Heikin-Ashi candle after a run of two opposite candles, only when price closes on the matching side of EMA 50. Heikin-Ashi is calculated inside the script, so the chart can stay on regular candles.
Indicators: Heikin-Ashi candles (calculated) · EMA (50)
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.