Trend Intensity Index Script

← All 56 scripts

  • Trend
  • Own panel
  • Intermediate

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.

  • File iqow-trend-intensity-index.lua
  • Version 1.0.0
  • Size 144 lines · 5 KB
  • Timeframes 1-minute to 15-minute candles
  • License MIT
Trend Intensity Index 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

TII(30) crosses above 80 on a candle that closes above its 60-period SMA.

LOWER marker

TII(30) crosses below 20 on a candle that closes below its 60-period SMA.

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 red line is the TII in a separate panel between 0 and 100, with levels at 20, 50 and 80. A green HIGHER triangle at the bottom of the panel marks TII crossing up through 80 above its SMA; a red LOWER triangle at the top marks TII crossing down through 20 below its SMA.

Indicators used

  • Trend Intensity Index (30, SMA 60)

Same view with built-in indicators: Add Trend Intensity Index (major 60, minor 30) with levels 20 and 80 and an SMA (60) on the price chart.

Default settings

SMA period (major)60
TII period (minor)30
Low level20
High level80

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

Key points

  1. The Trend Intensity Index shows how much of the recent price action sits above or below a 60-period moving average.
  2. It runs from 0 to 100: above 80 is a strong upward trend, below 20 a strong downward one.
  3. A HIGHER marker appears when the TII crosses up through 80 and the close is above the average.
  4. A LOWER marker appears when it crosses down through 20 with the close below the average.
  5. This is a trend-strength reading, not an overbought and oversold warning.
  6. Check the markers against the price chart on a Practice balance first.

Limitations. The TII needs 60 plus 30 candles of history, and by the time it reaches 80 or 20 a trend is already well under way, so it can arrive late or just before a pullback. The article also describes fading the 20 and 80 levels as reversal levels; this script uses the opposite, trend-continuation reading. 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: 32603606fc4e26178beb4232f51b68039662f86a4c6b1336267d6bdf8c047150

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Trend Intensity Index v1.0.0
--
-- The Trend Intensity Index (TII) compares how much of the recent price
-- distance from a 60-period SMA is above versus below it. It reads 0 to 100:
-- high values mean strong upward pressure, low values strong downward pressure.
-- Formula follows the official IQ Option indicator. Drawn in its own panel.
--
-- HIGHER: TII(30) crosses above 80 while the close is above its SMA 60.
-- LOWER:  TII(30) crosses below 20 while the close is below its SMA 60.
--
-- 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 Trend Intensity Index",
    short_name = "IQOW TII",
    overlay = false
}

input_group {
    "1. Trend Intensity Index",
    major_period = input (60, "SMA period (major)", input.integer, 3, 300),
    minor_period = input (30, "TII period (minor)", input.integer, 2, 200)
}

input_group {
    "2. Levels",
    low_level = input (20, "Low level", input.double, 5, 45, 1, false),
    high_level = input (80, "High level", input.double, 55, 95, 1, false)
}

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",
    tii_color = input { default = "#DB4931", type = input.color },
    level_low_color = input { default = rgba(255, 108, 88, 0.5), type = input.color },
    level_high_color = input { default = rgba(37, 225, 84, 0.5), type = input.color },
    middle_color = input { default = rgba(255, 255, 255, 0.15), 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 }
}

-- Distance of the close from its SMA, split into the part above and below.
major_sma = sma (close, major_period)
distance = close - major_sma
positive_sum = sum (max (distance, 0), minor_period)
negative_sum = -sum (min (distance, 0), minor_period)
tii_value = 100 * positive_sum / max (positive_sum + negative_sum, 1e-10)

-- Current-bar scalars for the Lua rule logic.
local tii_now = get_value (tii_value, nil)
local tii_before = get_value (tii_value [1], nil)
local close_now = get_value (close, nil)
local sma_now = get_value (major_sma, nil)

local settings_are_valid = minor_period <= major_period and low_level < high_level

local data_is_ready =
    settings_are_valid and
    tii_now ~= nil and
    tii_before ~= nil and
    close_now ~= nil and
    sma_now ~= nil and
    get_value (tii_value [major_period + minor_period], nil) ~= nil

-- Event: TII crosses a level on this candle while the close sits on the same side of the SMA.
higher_setup = conditional (
    data_is_ready and tii_before <= high_level and tii_now > high_level and close_now > sma_now
)
lower_setup = conditional (
    data_is_ready and tii_before >= low_level and tii_now < low_level and close_now < sma_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)
)

hline { value = high_level, color = level_high_color, width = 1 }
hline { value = low_level, color = level_low_color, width = 1 }
hline { value = 50, color = middle_color, width = 1 }
hline { value = 100, color = "#0000000", show_label = false }
hline { value = 0, color = "#0000000", show_label = false }

if lines_visible then
    plot (tii_value, "TII", tii_color, line_width)
end

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

    plot_shape (
        confirmed_lower,
        "TII 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 trend scripts

  • 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)

  • Trend
  • On price
  • Advanced

Ichimoku Kijun Cloud

Marks a close back across the Kijun-sen when price is already on the trend side of a coloured Ichimoku cloud. The cloud sets direction and the Kijun cross sets the timing.

Indicators: Ichimoku Cloud (9, 26, 52, displacement 26)

  • Trend
  • On price
  • Intermediate

KAMA Trend

Marks closes that cross Kaufman's Adaptive Moving Average in the direction the average is already sloping. The slope check removes crosses where the flat, slow-moving KAMA is merely being touched by price.

Indicators: KAMA (10, 2, 30)

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.