CALobo

string2float v1.0

CALobo Actualizado   
In the v5 version of PineScript, casting a string to a float - float(x) - does not appear to work, in spite of the reference manual seemingly indicating that it should. The simplest test case that I could generate "float('4750.0')" would result in a "Cannot call 'float' with argument 'x'='4750.0'. An argument of 'literal string' type was used but a 'const float' is expected." Since I was pulling the floats from a string array, I could not find a way to make them into "const floats". So I gave up and wrote a quick and dirty string to float converter function that handles both positive and negative integers and floats and returns the a float. Hopefully it might save someone else an afternoon of insanity.... :-)
Notas de prensa:
It's been pointed out that I missed the str.tonumber() function in my quest to convert a string to a float.... The update version 2.0 of the script tests out this function - see line 62 where it changes the str2float() function call to the built in function str.tonumber(). I'm happy to say that the revision passes all the tests and that this script/function/library can now be retired. I've left the code here in case some else has a similar problem, or wants to see how the str.tonumber() function call might be implemented...
Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?