• 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

Two Data Series in One Strategy?

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

    Two Data Series in One Strategy?

    Hello,

    I have a simple question. Is it possible to write a strategy that is attached to a 1-minute chart that includes indicator data that is on the 3-minute chart for the same instrument? If it is possible, how do I reference the 3-minute chart?

    Thanks for your help.

    LarryRay

    #2
    Hello LarryRay,

    Thanks for your post.

    You can add an additional data series with AddDataSeries() in State.Configure. Price Series in a multi time frame NinjaScript can be referenced with the plural version of the Price Series object. These are arrays of Price Series objects.

    I highly recommend going through our Multi Time Frame and Instruments documentation in addition to the documentation on the items above for a complete understanding on creating a NinjaScript with multiple data series.

    Publicly available documentation on these items can be found below.

    AddDataSeries() - https://ninjatrader.com/support/help...dataseries.htm
    Price Series reference - https://ninjatrader.com/support/help...riceseries.htm
    Multi Time Frame and Instruments (Important read!) - https://ninjatrader.com/support/help...nstruments.htm

    Please let me know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Thank you very much for your quick response and pointing me in the right direction. I have a lot of reading to do now.

      LarryRay

      Comment


        #4
        Hi, I'd like to followup on this thread with some additional clarifying questions instead of starting a new thread.

        1. From this thread:
        https://ninjatrader.com/support/foru...ad.php?t=85939

        It sounds like I can only display the primary data series in the Strategy Analyzer, correct?

        2. Can I display an indicator that points to the secondary data series instead of the primary?

        Comment


          #5
          Hello PN720,

          Yes, only the primary data series will be charted from the Strategy Analyzer. Additional data series can be added to the strategy itself for backtesting but cannot be added dynamically/optimized.

          An indicator or strategy can use information from one data series to be used for their plot that is based on the primary series. Essentially, the plot "Value" should be set in BarsInProgress == 0 to be synchronized with the primary data series, but the value used for the plot would reference the other data series.

          For example:
          Code:
          protected override void OnBarUpdate()
          {
          	if(BarsInProgress == 0)
          		Value[0] = Closes[1][0];
          }
          will plot the close of the secondary data series into the plot value of the hosting NinjaScript. (Please see the Multi Time Frame and NinjaScripts documentation linked in post 2 for further Multi Time Frame reference.)

          Please let us know if you have any additional questions.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hi Jim,

            Is there a reference sample of this where you point the Indicator at a different Data Series? Those are really helpful to me.

            Thanks!

            Comment


              #7
              Hello PN720,

              A reference sample for this concept can be found here - https://ninjatrader.com/support/help...ries_as_an.htm

              Please note that the sample assigns values on the secondary series BarsInProgress iteration, and if there is not a valid value on the primary data series BarsInProgress, the previous value for the secondary series is used.

              Code:
              			// when the primary series is processing set the primary plot to the sma with the primary series input
              			if (BarsInProgress == 0)
              			{
              				SMAPrimary[0] = sma1[0];
              				
              				// if the secondary 5 minute series did not close, set the current bar's value to the previous bar's value to prevent gaps 
              				if (!SMASecondary.IsValidDataPoint(0))
              					SMASecondary[0] = SMASecondary[1];
              			}
              If you have any questions involving this sample that is not clear with the Multi Time Frame and Instruments documentation, please do not hesitate to ask.
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by StealthM93, Today, 07:58 PM
              0 responses
              2 views
              0 likes
              Last Post StealthM93  
              Started by Mykro, Today, 11:01 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by bauerjj10, Today, 12:24 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Newtrader101, Today, 06:01 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_EricB  
              Started by Steve L, Today, 03:50 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X