I have som thoughts about best practice for programming computational efficient indicators for the NT Strategy Analyzer (as well as for real time trading).
1. What is the most efficient output Class? Is a DataSeries more efficient than a StringSeries for instance? Would it be eaven less expensive to expose just a double?
2. I think I have read that it's important to turn off draw objects and print statements in the code. But what about plots? Since the plot Collection holds an infit number of bars I understand that a plot is more expensive than a DataSeries with 256 bars. But how expensive is the plotting itself compared to a non plotting DataSeries with MaximimBarsLookBack = Infinite? If you just call the indicator in a strategy, but don't add the indicator to a chart, will the computational cost needed for plotting be avoided?
3. I do nest indicators frequently. What is the most efficient way to call an indicator from another indicator?
I have read this article: http://www.movethemarkets.com/downloads/rwt/rwt004 that argues that you should avoid to use indicators "in-line" in the OnBarsUpdate() method. Instead they recomend that you declare the indicator as a varaible of the calling indicator and initialize it in the OnStartUp() mehod of the calling indicator. The reason for this would be to prevent the strategy analyzer to create a lot of unnecessary instances of the indicator during backtesting? Do you agree?
4. I have recently started using the System.Collections.Generic List < T > Class and the Dictionary Class in my programming. I read in a post in this forum that the Strategy Analyzer doesn't automatically Dispose objects from these calsses as expected in c#. If so, what code should I put in the OnTermination() method to make the NT7 Strategy Analyzer properly Dispose a Lists or a Dictionary after each "loop"? Would these two lines be sufficient?
protected override void OnTermination() { // Dispose List myList = null; System.GC.Collect(); }
Comment