I’ve put out RWT-004 on the best-of page. This one is about how slow and redundant the typical Ninjatrader idiom for referencing indicators can be:
SMA(Close,5)[0] > SMA(Close,5)[1]
In one case, an apparent bug in ninja’s magical “don’t touch this” area broke code I had written in this fashion. The paper describes the issue, and tells how I now do all of my indicator references in ninjascript.
Here’s a direct link to the paper if you are too lazy to look in the list: RWT-004
why wait for OnBarUpdate() to initialize your indicators, you can do it in Initialize() and it works fine. at least, I haven’t seen any problems doing it this way.
You know, I did that first since it seems more natural, but on ninja6 I had calculation order issues about 1/3 of the time. Enough to annoy me. Maybe ninja6.5 is better about it, but I haven’t tried it that way again. I figure the method I’ve outlined is more future-proof since it assumes less about ninja’s initialization sequence. It calls upon the indicator in the same context that their tutorials and prepackaged indicators do.
Part of the problem of doing things in Initialize() is that that method is called when you just open up the indicators dialog. I was opening a file in Initialize once and kept seeing the output dialog show it and finally realized that it was happening whenever I opened the indicators dialog. Not what I wanted :) So… as far as I understand, Initialize should only be used for defining stuff like inputs, plots, flags, etc.