Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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 Offline
Serious User
AndrewAMD  Offline
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