Code sample is a great idea.
This exception occurs reliably using any stock symbol, and using 5-minute or 1-minute timeframes (I have not tested other time frames).
I first noticed this when I was opening up several windows, and minimized windows I wasn't currently interested in. When switching back to the minimized windows, I noticed the exception message and starting troubleshooting. I determined that the exception would only occur during streaming while minimized.
As a simple workaround I used a try/catch around the call to SetBackgroundColor, and this did prevent the exception. However when the window was restored, none of my custom chart painting and indicators were shown (until the next streaming update or I pressed 'Run').
This test code reproduced the exception on my first try. Here are my steps:
I compiled the code, set the date range to include today, selected a symbol from my list of 5-minute data sets, minimized the window, and then waited more than 5 minutes, so that the next update would occur while the window was minimized.
CODE:
Please log in to see this code.
I've assumed that if the code can detect (windowstate == minimized) then do not call SetBackgroundColor, and then hopefully I can get a notification that (windowstate changed and != minimized) so that I can force a repaint in my code.
But perhaps this is not the best way to avoid the exception, I'm open to suggestions since I'm fairly new to this platform.
Thanks for the rapid response and help