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 -
يعمل أيضًا:

إخلاء المسؤولية