This is my first post here and I'm happy that I found this forum

My coding knowledge is not that good and what I'm doing mostly is searching for indicators that would have the results that I want and try to combine the lines with other indicators so it results in something that I'm looking for.
I am looking for some help regarding the timeframe format. Anyone know what lines I should have in the following code in order to see the timeframe format similar to the instrument "Measure" (1d 10h or 1d only or 3h only) ?
Currently the format is "7.33" for 7d 4h (if I use Measure instrument) and I don't know how to round it.
Code: Select all
above_since = (time - ta.valuewhen(ta.crossover(close, sma200), time, 0))/1000/3600/24
below_since = (time - ta.valuewhen(ta.crossunder(close, sma200), time, 0))/1000/3600/24
cond = math.round(close, 5) > math.round(sma200, 5)
string above_below_string=close < sma200 ? "d/h/ BELOW" : "d/h/ ABOVE"
var ma_table = table.new(position.top_right, columns = 10, rows =24, bgcolor =color.new(color.gray, 74), border_width = 1)
table.cell(table_id = ma_table, text_color = color.white, column = 2, row = 2,text = str.tostring(math.round((cond? above_since:below_since),2)) +' ' + above_below_string, bgcolor=cond ? color.green : color.red, text_size = size.normal)
I found a script that has the outcome that I would like but I'm not that good to take the exact lines and add them in my indicator. In the labels of this script we can see the timeframe as "20.5 hours" or "4.6 days"
https://www.tradingview.com/v/9NXf1Bqb/ - Zendog V2 backtest DCA bot 3commas
Whatever solution anyone suggest that could improve the timeframe format I will accept, I just posted an example so maybe it could be easier to understand

Thank you in advance!