Zero Lag Trend Signals + Sideways filter

Zero Lag Trend Signals + Sideways filter

1. Introduction

The Zero Lag Trend Signals + Sideways filter indicator, developed by Algoalpha, is designed to capture trend changes rapidly by minimizing the lag inherent in traditional moving averages. It also incorporates a sideways-market filter to suppress signals when the instrument is trading in a range, thereby enhancing the reliability of entries and exits.

2. Overview

This indicator combines three core elements:

  • ZLEMA (Zero Lag Exponential Moving Average): A moving average that adjusts for price lag.

  • Volatility band (based on ATR): Defines upper and lower thresholds around the ZLEMA to confirm significant moves.

  • Sideways-market filter: Uses RSI and ADX to detect low-momentum, ranging conditions and suspend trend signals.

3. Component Calculations

3.1 ZLEMA Calculation

  1. Lag


    lag = floor((length − 1) / 2)
  2. Zero Lag EMA

    zlema = average[length, 1](src + (src − src[lag]))

     

    • src is the source price (default: close).

    • average[length, 1] is the built-in ProRealTime EMA function.

3.2 Volatility Band

  1. ATR over length periods

    atr = averagetruerange[length](close)
  2. Band width

    band = highest[length * 3](atr) * mult
    • mult scales the band (default: 1.2).

    • Upper band = zlema + band, Lower band = zlema − band.

3.3 Sideways-Market Filter

  1. RSI condition

    rsiValue = rsi[rsilength](close)
    rsiCondition = rsiValue > 40 and rsiValue < 60
  2. ADX condition

    pdi = DIplus[adxlength](close)
    mdi = DIminus[adxlength](close)
    iadx = ADX[adxlength]
    adxCondition = iadx ≤ 25 and iadx < pdi and iadx < mdi
  3. Combined sideways flag

    sideways = rsiCondition and adxCondition
    • When sideways is true (and showSideways = 1), grey points mark ranging bars.

4. Signals and Visualization

  • Trend state (trend):

    • Set to 1 when price crosses above zlema + band.

    • Set to –1 when price crosses below zlema – band.

    • No change when sideways is true.

  • Arrows

    • Buy arrow: Upward arrow below price on fresh bullish trend.

    • Sell arrow: Downward arrow above price on fresh bearish trend.

  • Extra markers

    • Small green “▲” when price re-crosses ZLEMA in an uptrend.

    • Small red “▼” when price re-crosses ZLEMA in a downtrend.

  • Colored area

    • Fills between ZLEMA and the appropriate band to highlight trend strength:

      • Solid color when in trend, transparent when out of band or sideways.

5. Parameters and Defaults

Parameter Default Description
length 70 Look-back for ZLEMA, ATR and highest ATR.
mult 1.2 Multiplier for the ATR-based volatility band.
src close Price source for ZLEMA calculation.
rsilength 14 Period for the RSI component of the sideways filter.
adxlength 14 Period for the ADX component of the sideways filter.
showSideways 1 Show grey dots when market is detected as sideways (1 = on, 0 = off).

6. ProRealTime Code

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

avatar
Register or

Likes

avatar avatar avatar avatar
Related users ' posts
Dest
3 years ago
DIDI Index
DIDI Index
0
Indicators
ChemaGeek Bonjour Nicolas, j'ai récemment découvert cet indicateur (Regularized Momentum 2017) et je l...
YvesRobert Bonjour, nouveau sur PRT (qq jours), j'essaie un peu de voir quel type d'indicateur me convi...
larouedegann It doesn't work
ggolfet it seems it's not working on prorealtime 11. I changed MACDSignal to MACDSign in order to av...
juanj Please note that the indicator is meant for PRT 10.3
Vonasi There are actually two ways to calculate standard deviations and I seem to have used the ver...
segie Can something similar be done with Supertrends?
Vonasi Not sure I fully understand what you are asking for. Are you asking for MTF Supertrend level...
Kris75 very interesting; thanks !
Rory Dryden Thank you. Experimenting with it now.
Wolf Hi Vonasi. Thank for this indicator. I like this calculate concept. I think that line 16 thi...
Vonasi Well spotted! It is just a safety check to ensure that no value below 1 can be used otherwis...
Stockastiss Can this code be simply transferred into Backtestingcode so one doesnt need to use call ? (i...
Vonasi Sorry for the late reply. Add the code to your strategy and remove line 5 and line 39. Chang...
viktorthunss Hi! How many averages are there? Can I see the somewhere?
leofi https://www.prorealcode.com/topic/simple-average-with-visual-color/
leofi Go visit www.prorealcode.com/topic/simple-average-with-visual-color/ and watch 2em post
Dritan Hi,I am new on Prorealtime and coding.I downloaded the indi but I have it on a separate wind...
Marie-Eve Vergoz Bonsoir - Voici l'erreur qui est signalée lorsque je souhaite utiliser cet indicateur : il...
Om Hello, thanks for sharing! Getting a message that Variable P is undefined?
matin Intraday Average Volume Indicator Not working, what can i do plz
Vonasi Sure that is possible. I will code it and make a post in the English ProBuilder forum and pu...
Vonasi Vama v2 with Hull moving average included can be found here: https://www.prorealcode.com/top...
JMat45 Thank you, Vonasi.
XXXXVII Excellent indicateur ! Déterminer une tendance est devenu un jeu d'enfants ! Félicitation......
gregoire bonjour nicolas j ai cherché partout sur le net et impossible de trouvé ce que je recherch...
Nicolas Merci de poster une demande dans le forum des indicateurs, ainsi on pourra le coder dans ce ...
Nicolas Thanks a lot for this new valuable addition to our library. I changed line 76 with "barindex...
Horance Thanks. I've noticed this leftover after submission, but it was too late for editing. BTW, I...
Etienne Thanks Horance for porting this code to PRT. I would like to bring some speedup to your cod...
Vonasi Forum discussion on these indicators can be found here: https://www.prorealcode.com/topic/av...
jennr29 Hi. Is it possible to convert this code to an mq4 file?
Nicolas Sorry but our website is dedicated to prorealtime programming. However, you can ask for priv...
rejo007 hello david, i'll try it could you tell me wich strategy do you use in real? thanks
David Somogyi Hello, I have a couple of DAX strategies of breakout and mean reversion. I'll try to post...
Roberto Blázquez Hi David, I just saw your strategy and it's good!!! I'm going to try it from today in real a...

Top