Hello Ricardo,
A very useful script, as always :-)
In this case, the calculation can be done in a simpler way, using the change of base formula with algorithms, for both integer and float values:
study(title="Function - Number of Digits",shorttitle="N",overlay=false,precision=0)
src = input(close,title="Source",type=input.source)
NDigits_f(_src) => 1+floor(log(_src)/2.30258509) // or 1+floor(log(_src)/log(10))
NDigits = NDigits_f(src)
plot(NDigits,title="N° of digits",color=color.blue)
@Epi_, @Epi_, Hello First of all, thank you for your response, I want the closing price of my 26th candle compared to the current time step. My goal is to create conditions that should be higher than the closing price of the previous 26 candlesticks. Thanks Ahmad
A very useful script, as always :-)
In this case, the calculation can be done in a simpler way, using the change of base formula with algorithms, for both integer and float values:
study(title="Function - Number of Digits",shorttitle="N",overlay=false,precision=0)
src = input(close,title="Source",type=input.source)
NDigits_f(_src) => 1+floor(log(_src)/2.30258509) // or 1+floor(log(_src)/log(10))
NDigits = NDigits_f(src)
plot(NDigits,title="N° of digits",color=color.blue)
Hope this helps!