TradingView
RicardoSantos
25 sep 2019 09:48

Function - Number of Digits in integer 

Euro Fx/U.S. DollarFXCM

Beskrivning

A improvement to previous script:
tradingview.com/script/Nebq5gB8-Function-Integer-Number-of-Digits/

This uses a algorithmic approach for calculating the digits in a integer.
Kommentarer
Epi_
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)

Hope this helps!
RicardoSantos
@Epi_, sure, many ways to skin a cat :)
ahmadnaderi1994
@Epi_, i want to find close price exactly at 26th candle late how can i calculate"?
Epi_
@ahmadnaderi1994, please see my PM
ahmadnaderi1994
@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
Mer