Back

Conversion of NinjaTrader Data Series Class

In Ninjatrader, I can define a data series class:

Definition
An IntSeries is a special type of data structure that holds a series of int values and always contains the same number of elements as bars in a chart. 

#region Variables
private IntSeries myIntSeries; // Define a IntSeries variable
#endregion

 

// Create a IntSeries object and assign it to the variable
protected override void Initialize()
{
    myIntSeries = new IntSeries(this); // "this" refers to the indicator, or strategy
                                      // itself. This syncs the IntSeries object
                                       // to historical data bars
}

 

Is there a way that I should convert this type of class for my strategy to work in QuantConnect?

 

Thanks,

Dan

 

 

Update Backtest








Hi Dan Hill, it looks like NinjaTrader's IntSeries is Lean/QuantConnect's RollingWindow, since it holds a series with a fixed number of elements of a given data type:

// RollingWindow of a TradeBar.
RollingWindow<TradeBar> _window = new RollingWindow<TradeBar>(3600);

// In OnData:
// Inject data into the rolling window.
_window.Add(data["SPY"]);


Is that what you are looking for?

0


I will try that.  Thanks

0

Would that same method work for the following:

 

myTime = new DataSeries(this);

myTime[0] = ToJulianDate(Time[0]);

 

0

I don't know NinjaTrader's API to answer that question.
If you could discribe what you want to do, the community could teach you the QuantConnect way.

0

Thanks for the help.  I am trying to save the time of each bar in another format.  I was thinking that I needed to create a class for the timeseries where I could update the value of each 1 min bar as I convert it to Julian format.  I do not quite have the syntax down correct in this example.

 

For example:

 

private RollingWindow<MyTimeState> mytime;

 

// class to hold the current state of a time instance
        public class MyTimeState
        {
            public readonly DateTime Time0;
            
            public MyTimeState()
            {
                Time0 = Time[0];
            }
        }

private void OnData(TradeBars Data)
        {

            

             MyTimeState.Add(Time[0]);

        }

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed