WM_USER_STREAMING_UPDATE MESSAGE notifies AmiBroker of new data sent via streaming. For symbols whose quotes change frequently, it also refreshes the charts of symbols whose quotes remain unchanged, causing additional processor load when calculating formulas. Is it possible to prevent this?
Short answer is no. Refresh mechanism is a result of in-depth development and is meant to behave correctly even if plugins are not 100% correct.
Refresh process is more complicated than you assume. First it depends how do you send WM_USER_STREAMING_UPDATE. There is difference in behavior Not only WM_USER_STREAMING_UPDATE message without wParam and lParam set to correct values and this message sent with those params set properly. Unfortunatelly many plugin writers do it wrong and AmiBroker has to somehow handle it gracefully. Also not only this message causes refresh but also other actions such as timed updates, scrolling, resizing, composite calculation and many little things you just forget because they "JUST WORK".
Chart code should be written as lightweight and not cause any problems. I can display 50 chart windows without significant load.
Ok, thanks.
Is there a difference for AmiBroker whether I use the PostMessage or SendMessage method?
You should rather use SendMessage as it is processed immediately and returns when it is done processing. That way pointers given in LPARAM/WPARAM are safe to use because they don't go out of scope. PostMessage puts the message in the application message queue, it may be processed LATER if there are other messages previously in the queue. PostMessage returns immediately and if you pass pointers to local variables via WPARAM/LPARAM they will go out of scope and cause Access Violation.
thanks again But...
In the basic WM_USER_STREAMING_UPDATE MESSAGE, we fill the WPARAM/LPARAM parameters with zero, but for GetRecentInfo, we fill the WPARAM/LPARAM parameters with a pointer to the symbol and a pointer to the RecentInfo structure (or zero and pointer to the RecentInfo structure). Should we create GetRecentInfo even if we don't use the "Real-time quote window?"