I wonder if there is a more efficient way to process these value just once, instead of during each OBU for realtime data?
In my mind, it seems since this indicator is only dealing with historical values, it should not be called by OBU realtime. But maybe I don't completely understand the lifecycles of historical vs realtime.
My understanding:
When a chart with this indicator is at state.DataLoaded, the code will iterate through the historical bars, and find the open, high, low and close during each historical bar's OBU event, and update the plot values.
Then it will switch state to realtime, and for each bar drawn by the realtime (new incoming data), it continues to update it's plot objects. At my current level of understanding this seems like a waste of CPU & Memory resources.
Is there a code example that would only run once, that would draw a line, instead of a continuous plot, and when state = Realtime, this code would stop running?
I copied the indicator and added a test of
state == state.realtime { return; }
I need help understanding that concept.
Is drawing a ray instead of a plot more efficient?
thanks
Comment