Large data inside afl -> Amobroker crashes

Hi everyone,
Im trying to test an idea of trading US stoks (on Days) based on its fundamental data.
For those I used python to generate a really huge (14Mb) the part of afl script like that:

switch (Name()) 
case "A":

case "AA":

For each tiker it returns its corresponding data of strings.
As you can guess amibroker crashes after I start to backtest it even though I have 20GB of RAM.
Any Ideas how to solve that?
(I start thinking to use static var and to load a separate file with those strings)
I would be glad for any advise. Thank you!

I use AB 6.18 64bit.

You might be running out of stack space because to parse files AmiBroker needs a stack and stack in Windows is 1MB per thread regardless of how much RAM you have. 64-bit version is actually worse because 64-bit apps need 64-bit addresses to be stored ON STACK, so they use stack space twice as fast. To address this difference 64-bit version of AmiBroker uses 2MB per thread stack.

To minimize the stack being used, don't create a single switch statement with 14MB worth of case clauses. Divide that single huge switch into several smaller pieces - I suggest less than 1000 case clauses or use simple if:

n = Name();

if( n == "A" ) .... do what ever
if( n == "AA" ) .... do what everelse

(Note that I did not use else because nesting else zillions of times also needs lots of stack)


It appears that all your data is time series numeric data. Personally, I would have imported this into your database under an artificial ticker symbol, like A-FUN for they symbol A, AAPL-FUN for the symbol AAPL, etc.

1 Like

That is the fastest option! Thanks!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.