• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddDataSeries - Different Trading Hours

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

    AddDataSeries - Different Trading Hours

    Hellos,

    I would like to ADDDataSeries "CME US Index Futures RTH" to an ETH indicator. I'm able to add a different time frame... I've attempted with the strategy builder and reviewed the help guide.

    Thanks in advance.

    #2
    Hello rcmcd,

    Thanks for your post.

    You will need to use one of the following overloads to add a data series with a different Trading Hours template. This cannot be done in Strategy Builder created strategies without first unlocking the code.

    Code:
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName, bool? isResetOnNewTradingDay)
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)
    Our BarsPeriod documentation page has an example that can be referenced for syntax:

    Code:
    protected override void OnStateChange()
    {
        if (State == State.Configure)
        {     
              // add a 1440 minute apple bars object using the RTH session template
              AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");               
        }
     
        else if (State == State.DataLoaded)
        {
              // Print out the loaded bars period 
              Print(Instrument.FullName + " " + BarsPeriod); // MSFT 1 Minute
              Print(BarsArray[1].Instrument.FullName + " " + BarsArray[1].BarsPeriod); // AAPL 1440 Minute
        }
    }
    As a tip, you could pass "null" (without quotes) as the instrument name, and the instrument for the primary data series will be used.

    For the thread's reference I will include documentation links for AddDataSeries() and for BarsPeriod. There are important notes to consider when adding additional data to your script. Finally, the Multi Time Frame and Instruments documentation should be referenced for a complete guide to creating and working with a multi series NinjaScript.

    AddDataSeries() - https://ninjatrader.com/support/help...dataseries.htm

    BarsPeriod - https://ninjatrader.com/support/help...barsperiod.htm

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    The documentation linked above is publicly available. If you have any additional questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello rcmcd,

      Thanks for your post.

      You will need to use one of the following overloads to add a data series with a different Trading Hours template. This cannot be done in Strategy Builder created strategies without first unlocking the code.

      Code:
      AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)
      AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName, bool? isResetOnNewTradingDay)
      AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)
      Our BarsPeriod documentation page has an example that can be referenced for syntax:

      Code:
      protected override void OnStateChange()
      {
          if (State == State.Configure)
          {     
                // add a 1440 minute apple bars object using the RTH session template
                AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");               
          }
       
          else if (State == State.DataLoaded)
          {
                // Print out the loaded bars period 
                Print(Instrument.FullName + " " + BarsPeriod); // MSFT 1 Minute
                Print(BarsArray[1].Instrument.FullName + " " + BarsArray[1].BarsPeriod); // AAPL 1440 Minute
          }
      }
      As a tip, you could pass "null" (without quotes) as the instrument name, and the instrument for the primary data series will be used.

      For the thread's reference I will include documentation links for AddDataSeries() and for BarsPeriod. There are important notes to consider when adding additional data to your script. Finally, the Multi Time Frame and Instruments documentation should be referenced for a complete guide to creating and working with a multi series NinjaScript.

      AddDataSeries() - https://ninjatrader.com/support/help...dataseries.htm

      BarsPeriod - https://ninjatrader.com/support/help...barsperiod.htm

      Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

      The documentation linked above is publicly available. If you have any additional questions, please don't hesitate to ask.
      Still not working.
      I used. AddDataSeries("ES 09-18", Data.BarsPeriodType.Minute, 3, "CME Us Index Futures RTH"); I get errors- CS1502, 1503.

      Please advise.

      Comment


        #4
        Hello rcmcd,

        The error is reporting your syntax is incorrect.

        Looking at the compiler errors, we may see the following:
        NinjaScript File Error Code Line Column
        MyCustomIndicator7.cs Argument 4: cannot convert from 'string' to 'NinjaTrader.Data.MarketDataType' CS1503 51 63
        The compiler sees that you have specified 4 arguments and assumes you are using the 4 argument overload below. With this hint from the compiler in mind, we know that we need to make sure we are using the correct overload.

        Code:
        AddDataSeries(string instrumentName, BarsPeriodType periodType, int period, MarketDataType marketDataType)
        I would suggest testing with the sample code from the BarsPeriod documentation verbatim, and then to change the Trading Hours template to be used to get the proper syntax.

        Code:
        AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");
        JimNinjaTrader Customer Service

        Comment


          #5
          I think that worked.

          You're my hero!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by waliopaozae, Today, 01:44 AM
          0 responses
          2 views
          0 likes
          Last Post waliopaozae  
          Started by Futurestrader00, Today, 01:35 AM
          0 responses
          6 views
          0 likes
          Last Post Futurestrader00  
          Started by firstlanetech, Today, 01:05 AM
          1 response
          4 views
          0 likes
          Last Post firstlanetech  
          Started by HiddenPhilosopher, Yesterday, 11:58 PM
          0 responses
          5 views
          0 likes
          Last Post HiddenPhilosopher  
          Started by glennts, Yesterday, 08:24 PM
          2 responses
          17 views
          0 likes
          Last Post bltdavid  
          Working...
          X