OPEN-SOURCE SCRIPT

Candle Decomposition

Aggiornato
The Candle Decomposition indicator shows the last 2 candles in detail, with 2 levels of lower timeframes (LTF).

In this way, you can keep oversight of history, while zooming in on the last and previous candle.
This tool is meant to be used in realtime, preferentially for intraday usage.


🔶 USAGE

In this example, on the current timeframe of 15 minutes, you see the 2 latest candles, visualized through dotted lines/boxes.
The first LTF level is set at 5 minutes, the second level at 15 seconds:
istantanea
(The 2 exclamation marks are just to emphasize this is the latest price which will be repainted)

The combination of 2 LTF's can be helpful in finding support/resistance levels.
These are taken in realtime, not in bar replay, so the outcome wasn't known in advance:istantanea
(blue lines were drawn manually)

After first testing resistance, the price went to the support area, bouncing back to an area of resistance and breaking it briefly.
Price turned back, and found support, after which resistance was tested once more:
istantanea

Support was again tested, after which resistance was clearly broken:
istantanea

A bit later (every time 1 candle further):
istantanea
istantanea
istantanea
istantanea


The following example shows 2 last candles with signs of indecision, but LTF candles show support and resistance areas:
istantanea


🔶 IMPORTANT

PP = TradingView Premium / Professional Plan
BEP = TradingView Basic / Essential / Plus Plan

This publication uses second-based TF's, which is only available for PP users.
To ensure a smooth experience for BEP users, we have disabled the setting "Premium/Professional Plan".

BEP users will get a warning when trying to use a second-based TF.

istantanea
If possible, BEP users should use non-second-based TF's.

PP users have to enable the setting "Premium/Professional Plan".


🔶 DETAILS


🔹 Timeframes

Most common timeframes can be used: 2W, W, 3D, 2D, D, 12h, 8h, 6h, 4h, 3h, 2h, 1h, 30min, 15min, 10min, 5min, 3min, 1min
When having the current chart timeframe at 1 of these TF's, you can set 1st and 2nd LTF. Choices are pré-set to ensure maximum usage of drawings:
istantanea

In the image above you'll see there are gaps between candles.
The script ensures that when there are no trades, instead of attaching the next bar next to the previous, it leaves the gap visible (which is more realistic).

More in detail you can see the gaps are preserved:
(compared between white -current TF- candles, and LTF candles)
istantanea
istantanea


🔹 Limitations

When on a Weekly TF, and 2nd LTF is set at 4h, all drawings have enough space:
istantanea
If we change the 2nd LTF to 2h, there isn't enough space for the second last candle, after which an orange coloured informational warning label will be shown:
istantanea

When current chart TF is not 1 of the encoded TF's, a red warning text will be shown:
istantanea

This script can be used using "Bar Replay", but very limited.
You can change the date ("Jump To..."), but "Play" is not advisable.


🔹 Code

This script uses string manipulation to convert inputs like "1 hour", "5 min", "5 sec" to usable timeframe strings like "60", "5" and "5S"



Since string manipulation consumes resources, these are place in local blocks.
While inputs always will be extracted, whether it is put in an if-block or not, the string manipulation only will be executed when condition is fulfilled, in this case when we are at the right timeframe.

In following example you'll always see the '1 sec' input, on every TF, but the string manipulation will only happen when we are at a 1 minute TF:


The "visible chart function" chart.right_visible_bar_time is used to reset everything when a new candle starts. This makes sure that when using "barstate.islastconfirmedhistory", the second last bar is used. Also all lines & boxes are automatically removed, starting with a fresh slate.



If boxes/lines end up before the first bar, or after the last bar, this can be messy.
To protect ourselves against it 2 techniques are used:

math.max(0, x) is used to make sure lines & boxes don't end up before the first bar,
isOK = index < last_bar_index is used to be sure that the width of 1 candle (here index) is not wider than the total of all bars (which is the same as last_bar_index)


🔶 SETTINGS

3 columns:
  • Current TF: This columns shows you the chart TF where LTF settings are applicable.
  • 1st LTF: set the timeframe of the first level LTF
  • 2nd LTF: set the timeframe of the second level LTF

    Colours can be set for 3 timeframes

Note di rilascio
Typo fixed
Candlestick analysiseducationalmultitimeframe

Script open-source

In pieno spirito TradingView, l'autore di questo script lo ha pubblicato open-source, in modo che i trader possano comprenderlo e verificarlo. Un saluto all'autore! È possibile utilizzarlo gratuitamente, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Vuoi usare questo script sui tuoi grafici?


PineCoder: pinecoders.com

- We cannot control our emotions,
but we can control our keyboard -

Declinazione di responsabilità