- Trend
- On price
- Intermediate
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.
The rules
HIGHER marker
EMA 9 crosses above EMA 21 on a candle where VHF(28) is above 0.35.
LOWER marker
EMA 9 crosses below EMA 21 on a candle where VHF(28) is above 0.35.
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 blue and amber lines are EMA 9 and EMA 21; they turn pale grey while the VHF is at or below the threshold, meaning the market is ranging. A green HIGHER triangle under a candle marks a bullish EMA cross in a trending market, and a red LOWER triangle above a candle marks a bearish one.
Indicators used
- Vertical Horizontal Filter (28, 0.35)
- EMA (9)
- EMA (21)
Same view with built-in indicators: Add Vertical Horizontal Filter (28) in a separate panel, plus Exponential Moving Averages 9 and 21 on the price chart.
Default settings
| VHF period | 28 |
|---|---|
| Trending threshold | 0.35 |
| Fast EMA | 9 |
| Slow EMA | 21 |
Every value is an input in the script settings. Platform advice is off by default.
Key points
- The Vertical Horizontal Filter compares the price range with the total distance price travelled.
- A high value means price moves in one direction; a low value means it chops sideways.
- We use it as a gate: EMA 9 and EMA 21 crosses count only when the VHF is above 0.35.
- In ranging markets the moving averages turn grey and no marker is given.
- HIGHER is a fast EMA crossing above the slow one; LOWER is the opposite.
- Try other thresholds on a Practice balance to see how much the filter removes.
Limitations. The 0.35 threshold is a script default, not a fixed rule, and the VHF often rises only after a trend has already begun, so a cross can come late. The VHF value itself is not drawn in this overlay version; add the built-in VHF to see it. Test on the Practice balance before risking real funds.
Install it in four steps
- 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.
- Open Chart Analysis → ScriptsIn the IQ Option traderoom, choose the Practice balance, open the chart analysis panel, select Scripts and choose Import script.
- Save and add to chartSelect the downloaded file, review the imported code, choose Save, then use the + control to add it to the chart.
- 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: d1c4d11a92082c4d7dc825d7bac3565a2aee1090824a98b2f53410f3d45c4fd4
-- SPDX-License-Identifier: MIT
-- IQOptionWiki QCS Library
-- IQOW VHF EMA Cross v1.0.0
--
-- The Vertical Horizontal Filter (VHF) tells trending markets from ranging
-- ones: it is high when price moves directionally and low when it chops.
-- EMA 9 / EMA 21 crosses are only marked while the VHF says the market trends.
-- Formula follows the official IQ Option VHF (closing-price range / path).
--
-- HIGHER: EMA 9 crosses above EMA 21 while VHF(28) is above 0.35.
-- LOWER: EMA 9 crosses below EMA 21 while VHF(28) is above 0.35.
--
-- 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 VHF EMA Cross",
short_name = "IQOW VHF EMA",
overlay = true
}
input_group {
"1. Vertical Horizontal Filter",
vhf_period = input (28, "VHF period", input.integer, 2, 200),
vhf_threshold = input (0.35, "Trending threshold", input.double, 0.05, 1, 0.01, false)
}
input_group {
"2. EMA cross",
fast_period = input (9, "Fast EMA", input.integer, 2, 100),
slow_period = input (21, "Slow EMA", input.integer, 3, 250)
}
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_color = input { default = "#56CEFF", type = input.color },
slow_color = input { default = "#FFB020", type = input.color },
idle_color = input { default = rgba(255, 255, 255, 0.3), 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 }
}
-- VHF: range of closes over the period divided by the sum of single-bar moves.
close_range = highest (close, vhf_period) - lowest (close, vhf_period)
path_length = sum (abs (change (close)), vhf_period)
vhf_value = close_range / max (path_length, 1e-10)
fast_ema = ema (close, fast_period)
slow_ema = ema (close, slow_period)
-- Current-bar scalars for the Lua rule logic.
local vhf_now = get_value (vhf_value, nil)
local fast_now = get_value (fast_ema, nil)
local fast_before = get_value (fast_ema [1], nil)
local slow_now = get_value (slow_ema, nil)
local slow_before = get_value (slow_ema [1], nil)
local periods_are_valid = fast_period < slow_period
local data_is_ready =
periods_are_valid and
vhf_now ~= nil and
fast_now ~= nil and
fast_before ~= nil and
slow_now ~= nil and
slow_before ~= nil and
get_value (slow_ema [slow_period], nil) ~= nil
local market_is_trending = data_is_ready and vhf_now > vhf_threshold
-- Event: the EMAs cross on this candle while the VHF reports a trending market.
higher_setup = conditional (
market_is_trending and fast_before <= slow_before and fast_now > slow_now
)
lower_setup = conditional (
market_is_trending and fast_before >= slow_before and fast_now < slow_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 lines_visible then
-- Lines are dimmed when the VHF says the market is not trending.
local fast_line_color = market_is_trending and fast_color or idle_color
local slow_line_color = market_is_trending and slow_color or idle_color
plot (fast_ema, "Fast EMA", fast_line_color, line_width)
plot (slow_ema, "Slow EMA", slow_line_color, line_width)
end
if signals_visible then
plot_shape (
confirmed_higher,
"VHF EMA HIGHER",
shape_style.triangleup,
shape_size.small,
higher_color,
shape_location.belowbar,
-1,
"HIGHER",
signal_text_color
)
plot_shape (
confirmed_lower,
"VHF EMA 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
- 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.