Call this method in your inherited class from DSTCreateModelBase in OnBarUpdate to add a Pre Signal Window (data window) for failed long trade data to the machine learning model training data. These are data sets in which the price did not reach the expected Ticks Up to Target. When creating your own data sets it is advisable to have substantial amounts of long trade data sets and failed long trade data sets.

The signalBarsAgo parameter defines how many bars back the signal bar occurred. The signal bar is the first bar before before the price of the instrument hits a profit target defined by Bars To Target and Ticks Up to Target or Ticks Down to Target. The data window that gets used for training a machine learning model is defined by a number of bars before the signal bar. The total bars for the data window is set by the parameter value Pre Signal Window Size.

The DSTAddFailedLongDataWindow will add a data set for failed long trades that do not reach their profit target. To add data sets for long trades that do reach their profit target, please use the DSTAddLongDataWindow method. Both data sets for reaching a profit target and failing to reach a profit target will need to be added in order to successfully train a model. 

The following chart shows the Pre-Signal Window, Signal Bar and Ticks Up to Target window. This is for illustration of the Pre-Signal Window and Signal Bar. The signalBarsAgo parameter will determine the data window for failed long data sets used in creating a model. In this case, the Pre-Signal Window size was set at 10 bars which is used to train our model. The Ticks Up to Target was set at 20 ticks (5 points for ES) but when CreateCustomDataWindows is set to true, the Deep Signal Library will ignore the Ticks Up to Target or Ticks Down to Target and use the signalBarsAgo parameter to determine the data window used for training.

Chart Showing Data Windows


Note:  The DSTAddFailedLongDataWindow method is an advanced method used to control adding failed to reach long profit target data for training a machine learning model. The CreateCustomDataWindows parameter needs to be set to true in order to use the DSTAddFailedLongDataWindow. Please see the Model Parameters page to learn more about the CreateCustomDataWindows parameter.



DSTAddFailedLongDataWindow(int signalBarsAgo)


Warning: This is an advanced method and will override the default Deep Signal Library method of training a machine learning library.




An int used to pass the number of bars back that the signal bar had occurred. The data window used to train the model will be determined by this parameter.





Example of only allowing training for short data sets in which a slow moving SMA crosses above a fast moving SMA at the signal bar for a short trade and long data sets in which the slow moving SMA crosses below the fast SMA.

protected override void OnBarUpdate()


      // Please do not change, the DST Library will need to call OnBarUpdate. Add any additional code below this line.


       if (CrossAbove(SMA(slowSMA), SMA(fastSMA), 1))                                


       else if (CrossBelow(SMA(slowSMA), SMA(fastSMA), 1))










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.