I have a question, and am just looking to see if there is some obvious way of doing this that I have not thought of?
But, I would like to draw objects, that are only PARTIALLY on the screen. Attached is an image of a chart, where you can see it technically STARTS off screen.
Obviously, I'd like to take advantage of the EFFICIENCY that comes with only rendering what is visible to the user, instead of storing a million drawn objects in memory at all times.
To further explain, imagine an indicator that only renders something on each bar. Also attached is a screenshot of such an indicator, where it simply draws a dot on the bottom of the screen, that is the width of the bar. This is simple, as I just have a dataseries that stores a value, and I simply loop through the visible bars on the chart within OnRender(), and draw a dot based on various conditions.
And example would be like this:
int rightMostBar = ChartBars.ToIndex;
int leftMostBar = ChartBars.FromIndex;
for (int i=leftMostBar; i <= rightMostBar; i++) //Start at necessary List position
{
if(dataSeries[i] == 1)
draw red dot;
else
draw blue dot;
}
But this seems somewhat complex, and I wonder if there is a simple way to do this that I am failing to think of? Any ideas on the best way to accomplish what I am trying to do? Just looking for basic ideas, code not necessary.
If it were JUST A LINE, I could potentially still use a single dataSeries, and just connect the individual elements of each point on that line. But this isn't possible with a more complex shape like a box.
Second question... is rendering something to ONLY the visible bars ALWAYS more EFFICIENT? I.e., imagine the typical VWAP indicator, or even a simple moving average... If you create the SAME indicator, but push everything to OnRender() to display only what is visible to the user, is it always going to be more efficient and easier to run?
Asking as I have many charts on screen, and I am going to recreate some of these indicators that use VWAPs, but push everything to OnRender().
To recap:
1) Is there an obvious way to render something to screen that is only PARTIALLY visible?
2) Is OnRender() always going to be more efficient than drawnObjects or Plots(E.g. moving averages)?
Thanks,
FP

Comment