CALobo

string2float v1.0

CALobo 업데이트됨   
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.... :-)
릴리즈 노트:
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...
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?