Double Stochastic Script

← All 56 scripts

  • Reversal
  • Own panel
  • Intermediate

Marks the candle where a slow Stochastic confirms a reversal cross that the fast Stochastic already showed in the same oversold or overbought zone. Using two settings asks the same question on two time scales before a marker appears.

  • File iqow-double-stochastic.lua
  • Version 1.0.0
  • Size 194 lines · 7 KB
  • Timeframes 5-minute to 15-minute candles
  • License MIT
Double Stochastic 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 fast Stochastic %K crossed above its %D at or below 20 within the last 5 candles, and the slow %K now crosses above its %D at or below 20.

LOWER marker

The fast Stochastic %K crossed below its %D at or above 80 within the last 5 candles, and the slow %K now crosses below its %D at or 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

The panel shows four lines: fast %K and %D in blue, slow %K and %D in orange, with lines at 20 and 80. A green HIGHER triangle at the bottom means both pairs crossed up inside the oversold zone; a red LOWER triangle at the top is the mirror case in the overbought zone.

Indicators used

  • Stochastic fast (8, 3, 5)
  • Stochastic slow (17, 3, 7)

Same view with built-in indicators: Add two Stochastic Oscillators: one with %K 8, %D 3, smoothing 5 and one with %K 17, %D 3, smoothing 7, both with levels 80 and 20.

Default settings

Fast %K / %D / smoothing8 / 3 / 5
Slow %K / %D / smoothing17 / 3 / 7
Oversold20
Overbought80
Fast cross memory (candles)5

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

Key points

  1. The Double Stochastic idea is simple: two Stochastics with different settings must agree.
  2. The fast one, 8 3 5, reacts first. When its lines cross inside the oversold zone it gives only a hint.
  3. The slow one, 17 3 7, is the confirmation. We wait until its lines also cross up below 20.
  4. The marker appears only when both have crossed in the same zone within a few candles.
  5. Overbought works the same way in reverse, marked LOWER.
  6. Markers use completed candles, so they do not move while a candle is still forming.

Limitations. The slow Stochastic is heavily smoothed, so it reaches the extreme zones rarely and the confirmation arrives late. In a strong trend both oscillators can stay in the zone and cross back several times without a lasting reversal. Test on the Practice balance before risking real funds.

Learn the strategy: read the full guide on IQOptionWiki →

Install it in four steps

  1. 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.
  2. Open Chart Analysis → ScriptsIn the IQ Option traderoom, choose the Practice balance, open the chart analysis panel, select Scripts and choose Import script.
  3. Save and add to chartSelect the downloaded file, review the imported code, choose Save, then use the + control to add it to the chart.
  4. 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: 1d123602a9ff44097c5f381550bbc6f20c4e943c295017000421cf6361a39ddc

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Double Stochastic v1.0.0
--
-- Two Stochastic oscillators with different settings. The fast one (8, 3, 5)
-- gives the first reversal hint; the slow one (17, 3, 7) confirms it, as the
-- IQOptionWiki Double Stochastic article describes. Settings are %K period,
-- %D period and %K smoothing.
--
-- HIGHER: the fast %K crossed above its %D in the oversold zone (at or below 20)
--         within the last few candles, and now the slow %K crosses above its %D
--         while also in the oversold zone.
-- LOWER:  the mirror case: fast cross down in the overbought zone (at or above
--         80), then the slow %K crosses below its %D in the overbought zone.
--
-- 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 Double Stochastic",
    short_name = "IQOW 2xSTOCH",
    overlay = false
}

input_group {
    "1. Fast Stochastic",
    fast_k_period = input (8, "%K period", input.integer, 2, 100),
    fast_d_period = input (3, "%D period", input.integer, 1, 50),
    fast_smooth = input (5, "%K smoothing", input.integer, 1, 50)
}

input_group {
    "2. Slow Stochastic (confirmation)",
    slow_k_period = input (17, "%K period", input.integer, 2, 100),
    slow_d_period = input (3, "%D period", input.integer, 1, 50),
    slow_smooth = input (7, "%K smoothing", input.integer, 1, 50)
}

