Vortex MACD Script

← All 56 scripts

  • Trend
  • Own panel
  • Intermediate

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.

  • File iqow-vortex-macd.lua
  • Version 1.0.0
  • Size 145 lines · 5 KB
  • Timeframes 5-minute candles (article)
  • License MIT
Vortex MACD 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

Vortex VI+(21) crosses above VI- on this candle while the MACD(12, 26, 9) line is above its signal line.

LOWER marker

Vortex VI+(21) crosses below VI- on this candle while the MACD(12, 26, 9) line is below its signal line.

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

This runs in a separate panel. The blue line is VI+ and the purple line is VI-; where they cross, the dominant movement changes side. A green HIGHER triangle at the bottom of the panel means VI+ crossed up while MACD was above its signal line; a red LOWER triangle at the top is the mirror case. The MACD is not drawn here.

Indicators used

  • Vortex Indicator (21)
  • MACD (12, 26, 9)

Same view with built-in indicators: Add IQ Option's Vortex Indicator (21) and MACD (12, 26, 9).

Default settings

Vortex period21
MACD fast12
MACD slow26
MACD signal9

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

Key points

  1. The Vortex Indicator has two lines: VI+ for upward movement and VI- for downward movement.
  2. A cross of the two lines shows which direction is gaining control.
  3. On its own it creates many false signals in sideways markets, so the article adds the MACD.
  4. We only mark a VI+ cross up when the MACD line is above its signal line, and the mirror for LOWER.
  5. The article suggests period 21 or 34 for a 5-minute chart; this script starts with 21.
  6. Practise on a Practice balance and compare the two periods.

Limitations. The article accepts the two crossovers a few candles apart; this script requires the MACD to be on the matching side at the time of the Vortex cross, which is a simpler test. Vortex crosses are frequent in consolidation, where MACD agreement helps but does not remove false marks. 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: eae74decc9e5f69520eb6a99d7e7024da342a84e3d493a48ee46e15882f18245

-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW Vortex MACD v1.0.0
--
-- Combines the Vortex Indicator (21) with MACD (12, 26, 9), as in the related
-- article. A VI+ / VI- cross shows the dominant price movement changing side; the
-- MACD line against its signal line checks that momentum agrees. The article
-- suggests period 21 or 34 on a 5-minute chart; 21 is the default here. The
-- chart shows the Vortex lines; the MACD condition is part of the rule only.
--
-- HIGHER: VI+ crosses above VI- while the MACD line is above its signal line.
-- LOWER:  VI+ crosses below VI- while the MACD line is below its signal line.
--
-- 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 Vortex MACD",
    short_name = "IQOW VORTEX",
    overlay = false
}

input_group {
    "1. Vortex Indicator",
    vortex_period = input (21, "Vortex period", input.integer, 2, 100)
}

input_group {
    "2. MACD",
    macd_fast_period = input (12, "Fast EMA period", input.integer, 2, 100),
    macd_slow_period = input (26, "Slow EMA period", input.integer, 3, 200),
    macd_signal_period = input (9, "Signal period", input.integer, 2, 100)
}

input_group {
    "Display and advice",
    vortex_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",
    plus_color = input { default = "#56CEFF", type = input.color },
    minus_color = input { default = "#B42EFF", type = input.color },
    vortex_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 }
}

-- Vortex Indicator as in the official indicator.
plus_movement = abs (high - low [1])
minus_movement = abs (low - high [1])
true_range_sum = sum (tr, vortex_period)
vi_plus = sum (plus_movement, vortex_period) / iff (true_range_sum > 1e-10, true_range_sum, 1e-10)
vi_minus = sum (minus_movement, vortex_period) / iff (true_range_sum > 1e-10, true_range_sum, 1e-10)

macd_line = ema (close, macd_fast_period) - ema (close, macd_slow_period)
signal_line = ema (macd_line, macd_signal_period)

local plus_now = get_value (vi_plus, nil)
local minus_now = get_value (vi_minus, nil)
local plus_previous = get_value (vi_plus [1], nil)
local minus_previous = get_value (vi_minus [1], nil)
local macd_now = get_value (macd_line, nil)
local signal_now = get_value (signal_line, nil)

local periods_are_valid = macd_fast_period < macd_slow_period

local data_is_ready =
    periods_are_valid and
    get_value (close [macd_slow_period + macd_signal_period], nil) ~= nil and
    get_value (close [vortex_period + 1], nil) ~= nil and
    plus_now ~= nil and
    minus_now ~= nil and
    plus_previous ~= nil and
    minus_previous ~= nil and
    macd_now ~= nil and
    signal_now ~= nil

-- Event: VI+ crosses VI- on this candle.
local vortex_crosses_up = data_is_ready and plus_previous <= minus_previous and plus_now > minus_now
local vortex_crosses_down = data_is_ready and plus_previous >= minus_previous and plus_now < minus_now

higher_setup = conditional (vortex_crosses_up and macd_now > signal_now)
lower_setup = conditional (vortex_crosses_down and macd_now < signal_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 vortex_visible then
    hline (1, "Vortex 1.0", rgba(255, 255, 255, 0.15), 1)
    plot (vi_plus, "VI+", plus_color, vortex_width)
    plot (vi_minus, "VI-", minus_color, vortex_width)
end

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

    plot_shape (
        confirmed_lower,
        "VORTEX MACD 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
  • 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)

  • Trend
  • On price
  • Intermediate

LRS Williams R

Uses the slope of a 100-candle regression line as the trend filter and Williams %R leaving its extreme zone as the timing event. The regression line is drawn on the price chart so the slope direction is visible.

Indicators: Linear Regression Slope (100) · Williams %R (14, levels -80/-20)

  • Trend
  • On price
  • Intermediate

MACD PSAR EMA

Marks a MACD signal-line cross that is backed by candle colour, the EMA and the Parabolic SAR. Three different views of price have to agree on the same completed candle.

Indicators: MACD (12, 26, 9) · Parabolic SAR (0.02, 0.2) · EMA (10)

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.