Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, 1 invisible), 1,423 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Variable scope #475676
01/03/19 03:59
01/03/19 03:59
Joined: Jan 2019
Posts: 12
F
First Offline OP
Newbie
First  Offline OP
Newbie
F

Joined: Jan 2019
Posts: 12
If I set variables in the 1st execution of the run() function, will the variables retain their 1st run values on subsequent runs of the run() function or do I need to somehow make them global so they cannot be changed between subsequent runs of the run() function?

Re: Variable scope [Re: First] #475677
01/03/19 04:15
01/03/19 04:15
Joined: Feb 2017
Posts: 1,731
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,731
Chicago
Use static to retain latest value, else it is lost once it goes out of scope.

Re: Variable scope [Re: AndrewAMD] #475679
01/03/19 04:24
01/03/19 04:24
Joined: Jan 2019
Posts: 12
F
First Offline OP
Newbie
First  Offline OP
Newbie
F

Joined: Jan 2019
Posts: 12
I am using static, however, I set the value after its initalization in the 1st run of the the run() function.

On subsquent runs of the run() function as set by the BarPeriod = 30, will Price be zero or the value from priceHigh() set in the first iteration of the run() function?

I need it to be the value from priceHigh() in the first iteration.

In the run() function:

static var Price = 0;

Price = priceHigh();


Last edited by First; 01/04/19 01:12.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1