Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

NinjaScript Feature Availability

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NinjaScript Feature Availability

    I have a question about whether a feature is available within NinjaScript.

    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.

    #2
    Originally posted by Aristotle View Post
    I have a question about whether a feature is available within NinjaScript.

    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.
    Your questions:

    (1) Yes. NinjaTrader 7 cannot store synchronized bid and ask data locally. However, it does store trade data, but you will not know whether the trade took place at the bid, the aks or in between. NinjaTrader 8 stores bid and ask data which is synchronized with trade data. It won't show changes of bid/ask when no trade occured.

    (2) Yes. The data is loaded into an array when the chart is setup. Depending on the selected settings for MaximumBarLookBack you will be able to access the last 256 bars or all bars of the chart (more RAM intensive).

    (3) Yes. The data base which is built from historical data (no intra-bar data, but OHLC + volume for each historical bar) is updated with real-time data (uses more RAM as it contains every single tick). Your database then contains historical bars, followed by a single hybrid bar (historical data completed with real-time ticks) and then followed by real-time data. The frontier between historical and real-time data can be shifted via F5, which triggers reloading of historical data.

    (4) Backtesting only works with historical data. if you wish to perform separate in-sample and out-of-sample backtests you need to set the start and end date for the backtests accordingly. The system does not read any data points beyond the selected end point.

    Comment


      #3
      Hello Aristotle,

      Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

      It looks like Harry has answered your questions, though I did want to add a few things:


      Further, the following link is to our help guide with an alphabetical reference list to all supported methods, properties, and objects that are used in NinjaScript: http://www.ninjatrader.com/support/h..._reference.htm

      Please, let us know if we may be of further assistance.
      Zachary G.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      3 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X