Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:


        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 aa731, Today, 02:54 AM
              0 responses
              4 views
              0 likes
              Last Post aa731
              by aa731
               
              Started by thanajo, 05-04-2021, 02:11 AM
              3 responses
              469 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              10 views
              0 likes
              Last Post Christopher_R  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              166 responses
              2,237 views
              0 likes
              Last Post sidlercom80  
              Started by thread, Yesterday, 11:58 PM
              0 responses
              4 views
              0 likes
              Last Post thread
              by thread
               
              Working...
              X