1. When an indicator method is encountered in a strategy (e.g. SMA(Period)), the program checks to see if that indicator already exists in the cache, and if it does, then the indicator's OnBarUpdate( ) is run. If that indicator is NOT found in the cache, then a new indicator object is initialized, and then the indicator's OnBarUpdate( ) is run for all bars up to the current bar.
2. Code from an indicator's OnBarUpdate( ) does not run in the background at the close of each bar, but rather only runs when the indicator is referenced in the strategy's OnBarUpdate(). This distinction is obvious in situations when an indicator is only called sporadically from the strategy. For example, let's say you have anything like this in your strategy:
OnBarUpdate() { //statements ... If SMA(Period)[0]>X If EMA(...) //Do something }
If anyone has other details they know of, please let me know.
My particular questions at this point are:
1) Is there a way to make the indicator run in the background so it does not need to "catch up" when it is later called?
2) Does anyone have any info on how Ninjascript handles "catching up"? I can't imagine this being more efficient than simply calculating on each bar in real time in the first place. Even in strategies' that call an indicator every single bar, the check to see if the indicator is up to date will take a toll (although slight one).
Comment