Welcome to Programming For Predicting With New Model. This section will cover how to use the Deep Signal Library for using an existing machine learning model for prediction. For help with programming to create a new model, please click on the Programming For Creating A New Model

The first step is to make sure the existing strategies will compile. From NinjaTrader, click on the menu item New -> NinjaScript Editor. When the NinjaScript Editor window opens we need to compile the strategies. Press F5 or click on the Compile button.



There are 8 Deep Signal strategy files under the DST folder.

  • DSTCreateModelBase is the base strategy file for creating a new machine learning model. Please do not modify this file as it will be the base file for any new Deep Signal Technologies (DST) strategy file you create. 
  • DSTCreateModelTest is derived from DSTCreateModelBase. This is an example file for creating a new machine learning model strategy. You can either modify this file or create a new strategy file and use the DSTCreateModelBase as the parent.
  • DSTCreateCustomTraining is derived from DSTCreateModelBase. This is an example file for creating a new machine learning model strategy using custom training data. You can either modify this file or create a new strategy file and use the DSTCreateModelBase as the parent. Please note, this is for advanced users when wanting to create their own customized training data sets.
  • DSTCreateMomentumModelTest is derived from DSTCreateModelBase. This is another example for creating a new machine learning model strategy. You can either modify this file or create a new strategy file and use the DSTCreateModelBase as the parent.
  • DSTPredictModelBase is the base strategy for running the machine learning model either in a backtest or live. Please do not modify this file because it is needed by the DSTPredictModelTest and any new predictive machine learning model strategies that are created.
  • DSTPredictModelTest is derived from DSTPredictModelBase and can be modified to suit your needs or can be used as an example for creating a new predictive machine learning strategy.
  • DSTPredictCustomTraining is derived from DSTPredictModelBase and is intended to be an example of how to predict models using customized data sets.
  • DSTPredictMomentumModelTest is derived from DSTPredictModelBase and can be modified to suit your needs or can be used as an example for creating a new predictive machine learning strategy.


We'll use the DSTPredictModelTest strategy file. If we click on the DSTPredictModelTest strategy in the NinjaScript Editor window, the C# code window will show the contents of the strategy file. We'll go over each of the numbered areas below.


  1. Each strategy that uses a machine learning model to predict long or short trade entry signals must derive the strategy from DSTPredictModelBase. This is the base class that contains code to access the DST Library and will call methods needed to get the trade entry signals.
  2. Each derived strategy from DSTPredictModelBase must override the OnStateChange method and call base.OnStateChange. 
  3. The AddDSTIndicator method is used to add indicator data to the machine learning model. This method is used in both creating a new model or using an existing model to predict long or short signals. The AddDSTIndicator data for the prediction strategy must match the same data that was used to create the machine learning model. If you used AddDSTIndicator method such as AddDSTIndicator(MACD(1, 26, 9).Diff, "MACD Diff", 4) then you will need to add it in the prediction strategy in the same order as well. Here is a link to more information about AddDSTIndicator. This method is where you can add whatever indicator data you would like to use in the machine learning model. As an example, if you wanted to add a moving average of the primary instrument, you could add AddDSTIndicator(SMA(20), "SMA-20", 2). This will add the Simple Moving Average of the primary instrument with a period of 20, indicator name is "SMA-20" and all data fed to the machine learning model will be rounded to 2 decimals.
  4. AddDSTInstrument is similar to AddDSTIndicator except that AddDSTInstrument will add instrument data to the machine learning model. Here is a link to more information about AddDSTInstrument.
  5. Each derived strategy from DSTPredictModelBase must override the OnBarUpdate method and call base.OnBarUpdate.
  6. There are two methods used to predict a long or short trade entry signal. 
    • DSTLongSignal - DSTLongSignal will return true if the machine learning model has found a long trade entry signal, otherwise it will return false.
    • DSTShortSignal - DSTShortSignal will return true if the machine learning model has found a sell short trade entry signal, otherwise it will return false.


This is a very simplified example of how to use the DSTLongSignal or DSTShortSignal to look for trade entry opportunities. The DSTPredictModelTest may be modified to suit your needs, however please remember to not change DSTPredictModelBase. If you create your own new prediction strategy, make sure that the new prediction strategy is derived from DSTPredictModelBase and that you call base.OnStateChange in the OnStateChange override and call base.OnBarUpdate in the OnBarUpdate override.



Note: It is important that the indicator or instrument data that was added using AddDSTIndicator or AddDSTInstrument for creating the machine learning model must be the same that is used for the machine learning model to predict trade entry signals.



The next step is Backtesting Your Machine Learning Model to find out how it performs. 









Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.