RSI Stochastic EMA200 Script

← All 70 scripts

iqow-rsi-stochastic-ema200.lua 6 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

  1. Get the file. Press Get the script. Your browser saves a .lua file.
  2. 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.
  3. 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.

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

Uses the EMA 200 as a trend filter, RSI 50 as a momentum filter and a Stochastic cross out of its extreme zone as the timing. It marks the end of a pullback in the direction of the larger trend.

  • File iqow-rsi-stochastic-ema200.lua
  • Version 1.0.1
  • Size 174 lines · 6 KB
  • Timeframes Any timeframe; the article shows higher timeframes with stop and target
  • License MIT
RSI Stochastic EMA200 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

The close is above EMA(200), RSI(14) is above 50, and Stochastic %K crosses above %D after %K was at or below 20 on the previous candle.

LOWER marker

The close is below EMA(200), RSI(14) is below 50, and Stochastic %K crosses below %D after %K was at or above 80 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 yellow line is the EMA 200 trend filter. A green HIGHER triangle under a candle means price is above the EMA, RSI is above 50 and the Stochastic has just crossed up out of oversold; a red LOWER triangle above a candle is the mirror case below the EMA. RSI and the Stochastic are not drawn on the price chart.

Indicators used

  • EMA (200)
  • RSI (14)
  • Stochastic (14, 3, 3)

Same view with built-in indicators: Add IQ Option's Moving Average of type EMA (200), Relative Strength Index (14) and Stochastic (14, 3, 3, levels 80/20).

Default settings

EMA period200
RSI period14
RSI midline50
Stochastic %K14
Stochastic smoothing3
Stochastic %D3
Oversold20
Overbought80

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

Key points

  1. Step one is the trend: price above the EMA 200 means we only look for HIGHER marks.
  2. Step two is momentum: RSI should be above 50 for HIGHER and below 50 for LOWER.
  3. Step three is timing: the Stochastic %K line crosses %D after sitting in the oversold or overbought zone.
  4. This is a pullback idea: the Stochastic shows the pullback is ending while the trend filter still agrees.
  5. The article also uses RSI divergence by eye; this script uses the RSI 50 side as a simple stand-in.
  6. Marks are confirmed on a completed candle. Try it on a Practice balance.

Limitations. The article uses RSI to spot hidden divergence by eye; the script uses a simple RSI above or below 50 check instead, because divergence cannot be defined exactly in a few lines. RSI and the Stochastic are calculated like IQ Option's built-in versions: RSI with exponential smoothing, the Stochastic from the close and the highest high and lowest low of the %K period. Marks are rare because every condition must agree. Test on the Practice balance before risking real funds.

Learn the strategy: read the full guide on IQOptionWiki →

Complete source code

The download and this preview resolve to the same reviewed file. SHA-256: 8f8659bb10d24c569863f931890cff0cd79c7ecc0dd57d4b70f22b5a73a75c9a

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW RSI Stochastic EMA200 v1.0.1
--
-- Combines three tools as in the related article: the EMA 200 as a trend
-- filter, RSI (14) for the side of 50, and the Stochastic (14, 3, 3) for the
-- entry timing. The Stochastic cross must start from the oversold or overbought
-- zone, so it marks the end of a pullback in the direction of the trend.
--
-- RSI and the Stochastic follow IQ Option's built-in indicators. RSI uses the
-- close with an exponential average of gains and losses (alpha 2 / (period +
-- 1)); the Stochastic compares the close with the highest high and the lowest
-- low of the %K period. Version 1.0.1 (9 October 2026) changed both from
-- Wilder smoothing and highest/lowest close; the inputs, periods and levels
-- are unchanged.
--
-- HIGHER: close is above EMA 200, RSI is above 50, and %K crosses above %D
--         after %K was at or below 20 on the previous candle.
-- LOWER:  close is below EMA 200, RSI is below 50, and %K crosses below %D
--         after %K was at or above 80 on the previous candle.
--
-- 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 RSI Stochastic EMA200",
    short_name = "IQOW RSI STO",
    overlay = true
}

