OPEN-SOURCE SCRIPT

Candle Decomposition

アップデート済
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:
スナップショット
(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:スナップショット
(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:
スナップショット

Support was again tested, after which resistance was clearly broken:
スナップショット

A bit later (every time 1 candle further):
スナップショット
スナップショット
スナップショット
スナップショット


The following example shows 2 last candles with signs of indecision, but LTF candles show support and resistance areas:
スナップショット


🔶 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.

スナップショット
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:
スナップショット

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)
スナップショット
スナップショット


🔹 Limitations

When on a Weekly TF, and 2nd LTF is set at 4h, all drawings have enough space:
スナップショット
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:
スナップショット

When current chart TF is not 1 of the encoded TF's, a red warning text will be shown:
スナップショット

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

リリースノート
Typo fixed
Candlestick analysiseducationalmultitimeframe

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?


LuxAlgo Dev: luxalgo.com
PineCoder: pinecoders.com

- We cannot control our emotions,
but we can control our keyboard -
他のメディア:

免責事項