Volume Delta Trailing Stop [LuxAlgo]

The 'Volume Delta Trailing Stop' indicator uses Lower Time Frame (LTF) volume delta data which can provide potential entries together with a Volume-Delta based Trailing Stop-line.


Our 'Volume Delta Trailing Stop' script can show potential entries/Stop Loss lines

A trigger line needs to be broken before a position is taken, after which a Volume Delta-controlled Trailing Stop-line is created:


🔹 Volume rises when bought or sold

🔹 When the opening price appears on the chart, a buy/sell order has been executed.
If that order is less than the available supply of that particular price, volume will rise, without moving the price.
🔹 When the opening price is the same as the closing price, the volume of that bar can be seen as "neutral volume" (nV); nor "up", nor "down" volume.

A buy order doesn't fill the first available supply in the order book. This price will be the opening price with a certain volume.
When at closing time, price still hasn't moved (the first available supply in the order book isn't filled, or no movement downwards),
the closing price will be equal to the opening price, but with volume. This can be seen as "neutral volume (nV)".
🔹 Delta Volume (ΔV): this is "up volume" minus "down volume"

🔹 Standard volume is colored red when closing price is lower than opening price ( = "down volume").

🔹 Standard volume is colored green when closing price is higher OR equal (nV) than opening price ( = "up volume").

🔹 Neutral Volume

The "Neutral-Volume" is considered "Up-Volume" - setting will dictate whether nV is considered as green 'buy' volume or not.


29 July 10:00 -> 10:05, chart timeframe 5 minutes, open 29311.28, close 29313.89

close > open, so the volume (39.55) is colored green ("up volume").
(The Volume script used in the following examples is the open-source publication Volume Columns w. Alerts (V) from LucF)

Let's zoom to the 1-minute TF:
The same period is now divided into more bars, volume direction (color) is dependable on the difference between open and close.
Counting up and down volume gives a more detailed result, it remains in an upward direction though):
(ΔV = +15.51)

Let's further zoom in to the 1-second TF:
The same period is now divided into even more bars (more possibility for changing direction on each bar)
Here we see several bars that haven't moved in price, but they have volume ("neutral" volume).
(neutral volume is coloured light green here, while up volume is coloured darker green)
When we count all green and red volume bars, the result is quite different:
(ΔV = -0.35)
In total more volume is found when price went downwards, yet price went up in these 5 minutes.

-> This is the heart of our publication, when this divergence occurs, you can see a barcolor changement:

    • orange: when price went up, but LTF Volume was mainly in a downward direction.
    • blue: when price went down, but LTF Volume was mainly in an upwards direction.

When we split the green "up volume" into "up" and "neutral", the difference is even higher
(here "neutral volume" is colored grey):
(ΔV = -12.76; "up" - "down")


bullishBear = current bar is  red  but LTF volume is in  upward direction ->   blue bar
bearishBull = current bar is green but LTF volume is in downward direction -> orange bar

🔹 Potential positioning - forming of Trigger-line

When not in position, the script will wait for a divergence between price and volume direction. When found, a Trigger-line will appear:

• at high when a blue bar appears (bullishBear).
• at  low when an orange bar appears (bearishBull).

Next step is when the Trigger-line is broken by close or high/low (settings: Trigger)

Here, the closing price went under the grey Trigger-line -> bearish position:

🔹 Trailing Stop-line

When the Trigger-line is broken, the Trailing Stop-line (TS-line) will start:

low when bullish position
high when bearish position

You can choose (settings -> Trigger -> Close or H/L) whether close price or high/low should break the Trigger-line

When alerts are enabled ("Any alert() function call"), you'll get the following message:
• 'signal up'  when bullish position
• 'signal down' when bearish position

After that, the TS-line will be adjusted when:
• a    blue    bullishBear  bar appears when in bullish position  ->  lowest   of {low , previous blue bar's high or orange bar's low}
• an orange bearishBull bar appears when in bearish position -> highest of {high, previous blue bar's high or orange bar's low}

When alerts are enabled ("Any alert() function call"), and the TS-line is broken, you'll get the following message:
• 'TS-line broken down'  when out bullish  position
• 'TS-line broken up'       when out bearish position

🔹 Reference Point

Default the direction of price will be evaluated by comparing closing price with opening price.
When open and close are the same, you'll get "neutral volume".

You can use "previous close" instead (as in built-in volume indicator) to include gaps.
If close equals open, but close is lower than previous close, it will be regarded as "down volume",
similar, when close is higher than previous close, it will be regarded as "up volume"

Note, the setting applies for the current timeframe AND Lower timeframe:

Based on: "open" (close - open)

Based on: "previous close" (close - previous close)

🔹 Adjustment

When the TS-line changes, this can be adjusted with a percentage of price, or a multiple of "True Range"

Default (Δ line -> Adjustment - 0)

Δ line -> Adjustment 0.03% (of price)

Δ line -> Mult of TR (10)


🔹 LTF: choose your Lower TimeFrame: 1S (seconds), 5S, 10S, 15S, 30S, 1 minute)

🔹 Trigger: Choose the trigger for breaking the Trigger-line; close or H/L (high when bullish position, low when bearish position)

🔹 Δ line (Trailing Stop-line): add/subtract an adjustment when the TS-line changes (default: Adjustment):
• Adjustment (default: 0): add/subtract an extra % of price
• Mult of TR                     : add/subtract a multiple of True Range
🔹 Based on: compare closing price against:
previous close
🔹 "Neutral-Volume" is considered "Up-Volume": this setting will dictate whether nV is considered as green 'buy' volume or not.


🔹 The lowest LTF (1S) will give you more detail and will get data close to tick data.
However, a maximum of 100,000 intrabars can be used in calculations.
This means on the daily chart you won't see anything since 1 day ~ 86400 seconds. (just over 1 bar)
-> choose a lower chart timeframe, or choose a higher LTF (5S, 10S, ... 1 minute)
🔹 Always choose a LTF lower than the current chart timeframe.

🔹 Pine Script™ code using this request.security_lower_tf() may calculate differently on historical and real-time bars, leading to repainting.

Get access to our exclusive tools:

Join our 150k+ community:

All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?