Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String to Float Pine Script

Tags:

pine-script

Is it possible to convert String into Float or int in PineScript?

We can use str.tostring to convert float to string, but is there a way to go from string to float or int?

I want to try this as a workaround to offset value to the left. As I cant find a way to offset a value to the left, only to the right, I would like to see If I can achieve it by going from Float to String in July/2021 and from String to Float in May/2021.

like image 886
Lenon Fernandes Avatar asked Aug 11 '26 16:08

Lenon Fernandes


1 Answers

There is a built-in function for that in Pine v5. See str.tonumber()
It was also already there in Pine v4. See tonumber()

like image 52
Bjorn Mistiaen Avatar answered Aug 14 '26 20:08

Bjorn Mistiaen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!