I want my indicator to do NOTHING, until the initial bars that will load on the chart happen. I.e., let's say I have the data series set to n-number of bars, or a start date... I'd like nothing to occur until those initial bars are loaded.
I've come up with things that sort of work, but don't do what I want.
E.g....
I set a global variable initially to false called 'startScript'
I then set at the top of my OnBarUpdate() like so:
if(!startScript) return;
else if (State == State.DataLoaded)
{
startScript = true;
}
else if (State == State.Transition)
{
startScript = true;
}
else if (State == State.Realtime)
{
startScript = true;
}
The State.Transition is close, but it doesn't do anything until a bar actually COMPLETES for the first time after the script is instantiated.
The State.Realtime operates in a similar fashion to State.Transition.
I.e., I don't want my script to WAIT until a bar is completed after all the bars are loaded....
I also tried using the a BarCount in State.DataLoaded, which would allow me to put a return statement in if the CurrentBar is less that that bar count I captured in State.DataLoaded, but this didn't work the way I wanted either.
So if all of the above was confusing the way I explained it... I would just like the indicator's FIRST calculation to be run as soon as all the bars are loaded onto the chart, irrespective of being connected to a data feed. And then run normally after that. is such a thing possible?

Comment