Most commonly, I think strategies are based on the last, maybe couple hundred, ticks/bars. Within a strategy, it would be completely fine to simply query that from your data provider, or (better) load it from a database within NinjaTrader.
I would like to have access to a full set of historical data, however. For simplicity, assume I want to have historical tick data for the last year available, for each and every decision whether to open/close/modify a position. Assume it's a 24/7 market like Forex and there's one data point (bid/ask, 4 byte each) per second, that's around 240 MiB of data per year. I don't want to load this from a database every few seconds, and I certainly don't want to query that from a data provider every couple of seconds, even if it were possible. I want to keep that in memory, between decisions. Of course, that data will change. Between one decision and another one in 10 seconds time, there will be new market data incoming, so my array of data points will need to be updated for the next decision.
For backtesting, assume I have data available for the last two years and want to backtest on the last year. Then, the system needs to load the appropriate time frame for each point in time tested during backtesting, of course.
To summarize, my questions are:
- Does NT have the option to save historical quotes to a database on the local disk?
- Can I load this database into an array inside my script, available statically for each execution of the script (i.e., for each decision taken, without loading all the data from the DB each time)?
- Can the DB be updated while an automated strategy is running, using real-time data? The essential point is that the array from the previous question can be updated in real time.
- While backtesting, can NinjaTrader handle to simulate above behaviour? Say backtesting starts one year back, then initially, the data between one year back and two years back needs to be loaded into the array, and for the tests on later points in time, it needs to be updated by adding historical data and the script should never be able to see data from the "future" while backtesting, of course.
Comment