Is there a better way to deal with Warning 512?

My code requires me to use set foreign function 12 times and when I did I noticed this warning pop up. I want to know if there is another way to do what I am doing more efficiently and what could be the implications of this warning.


1 Like

search the forum

Basics: Error, warning, notice - AFL Programming - AmiBroker Community Forum

People may stop responding with replies if you post questions like this.


a SetForeign will be called about 60x every minute (cmiiw)
i'm thinking about setting a counter using staticvarset

so we only call the SetForeign every 2 secs or 4secs
and save the values using staticvarset as well.

maybe applying schedule for each setforeign will help
for example, 4 SetForeigns will run at 1st sec, 4 at 2nd sec and so on.

i noticed MA's value are not significant vary across the time
so no need to call SetForeign every second to get MA's value.
in case you only need MA's value, i think we just need to call SetForeign every 60secs. (applying counter using staticvarset) and store the value using staticvarset as well.

i'm gonna try code it and see how it work

1 Like

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

In short: POST the code.

How many core do you have on your cpu ?

I'm trying to split my 32 SetForeigns into two charts.
(since i only have two cores CPU).

I'm gonna get 8 cores new laptop and split my AFL into 8 charts, assign 4 SetForeigns for each 8 charts, to see how it come up.
(i do have Amibroker Professional Edition)

Reading from this article, i assume it will help


btw, did you call 1 Setforeign 12 times in a loop ?
call 12 Setforeigns once ?

Did you read the thread that was pointed out to you:

In short: a warning is not an error.

Yes. I read the thread and I am aware that it is just a warning and it won't hinder my code but I just wanted to know if there is a way to make my code more efficient because the warning mentions that cuase of using setforeign function for many times..code would be inefficient.


I called 12 Setforeigns once.

@ab-ami I have a 12core cpu with 24 threads.

It doesn't matter how many cores you have in that case. There is a rule one chart pane - one thread. Cores would only matter if you run multiple chart panes. SetForeign by nature accesses single shared resource (database) and you are limited mainly by RAM bandwidth, not by anything else.