Realtime chart refresh interval - feature request

image

I request to be able to change this time below a second and not only very fast (0) and slow (1s, 2s ...).
thanks!

@jcorniko, this was already discussed and referenced multiple times in the forum...

See: Sub-second TImed Refresh via Registry - #11 by Milosz

RequestTimedRefresh and Realtime chart refresh are not the same.
For example, with ReqeustTimedRefresh(1) and Realtime 0, I don't slow down chart refresh to 1 second.

I don't see any reason to change this.
In majority of cases you should just use 0.
The setting of 0 means "adaptive".
With this setting there is no constant refresh interval. If your formulas are efficient you can get as much as 10x per second refresh or even more. If formula is slow, then it refreshes in proportion to its execution time.

Besides, with multi-threading enabled, every chart pane has independent refresh rate (if it is fast it is refreshing faster than others), so this setting has historical meaning and can only be used to slow down refreshes.

@jcorniko, If I understand correctly, you are looking for a way to "slow down" the RT update but still keep it under a second (and not as efficient as possible as said by @Tomasz).

In such a case, personally, I would try to add some (useless) expensive operation in terms of calculation to the formula to see if it is actually possible to slow down the refresh - but I guess that's not a great idea...

That's because my data plugin is very fast and I don't always need that speed. If the chart refreshes very fast, the formula is also recalculated very fast and it overloads the computer.

You are approaching the PLUGIN problem from wrong angle.
If your plugin is sending too much updates, you can send less WM_USER_STREAMING_UPDATE messages from your plugin.

1 Like

Ok, that's what I'll do, although I thought the "slow down" function via AFL could be useful, such as "slow down chart refresh when you don't expect autotrading" :slight_smile:

You love to talk just for the sake of having something to talk, right?

No, don't do this. If you need to waste time in the formula use ThreadSleep() - this at least does not use CPU and electricity. Take care for the environment. We have only one planet, don't waste electricity on doing busy-waiting and burning CPU for no reason. (Yes I share the opinion that cryptos are bad idea for sole reason of burning so much energy for no purpose)

2 Likes

@Tomasz, thanks for this tip.
In fact, the first thing that came to mind was ThreadSleep (), but when I read the documentation, specifically this step:

Works only from NON-UI threads. When called from UI thread the function does NOTHING and returns immediatelly

I assumed that calling it in a formula that updates a chart (a UI thread in my perception) wouldn't cause any delay, returning immediately.

So it seems that I have misinterpreted the above quote.

Could you please elaborate further in what cases when we work with AmiBroker we are dealing with NON-UI threads and/or point me to additional documentation to better understand when it is OK to "sleep" and when it does not really affect everything? Thank you.

No, you misunderstand what UI thread is. UI thread is for User Interface (handling buttons, menus, etc elements of Windows UI). There is one and only UI thread in the application. All the remaining threads are worker threads (NON-UI). Charts DO NOT use UI thread if multi-threading is enabled.

image

2 Likes

image

Tomasz, I have did this on data plugin level, but what is the best way to control this from AFL?

The only general purpose function that data plugins expose to AFL formulas is GetExtraData. It wasn’t meant for changing settings in the plug-in, but nothing stops you from (ab)using it :wink:

1 Like

Done! I send AFL e.g. GetExtraData("setSlow") and plugin changes the parameters. Thanks for the idea. It is unbelievable that after so many years you still remember everything and know everything about AmiBroker.

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