1

In Pine script version 6, we can define a variable with var and without var. Like this sample:

var float Number1 = 0.0

and

float Number1 = 0.0

If this variable does not need the value of the previous cycle, which one of the definitions is more efficient?

I want to see the efficiency of the difference between them.

3
  • What do you mean by efficient? Your second one is slightly slower yes, but it will also avoid the issues mentioned here: stackoverflow.com/a/76277465/21440243 Are you looking for compiling speed or something else? Commented Mar 18 at 1:57
  • Hi @Starship, I see that question, but I'm looking for the best way of coding. Actually, in PineScript, compiling speed doesn't matter, because all codes run on the Threading view server, all about resource management on server side. Commented Mar 27 at 7:53
  • What does best mean though. They both work fine as you know. The second one is I guess quicker to type…seem pretty equal Commented Mar 27 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.