Deviation Trend Profile indicator

Deviation Trend Profile indicator

1. Introduction

The Deviation Trend Profile indicator, developed by BigBeluga, merges trend analysis via a simple moving average (SMA) with a distribution profile based on ATR-scaled deviations. Its purpose is to highlight trend changes and zones of high or low price concentration, offering a visual map of volatility accumulation since the last market inflection.

2. What Is Deviation Trend Profile?

Deviation Trend Profile is a dual-purpose tool:

  • Trend: Plots an SMA whose color reflects momentum, and marks the exact bars where bullish or bearish turns begin.

  • Volatility & Distribution: Overlays six deviation lines (±1, ±2, ±3 ATR multiples) around the SMA, and generates a side histogram showing how many closes have fallen into each of a configurable number of bins between the maximum and minimum deviation levels.

This hybrid approach makes it easy to see when price deviates significantly from its mean and how those deviations are distributed over time.

3. How It Works

3.1. Calculation of SMA and ATR

  • SMA: Simple moving average of closes over a user-set period (smaLength, default 50).

  • ATR: 200-bar Average True Range, serving as the volatility baseline for scaling deviations.

3.2. Standard Deviation Levels

Six horizontal lines are drawn around the SMA:

  • Positive levels:

    • +1 = SMA + ATR × mult1

    • +2 = SMA + ATR × mult2

    • +3 = SMA + ATR × mult3

  • Negative levels:

    • –1 = SMA – ATR × mult1

    • –2 = SMA – ATR × mult2

    • –3 = SMA – ATR × mult3

These lines help distinguish “normal” price territory (±1 ATR) from stronger expansion zones (±2 and ±3 ATR).

3.3. Trend Change Detection

The indicator computes a normalized momentum:

avgDiff = SMA − SMA[5]
avgCol = avgDiff / ATR

A cross above +0.1 signals the start of a bullish trend; a cross below –0.1 signals the start of a bearish trend.

Each turn is marked with a point on the SMA.

4. Deep Dive into the Distribution Profile (Histogram)

This advanced feature works as follows:

  1. Initialize bins
    Create an array $bin of length bins (default 50), filled with zeros.

  2. Populate bins with closes
    For each bar since the last trend change (startIndex):

    • Compute the dynamic range: profileRange = maxDev − minDev.

    • Compute each bin’s width: step = profileRange / bins.

    • Determine which bin a close c falls into by comparing it against lower = minDev + step × i and upper = lower + step, then increment $bin[i].

  3. Determine color scaling
    Find maxVal, the highest frequency among all bins. This value is used to set each rectangle’s transparency proportionally (val / maxVal).

  4. Draw rectangles

    • Position the histogram to the right by profileOffset bars.

    • For each bin with val > 0, draw a rectangle from upper down to lower, with width proportional to val, filled semi-transparently in the current trend color.

The result is a lateral histogram showing price-close concentration since the last turn, highlighting potential dynamic support/resistance zones.

5. Parameter Configuration

Parameter Description Default
smaLength Period of the simple moving average 50
mult1 ATR multiplier for ±1 deviation 1
mult2 ATR multiplier for ±2 deviation 2
mult3 ATR multiplier for ±3 deviation 3
showTp Show distribution profile (1 = yes, 0 = no) 1
bins Number of histogram bins 50
profileOffset Horizontal offset (bars) for the histogram 30
colUpR/G/B RGB channels for bullish trend color 18/209/235
colDnR/G/B RGB channels for bearish trend color 250/40/86

6. Default Values and Recommendations

  • SMA (50) & ATR (200): a balanced medium-term setting.

  • Deviations 1–3: distinguish consolidation (±1) from strong expansions (±2, ±3).

  • Bins (50): balance detail and performance; reduce to 30–40 for faster charts, or increase to 70–100 for finer analysis.

  • Offset (30 bars): keeps the profile clear of price action; adjust to fit your chart width.

  • Colors: customize to match your template, ensuring good contrast against candles and other studies.

7. ProBuilder 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
Related users ' posts
Violet Ivan, it looks as if something is really wrong with this indicator. When I import and apply ...
Iván Hello! For proper visualization, it is recommended to have more than 1k bars loaded.
Violet Thanks Ivan. Though it does not remove the 'tapering at the beginning' phenomenon, it does m...
roccafragius Thank you so much, for my point of view very useful!!!
NicoGB67 Excelente trabajo!!
Jrmjrm Bonsoir est-il possible d'avoir cet indicateur, mais à la place du Wilder Average, utiliser ...
geroniman merci Ivan, super indicatuer. Les cours vont souvent toucher 50% des zones vertes ou rouges....
Iván Pour ajouter une ligne supplémentaire, il suffit de créer une nouvelle variable, par exemple...
Maurizio A. excellent indicateur ! comment puis-je modifier le code pour afficher uniquement les dernier...
Iván Hi! just change line13 for this: showsignals=1
Quino Hi Excellent indicator as usual. Just 2 questions: Why LenH and LenL = 15 as Len could be...
Iván Hi! good question. This is a code request traslation from other platform. I took same inputs...
Gaspare Grazie Ivan, ottimo indicatore posso chiedere, per favore, una strategia che apre posizio...
Iván thanks! maybe I could test it
Iván
8 months ago
Madrosat Bonjour ivan Quelle différence il y a t il entre Extra trend et ultra trend lequel est le p...
P. Marlowe Muy bueno. ¿Podría hacerse para señalar extremos por el lado bajista? Lo mismo a la inversa....
Miro Esta es una versión del indicador, para ambos extremos. //-------------------------------...
P. Marlowe Muchas gracias ¡¡
MaoRai54 dear Ivan, it seems to be very interesting but please clarify what are all the lines I see i...
Iván Hi! you have the answer in the last line of code... MacdMiddle as "histo" style(histogra...
kats Le Top , a utiliser avec le nuage violet et alerte TN pour plus de précision.
Iván Hi! yes. You can ask for it here: https://www.prorealcode.com/free-code-conversion/
roccafragius Thank you so much Ivan! I created this request in english Translate from TradingView Indicat...
ipbvba Hello, Is it possible to have a screener for the various buy and sell signals?
Regisnew très bel indicateur merci

Top