TradingView
LonesomeTheBlue
Mar 21, 2020 2:03 PM

Pine Script: Live and non-repainting HTF Moving Averages Education

Bitcoin / U.S. DollarGemini

Description

Hello Everyone,

While using "Security" function for Higher Time Frames (htf) you must accept "Repainting" issue or better you must use previous day data such "security(syminfo.tickerid, 'D', close[1], lookahead=barmerge.lookahead_on)" that's best normally (or barmerge.lookahead_off). But the problem is (as you can see) it uses previous day data, and this causes latency.

So how to draw LIVE and NON-REPAINTING HTF moving averages?
Until the last candle of higher time frame all is fine and no repaint issue. when it came to last candle of HTF and if we use real data, (because of we can not know the future) while price is changing it starts drawing on each candle of current period without correcting old ones (this is repaint issue). it needs to calculate number of curent times frame candles for higher time frame and must change all points as in that period as you can see in the video (non-repainting one).

we have "50 lines" limitation in current Pine version. we hope to have unlimited lines in next version.

This work is completely experimetal.

btw Thanks to all Pine Platform Developers, They are doing very good job!


Enjoy!

Comment

Comments
flowdelta
More simply solved using an MA period on current timeframe that is equivalent to the higher TF.
For example, plot a daily (assuming 24hr market) MA on a 15m chart by using a period of 96. Similarly, a 5DMA on the 15m using an MA period of 480.

The more interesting problem is calculating an indicator with LOWER time frame data...
jackyliaw82
Thanks for the idea @LonesomeTheBlue

Too bad a strategy decision is still relying on latest repaint future data which causing false signal, the above is just to draw out a straight horizontal line so it visually looks not repainted
eraymandaci
emeğine sağlık abim teşekkürler
mamtabanjare213
how can I get your indicator
sabziali1390
tanks
S_2023_
Thank you!
More