input_group {
    "1. Trend filter and RSI",
    ema_period = input (200, "EMA period", input.integer, 10, 400),
    rsi_period = input (14, "RSI period", input.integer, 2, 100),
    rsi_midline = input (50, "RSI midline", input.double, 30, 70, 1, false)
}

input_group {
    "2. Stochastic",
    k_period = input (14, "%K period", input.integer, 2, 100),
    k_smoothing = input (3, "%K smoothing", input.integer, 1, 20),
    d_period = input (3, "%D period", input.integer, 1, 20),
    oversold_level = input (20, "Oversold level", input.double, 1, 45, 1, false),
    overbought_level = input (80, "Overbought level", input.double, 55, 99, 1, false)
}

input_group {
    "Display and advice",
    ema_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 = "#FFD166", type = input.color },
    ema_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)

-- RSI as IQ Option's built-in RSI draws it: the average gain and the average
-- loss are exponential averages (alpha = 2 / (period + 1)), not Wilder's
-- smoothing (alpha = 1 / period). It stays empty until both averages exist and
-- is 50 when price did not move at all.
rsi_change = close - close [1]
rsi_gain = ema (max (rsi_change, 0), rsi_period)
rsi_loss = ema (max (-rsi_change, 0), rsi_period)
rsi_total = rsi_gain + rsi_loss
rsi_value = iff (rsi_total > 0, 100 * rsi_gain / rsi_total, rsi_total + 50)

-- Stochastic as IQ Option's built-in oscillator 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.
stoch_low = lowest (low, k_period)
stoch_range = highest (high, k_period) - stoch_low
stoch_raw = iff (stoch_range > 0, (close - stoch_low) / stoch_range, stoch_range + 0.5)
stoch_k = sma (stoch_raw, k_smoothing) * 100
stoch_d = sma (stoch_k, d_period)

local ema_now = get_value (trend_ema, nil)
local rsi_now = get_value (rsi_value, nil)
local k_now = get_value (stoch_k, nil)
local d_now = get_value (stoch_d, nil)
local k_previous = get_value (stoch_k [1], nil)
local d_previous = get_value (stoch_d [1], nil)
local close_now = get_value (close, nil)

local levels_are_valid = oversold_level < 50 and overbought_level > 50

local data_is_ready =
    levels_are_valid and
    get_value (close [ema_period], nil) ~= nil and
    ema_now ~= nil and
    rsi_now ~= nil and
    k_now ~= nil and
    d_now ~= nil and
    k_previous ~= nil and
    d_previous ~= nil and
    close_now ~= nil

-- Event: %K crosses %D on this candle, starting from the extreme zone.
local cross_up_from_oversold =
    data_is_ready and k_previous <= d_previous and k_now > d_now and k_previous <= oversold_level
local cross_down_from_overbought =
    data_is_ready and k_previous >= d_previous and k_now < d_now and k_previous >= overbought_level

higher_setup = conditional (
    cross_up_from_oversold and close_now > ema_now and rsi_now > rsi_midline
)

lower_setup = conditional (
    cross_down_from_overbought and close_now < ema_now and rsi_now < rsi_midline
)

-- 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 ema_visible then
    plot (trend_ema, "EMA 200", ema_color, ema_width)
end

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

    plot_shape (
        confirmed_lower,
        "RSI STO 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
  • Intermediate

Trend Intensity Index

Marks the moment the Trend Intensity Index enters its strong zone: above 80 for upward pressure or below 20 for downward pressure, with the close on the matching side of the 60-period SMA. It is a trend-strength entry marker, not a reversal marker.

Indicators: Trend Intensity Index (30, SMA 60)

  • Trend
  • On price
  • Intermediate

VHF EMA Cross

Marks EMA 9 and EMA 21 crosses only while the Vertical Horizontal Filter reports a trending market. The filter removes crosses that happen during sideways price action, where moving-average crosses tend to be unreliable.

Indicators: Vertical Horizontal Filter (28, 0.35) · EMA (9) · EMA (21)

  • Trend
  • Own panel
  • Intermediate

Vortex MACD

Marks a Vortex VI+/VI- cross when the MACD line is on the matching side of its signal line. The Vortex cross shows which direction dominates and the MACD checks that momentum agrees.

Indicators: Vortex Indicator (21) · MACD (12, 26, 9)

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.

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.