input_group {
    "3. Zones and timing",
    oversold_level = input (20, "Oversold level", input.double, 5, 45, 1, false),
    overbought_level = input (80, "Overbought level", input.double, 55, 95, 1, false),
    fast_memory = input (5, "Fast cross memory (candles)", input.integer, 1, 20)
}

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",
    fast_k_color = input { default = "#56CEFF", type = input.color },
    fast_d_color = input { default = rgba(86, 206, 255, 0.45), type = input.color },
    slow_k_color = input { default = "#FF7700", type = input.color },
    slow_d_color = input { default = rgba(255, 119, 0, 0.45), type = input.color },
    zone_color = input { default = rgba(255, 255, 255, 0.30), 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 }
}

-- Stochastic in QCS returns 0..1; smooth %K, then %D is its average.
fast_k = sma (stochastic (close, fast_k_period), fast_smooth) * 100
fast_d = sma (fast_k, fast_d_period)
slow_k = sma (stochastic (close, slow_k_period), slow_smooth) * 100
slow_d = sma (slow_k, slow_d_period)

-- Current and previous values for the rule logic.
local fast_k_now = get_value (fast_k, nil)
local fast_d_now = get_value (fast_d, nil)
local fast_k_before = get_value (fast_k [1], nil)
local fast_d_before = get_value (fast_d [1], nil)
local slow_k_now = get_value (slow_k, nil)
local slow_d_now = get_value (slow_d, nil)
local slow_k_before = get_value (slow_k [1], nil)
local slow_d_before = get_value (slow_d [1], nil)

local levels_are_valid = oversold_level < 50 and overbought_level > 50

local data_is_ready =
    levels_are_valid and
    fast_k_now ~= nil and fast_d_now ~= nil and
    fast_k_before ~= nil and fast_d_before ~= nil and
    slow_k_now ~= nil and slow_d_now ~= nil and
    slow_k_before ~= nil and slow_d_before ~= nil

-- Fast Stochastic cross inside its extreme zone (first hint).
fast_cross_up = conditional (
    data_is_ready and
    fast_k_before <= fast_d_before and fast_k_now > fast_d_now and
    fast_k_now <= oversold_level
)

fast_cross_down = conditional (
    data_is_ready and
    fast_k_before >= fast_d_before and fast_k_now < fast_d_now and
    fast_k_now >= overbought_level
)

-- Did the fast cross happen on this candle or within the memory window?
local function seen_recently (event, bars)
    if get_value (event, false) then
        return true
    end
    for back = 1, bars - 1 do
        if get_value (event [back], false) then
            return true
        end
    end
    return false
end

local fast_up_recent = seen_recently (fast_cross_up, fast_memory)
local fast_down_recent = seen_recently (fast_cross_down, fast_memory)

-- Slow Stochastic cross inside the same zone (confirmation).
local slow_cross_up =
    data_is_ready and
    slow_k_before <= slow_d_before and slow_k_now > slow_d_now and
    slow_k_now <= oversold_level

local slow_cross_down =
    data_is_ready and
    slow_k_before >= slow_d_before and slow_k_now < slow_d_now and
    slow_k_now >= overbought_level

higher_setup = conditional (slow_cross_up and fast_up_recent)
lower_setup = conditional (slow_cross_down and fast_down_recent)

-- 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
    fill_area (overbought_level, oversold_level, "Neutral zone", rgba (255, 255, 255, 0.04))
    hline (overbought_level, "Overbought", zone_color, 1)
    hline (oversold_level, "Oversold", zone_color, 1)
    plot (fast_k, "Fast %K", fast_k_color, line_width)
    plot (fast_d, "Fast %D", fast_d_color, line_width)
    plot (slow_k, "Slow %K", slow_k_color, line_width)
    plot (slow_d, "Slow %D", slow_d_color, line_width)
end

if signals_visible then
    plot_shape (
        confirmed_higher,
        "2xSTOCH HIGHER",
        shape_style.triangleup,
        shape_size.small,
        higher_color,
        shape_location.bottom,
        -1,
        "HIGHER",
        signal_text_color
    )

    plot_shape (
        confirmed_lower,
        "2xSTOCH 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 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.

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.