Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, 7th_zorro, VoroneTZ, Quad), 901 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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