This question has been asked a long time ago but because NinjaTrader has come a long way I wanted to bring it up again to see if it is possible to do this now. I'm trying to backtest a system that does the following:
- Using Daily price series as primary series
- If SMA has been rising for the last 3 bars
- AND if the Close price has been falling for the last 3 bars
- AND If the Open of the next bar is lower, buy at that price. Otherwise, if the open is higher, wait to buy the lower Close. If neither is lower, don't buy at all.
I had one idea that I tested but am not having luck with it. My idea was based on the SampleIntraBarBacktest.cs found in the NinjatTrader 8 Guide. It states in the comments in the code:
When working with multiple bar series objects it is important to understand the sequential order in which the OnBarUpdate() method is triggered. The bars will always run with the primary first followed by the secondary and so on. Important: Primary bars will always execute before the secondary bar series. If a bar is timestamped as 12:00PM on the 5min bar series, the call order between the equally timestamped 12:00PM bar on the 1min bar series is like this: 12:00PM 5min 12:00PM 1min 12:01PM 1min 12:02PM 1min 12:03PM 1min 12:04PM 1min 12:05PM 5min 12:05PM 1min
AddDataSeries(Data.BarsPeriodType.Day, 1);
I'd hate to have to resort to writing the buy/sell values to a csv and import into Excel just to get accurate backtesting data for this type of system.
Thank you!
Paul

I understand those things already but ultimately they are trying to work around the solution rather than solve it in my opinion. You can easily use Calculate.OnEachTick and check the time of day and enter a position near the close, or check if it is the first tick of the bar as you mentioned and enter a position on the open etc, but the real topic at hand here is not real time, it is backtesting these types of systems to understand the profile of the system before trading in real time. This is such a vital step that I feel strongly that it deserves its own behavior in the code.
Comment