If you aren't familiar, but want to have a crack at solving this problem, just put this code in the OnBarUpdate() method:
[COLOR="DarkRed"]Print("CurrentBar: "+CurrentBar);[/COLOR]
This is what is causing my problem. On every pointer update (this is not a new tick update), the indicator processes all the bars up to the CurrentBar reference. My indicator requires a minimum of 41 bars, so I have the code,
[COLOR="DarkRed"]if (CurrentBar < 41) return;[/COLOR]
The problem is, it is common to have 300-500 bars on the chart when using the indicator. So, what happens is, on bar reference 41, it process those 41 bars, then 42 bars, then 43 bars, then 44 bars, etc., until the CurrentBar pointer finally hits the most recently closed bar on the chart.
This results in, every time I drop my indie on a chart with a reasonable number of bars, or change any of the settings, I have to sit and wait about 5 minutes for it to update. I tried once with loading 500 bars on my chart, and I ended up waiting about 30 minutes before it finally displayed. So, the problem is a pretty big one.
Now.....whatever you do......do NOT tell me increase the minimum number of bars required for CurrentBar. Telling me this means you haven't given this issue any serious thought. The number of bars on the chart must be allowed to change, and I cannot know what the end users will have on their charts. The issues being, if I set the minimum required number too high, then they may not be able to load enough data. If I set the minimum number too low....then they could be waiting for a couple hours because they had to change a setting in the indicator.
So, here is what I need to know: Is there a way to instantly get a value for the total number of bars loaded on a chart? And, as I just got through pointing out, CurrentBar does not give this value instantly. It recursively processes through every bar on the chart before reaching the last bar.
ANY useful ideas to solve this issue will be greatly appreciated!
Comment