TradingView
Duyck
Feb 9, 2021 11:11 PM

MTF seconds values - JD 

Bitcoin / TetherUSBinance

Description

[u]Add MTF capabilities to "seconds" timeframes!![/u]


This script is not intended to be used as an indicator but gives you a workaround to solve the missing seconds MTF capabilities.


The "resolution" function in Pinescript doesn't allow for seconds values to be put in MTF
So I wrote a little helper code with arrays to get MTF on seconds timeframes.


If you want to add MTF in minutes, hours,... you can always add ' resolution = "" ' to the study line of the script



With these arrays of MTF values you can perform various calculations.

As an example I plotted the sma from the MTF values on the chart, but you can add anything you want that you can calculate from the array values.



Have fun with it !

Gr, JD.

Release Notes

.
Comments
PineCoders
Duyck
@PineCoders, thank you very much! X
slowcoconut
Great work.... inspired stuff for sure... I'm a big fan of timeframes < 1min so this is a great help, ty

I did encounter an issue recently when trying to use this to create custom low timeframe oscillators and fib-based bollinger bands.

...it seems that there is an issue when using built-in functions like ta.stoch,ta.sma,ta.ema with this array data... I can change the period/length to accommodate the additional candles (i.e., 30 second, length 20 => 15 second, length 40) but ultimately the calculations do not match-up between timeframes...I tried calculating all values only 'if new_bar' but the values/moving averages do not match up exactly and the oscillators using these values lose some of their reactivity to price...any idea how to remedy this?
thanks again Duyck!
Jittra
Welcome back.
Duyck
@Jittra, thx, never really was away, just occupied with different stuff for a while! ;-)
PineCoders
This publication is now featured in our Editors' Picks: tradingview.com/scripts/editors-picks/ .
In the name of all TradingViewers, thank you for your valuable contribution to the community, and congrats!
Duyck
@PineCoders, Thx for the support, glad if I can help!

Gr, JD.
More