Stochastic PSAR Script

← All 70 scripts

iqow-stochastic-psar.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

  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.

  • Reversal
  • On price
  • Beginner

Marks a Stochastic %K/%D cross that starts in the oversold or overbought zone while the Parabolic SAR dot is on the matching side of price. The Stochastic gives the timing and the SAR checks the trailing stop agrees.

  • File iqow-stochastic-psar.lua
  • Version 1.0.1
  • Size 153 lines · 5 KB
  • Timeframes Any timeframe
  • License MIT
Stochastic PSAR 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

Stochastic %K crosses above %D after %K was at or below 20 on the previous candle, and the Parabolic SAR dot is below the close.

LOWER marker

Stochastic %K crosses below %D after %K was at or above 80 on the previous candle, and the Parabolic SAR dot is above the close.

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 dots are the Parabolic SAR. A green HIGHER triangle under a candle means the Stochastic just crossed up from the oversold zone while SAR dots sit below price; a red LOWER triangle above a candle is the mirror case. The Stochastic is not drawn on the price chart.

Indicators used

  • Stochastic (14, 3, 3)
  • Parabolic SAR (0.02, 0.2)

Same view with built-in indicators: Add IQ Option's Stochastic Oscillator (14, 3, 3, levels 80/20) and Parabolic SAR (0.02, 0.2).

Default settings

Stochastic %K14
Stochastic smoothing3
Stochastic %D3
Oversold20
Overbought80
SAR start0.02
SAR step0.02
SAR maximum0.2

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

Key points

  1. The Stochastic has two lines, %K and %D, and moves between 0 and 100.
  2. Below 20 is oversold and above 80 is overbought.
  3. We want %K to cross %D after sitting in one of those zones.
  4. The Parabolic SAR dots must support the direction: below price for HIGHER, above price for LOWER.
  5. Both signals must appear on the same completed candle, and the marker is drawn one candle later.
  6. Test it on a Practice balance and note how SAR timing changes the number of marks.

Limitations. The article describes the Stochastic cross and the SAR as a combination but gives no exact oversold or overbought rule, so 20 and 80 are used. Because the SAR dot must already be on the other side of price, the mark can arrive late, and in strong trends the Stochastic stays in its zone for a long time. The Stochastic is calculated like IQ Option's built-in version: the close against the highest high and lowest low of the %K period. 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: 9e1fc0313703da65a906120625502510238a3c78495a11f3612f45d838befb0d

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Stochastic PSAR v1.0.1
--
-- Combines the Stochastic oscillator (14, 3, 3) with the Parabolic SAR, as in
-- the related article. The Stochastic cross out of an extreme zone gives the
-- timing; the SAR confirms that its dots are on the matching side of price.
--
-- 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 after %K was at or below 20 on the previous
--         candle, and the Parabolic SAR dot is below the close.
-- LOWER:  %K crosses below %D after %K was at or above 80 on the previous
--         candle, and the Parabolic SAR dot is above the close.
--
-- 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 Stochastic PSAR",
    short_name = "IQOW STO PSAR",
    overlay = true
}

input_group {
    "1. Parabolic SAR",
    sar_start = input (0.02, "Start", input.double, 0.01, 1, 0.01),
    sar_step = input (0.02, "Step", input.double, 0.01, 1, 0.01),
    sar_maximum = input (0.2, "Maximum", input.double, 0.01, 1, 0.01)
}

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",
    sar_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",
    sar_color = input { default = "#56CEFF", type = input.color },
    sar_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 }
}

psar = sar (sar_start, sar_step, sar_maximum)

-- 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 sar_now = get_value (psar, 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
    sar_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 sar_now < close_now)
lower_setup = conditional (cross_down_from_overbought and sar_now > close_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 sar_visible then
    plot (psar, "Parabolic SAR", sar_color, sar_width, 0, style.points)
end

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

    plot_shape (
        confirmed_lower,
        "STO PSAR 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 reversal scripts

  • Reversal
  • Own panel
  • Intermediate

Fisher Transform Reversal

Marks a Fisher Transform cross of its trigger line while the indicator is in an extreme zone. This is the extreme-then-cross confirmation the related article describes.

Indicators: Ehlers Fisher Transform (10)

  • Reversal
  • On price
  • Beginner

Harami RSI

Marks bullish and bearish harami candle pairs when RSI is in a low or high zone. RSI helps check that the pair follows a push in the opposite direction.

Indicators: Harami candle pair · RSI (14, 40/60)

  • Reversal
  • Own panel
  • Intermediate

KDJ Cross

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.

Indicators: KDJ (9, 3, 3)

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.