Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (frutza, Quad, AndrewAMD), 385 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Populating an array of dynamic size on each run of run() #482425
02/04/21 09:08
02/04/21 09:08
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline OP
Newbie
strimp099  Offline OP
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
Greetings,

My intent is to populate an array with option strikes for daily run. However I receive a syntax error when attempting to create an array like this:

Code
var strikes[NumContracts];


presumably because arrays are static and cannot be redeclared. According to the manual, using malloc to allocate space dynamically is slow. So something like this:

Code
var strikes = malloc(NumContracts*sizeof(var));


Is not recommended

Is there a standard way to dynamically create arrays during each run?

Re: Populating an array of dynamic size on each run of run() [Re: strimp099] #482426
02/04/21 10:48
02/04/21 10:48
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
may be series?

Re: Populating an array of dynamic size on each run of run() [Re: Grat] #482428
02/04/21 11:30
02/04/21 11:30
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline OP
Newbie
strimp099  Offline OP
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
I’m trying to create an array of strikes each day. Can I do that with a series?

Re: Populating an array of dynamic size on each run of run() [Re: strimp099] #482430
02/04/21 13:40
02/04/21 13:40
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Allocations are slow.

The trick is to use a fixed-size buffer and only use as many elements as you need per run.

Incidentally, the maximum number of contracts available at any given run is MAX_CONTRACTS, so use MAX_CONTRACTS for your number of fixed buffer elements.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1