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

Adding multiple data series in one strategy

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

    Adding multiple data series in one strategy

    I have looked every where I am at the point of giving up. I need to add 4 different times frames in one strategy. Am I writing this correct? AddDataSeries(Data.BarsPeriodType.Day, 1);

    #2
    Hello faisamtrader,

    AddDataSeries is the correct method for adding data, we have this documented with some samples in the following pages:




    I highly suggest reviewing the second like that goes over multi timeframe scripts, there are a lot of considerations to make when using more than one series and this page highlights these items.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello faisamtrader,

        AddDataSeries is the correct method for adding data, we have this documented with some samples in the following pages:




        I highly suggest reviewing the second like that goes over multi timeframe scripts, there are a lot of considerations to make when using more than one series and this page highlights these items.


        I look forward to being of further assistance.
        Can I add and show only the data series in 5min when the original chart has only shown 1 min chart by just adding in the strategy which means when I disable the strategy , only 1 min chart was shown but it showed both one and 5min chart if strategy enabled.??

        Comment


          #5
          Hello stantenlee,

          Added series are not visual so if you wanted to visualize 5 minute chart bars you would need to use a 5 minute chart.
          JesseNinjaTrader Customer Service

          Comment


            #6
            but I have MACD1min and 5 min added to strategy, when I pick primary series to be 1 min, for the MACD 5 min, I can see nothing for the MACD5min but just MACD1min have data, whats wrong?WHEN I add the 5min series from the chart manually to the chart(both 1min and 5min chart can be seen) , it could show the 5min MACD back as normal. BUT WHEN I RUN THE STRATEGY, IT CAUSE ERROR AS THE SCREEN ATTACHED AND whole NINJATRADER PLATFORM CLOSED DOWN AUTOMATICALLY,SEEMS THERE ARE ERRORS. I attached my strategy and can u help to check what is the problem?
            Attached Files

            Comment


              #7
              Hello stantenlee,

              I was unable to see what code you used as the file attached was a compiled assembly. If you want to upload a small sample of what you are doing you can attach the .cs file or copy/paste the relevant code into the post.

              The error you are seeing is that an order was rejected, that is 1 part of the error message. You generally see two popups for a rejection with one including a reason, alternatively you can review the control center log tab to check for the rejection reason.

              If the platform is closing down or crashing in that use case it could be a result of the code being used, I would need more details about what code was used and the specific situation that you are encountering. You can run the sampleMACrossOver strategy to verify the platform in general is working, that strategy should produce historical trades and not cause an issues.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hi Jesse,

                Please find file attached
                Last edited by NinjaTrader_Jesse; 02-15-2022, 01:37 PM.

                Comment


                  #9
                  Hello stantenlee,

                  You would need to export the item as source code, the file you attached was a compiled assembly which cannot be viewed.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Please find file attached RINGOSTRATEGY.cs

                    Comment


                      #11
                      Hello stantenlee,

                      That is not code but is is instead a file which compliments the .dll file inside the .zip file you previously attached. If this is a script you created using the NinjaScript editor or strategy builder then you need to export the script as source code using the platforms export tool. When exporting leave the compiled assembly box unchecked to export as source code. If this is a third party item then what you provided already was a protected file which cannot be viewed.

                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Jesse
                        RINGOStrategy2.cs

                        Comment


                          #13
                          Originally posted by stantenlee View Post
                          but I have MACD1min and 5 min added to strategy, when I pick primary series to be 1 min, for the MACD 5 min, I can see nothing for the MACD5min but just MACD1min have data, whats wrong?
                          Originally posted by stantenlee View Post
                          WHEN I add the 5min series from the chart manually to the chart(both 1min and 5min chart can be seen) , it could show the 5min MACD back as normal. BUT WHEN I RUN THE STRATEGY, IT CAUSE ERROR AS THE SCREEN ATTACHED AND whole NINJATRADER PLATFORM CLOSED DOWN AUTOMATICALLY,SEEMS THERE ARE ERRORS. I attached my strategy and can u help to check what is the problem?

                          Comment


                            #14
                            Hello stantenlee,

                            Thank you for providing the source code.

                            I took a look at the file however I am not sure on the question about the data series here. The error you provided is an order rejection, that specifically does not have anything to do with AddDataSeries, the order was just rejected based on the reason it had noted. AddDataSeries could relate if you supplied an incorrect price

                            I see that you are trying to use AddChartIndicator with the secondary series however that wont work based on the following comment in the help guide:

                            •An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)

                            You can't visualize the indicators but you can use them in code. Please try removing the AddChartIndicator code from the script.

                            JesseNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Jesse View Post
                              Hello stantenlee,

                              Thank you for providing the source code.

                              I took a look at the file however I am not sure on the question about the data series here. The error you provided is an order rejection, that specifically does not have anything to do with AddDataSeries, the order was just rejected based on the reason it had noted. AddDataSeries could relate if you supplied an incorrect price

                              I see that you are trying to use AddChartIndicator with the secondary series however that wont work based on the following comment in the help guide:

                              •An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)

                              You can't visualize the indicators but you can use them in code. Please try removing the AddChartIndicator code from the script.
                              •An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)---I DONT quite understand for this, do you mean I can't have both MACD1min and MACD5min for the same instrument??or cannot even same product?U mean I should add the the indicator MACD5min and MACD 1min to the chart directly followed by calling them in strategy?
                              ANY SAMPLE shared so I can know more clearly??

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,610 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X