allanster

How To Color Prior Bars

allanster Wizard Zaktualizowano   
Example how to color the trigger bar of the condition and n-1 prior bars using only 1 barcolor() function.

Currently when offsets are used in barcolor(), bgcolor(), plot(), plotarrow(), plotchar(), or plotshape(), the offset only works with a simple (static) integer. If series (dynamic) integers are used instead, there is not an error, but the series values are ignored. Because of this limitation of offset being constrained to using only fixed offsets, the normal way to paint 3 Black Crows would be to use 3 barcolor() functions. Since there are a known number of bars to be painted in that scenario, this can be easily accomplished.

If a condition encompassed a variable length of n bars, then the number of barcolor() functions needed to use would be unknown. How to color the trigger bar of the condition and n-1 prior bars using only 1 barcolor() function? Dual examples below solves issue but requires n "future" bars, because of this it will not paint the most recent condition in realtime and may not be applicable for use in certain realtime situations. It paints similar in behavior to how a pivot does. Special thanks to LucF and RicardoSantos for illumination!

NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Informacje o Wersji:
Updated for Pine Script v5.
Informacje o Wersji:
Cosmetic.

Telegram: t.me/allanster • Website: www.allanster.com

If you wish to buy me a refreshing beverage :)...

LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y

BTC: 13LhkeXBYrRomVAqbXcoLXHuqMk6Mf7G6N
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?