Using loops instead of array processing. Was: slow performance when switched to hourly bar view

I imported forex hourly bars into Amibroker through ASCII.

When I view the 1-hourly bars, Amibroker becomes slow and sluggish. It takes noticeable time for the vertical selection line to move when I click the mouse to a new location. In daily/weekly mode, there is no problem with the speed. This slow speed problem appears only during for hourly bars. I notice that there are about 37000 bars in hourly view. There are only 1571 bars in daily view. Is too many bars the main cause for the sluggishness?

I am using Intel I7 chip, 16G RAM, SSD. It is certainly not a slow PC.

What are some settings to optimize to improve the speed in hourly intra-day view?

I am using Amibroker ver6.29

Weak AFL code... that is the most probable cause in majority of cases.

Improve your code first (then hardware)!

Look at below video(s)...
I can browse through millions of data bars without recognizable lag.
Look at entire array size of over 6 Million 1-minute bars (at last bar location)!
Look at selector line... "zero" lag.

Test hardware:
10 years old(!) dual core and 4GB RAM!

Do you see any (noticeable) selector line lag where you would say "Oh man, why is that soooooo slow"? When using proper glasses then I would respond "I don't think so" (and I am using proper glasses).

Now think about what would happen when I would make another video using most recent hardware...

(Note: I had to make multiple short gifs otherwise gif size would explode and because of 500KB size per picture restriction).



Now look at number of visible bars in next two ones (200,000 to 500,000 visible bars!)




@thankyou18 AmiBroker is probably the fastest technical analysis software on the market, so the problem is on your end. Your code must be very inefficient. For instance it might contain several nested loops used instead of array functions and/or many, many other problems ...

There are several articles on this topic available. I have provided links to some of them and a few suggestions how to cope with selected efficiency issues in this reply: How to check if the code is efficient - you might find it useful.

1 Like

I also believe the problem lies with my AFL code. I have been using Amibroker for several years, so I am no stranger to its speed and efficiency. I was hoping there could be some settings that could improve the situation for the time being.

@thankyou18 if you fuel your Ferrari with cooking oil instead of good fuel, there aren't many settings allowing to reach it's top performance :wink:

But seriously - there are lots of things that you could do, but nobody is able to help you if you provide zero necessary information. If I were you I would start from pasting your code here or if it's a secret, from using Code Check & Profile as suggested in my link above. This might help you to identify the reason of the poor performance..


Besides, check if there is SetBarsRequired(-2,-2) or SetBarsRequired(sbrall, sbrall) or RequestTimedRefresh() etc. in your code ...

For monitoring real-time performance, you can also use:

Performance Monitor :


... and Performance indicator :


1 Like

I discovered the cause of the slowness. Basically, it's caused by not using amibroker array and using for-loop instead.

Thanks for all the replies.