Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding multiple data-series & perform multiple operation on these

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

    Adding multiple data-series & perform multiple operation on these

    In this i want to take multiple dataSeries in my strategy like this

    protected override void OnStateChange()
    {
    if (State == State.Configure)
    {
    AddDataSeries("ES 09-16", BarsPeriodType.Tick, 100);
    AddDataSeries("6E 09-19", BarsPeriodType.Tick, 100);
    AddDataSeries("6B 12-19", BarsPeriodType.Tick, 100);
    AddDataSeries("ZB 09-16", BarsPeriodType.Tick, 100);
    AddDataSeries("ZE 09-16", BarsPeriodType.Tick, 100);
    ​​​​​​
    }
    }

    now i want to store these data but how?

    And also i want difference of
    ("ES 09-16") - ("6E 09-19")
    ("ES 09-16") - ( "6B 12-19" )
    ("ES 09-16") - ( "ZB 09-16")
    ("ES 09-16" ) - ( "ZE 09-16")

    stores these differencese values on CLOSE price

    But how can i get return values of that which are adding my strategy by AddDataSeries() method




    please reply me anyone


    PLEASE
    Last edited by shaista parveen; 01-23-2020, 02:47 AM.

    #2
    Hello shaista parveen ,

    Thanks for your post.

    When you add multiple data series to a script you can reference them by using the plurals of Open, High, Low and Close, IE: Opens, Highs, Lows, Closes. To identify the particular data series, when added in state.Configure, the first added data series will be BarsArray indexed as [1], the 2nd added would be [2], the third added would be [3], etc, etc. The chart bars, that the script is applied to will be identified as [0]. The plurals use two indexes, the first is the bars array as previously advised, the 2nd index will be the specific bar to pull the data of. For example (using your sample code):

    Closes[2][0] would be the close price of the currently processed bar of the 6E 09-19.
    Highs[1][2] would be the high price of 2 bars ago of the ES 09-16
    Lows[3][0] would be the low price of the current bar of the 6B 12-19

    If you want to store the math differences into another array then you would need to create a private data series which will have the same number of array slots as the chart bars. Please see: https://ninjatrader.com/support/help...8/?seriest.htm If you created the data series with the name of ES6Ediff then an example of assigning the difference would look like:

    if (BarsInProgress == 0) // run this when the chart bars call the OnBarUpdate method
    {
    ES6Ediff[0] = Closes[1][0] - Closes[2][0]; // store the diff of ES - 6E into the data series ES6Ediff
    }


    If you are not familiar with multi time frame coding in Ninjascript we highly recommend that you review the help guide resource as this will provide a number of concepts to help you code your script in that environment: https://ninjatrader.com/support/help...nstruments.htm

    Comment


      #3
      Thank u PaulH sir
      when i add multiple data series to a script then how i can references them by using the plurals of Open, High, Low and Close.
      I am not getting your point please Sir clear this point through an example


      Please sir

      Comment


        #4
        Hello shaista parveen ,

        Thanks for your reply.

        If you are not familiar with multi time frame coding in Ninjascript we highly recommend that you review the help guide resource as this will provide a number of concepts to help you code your script in that environment: https://ninjatrader.com/support/help...nstruments.htm

        Here are the topics you will find in that link:
        Working With Multi-Time Frame Objects
        Adding Additional Bars Objects to NinjaScript
        Creating Series<T> Objects
        How Bars Data is Referenced
        Using Bars Objects as Input to Indicator Methods
        True Event Driven OnBarUpdate() Method
        Accessing the Price Data in a Multi-Bars NinjaScript
        Entering, Exiting and Retrieving Position Information


        These topic include illustrations and examples. The link is the best information we can provide to help you and reading it in its entirety will put you in a better position to understand the requirements.

        To be clear, we do not provide a code writing, debugging service as we are a small team. If you would like your script created for you, we can provide you with a link to 3rd party programmers in the Ninjatrader ecosystem that would be happy to provide that service

        Comment


          #5
          okay but you can helm me or not

          Comment


            #6
            tomorrow i will send you code please check and verify my strategy is right or wrong .
            Please sir

            Comment


              #7
              Hello shaista parveen,

              Thanks for your replies.

              As previously advised, "To be clear, we do not provide a code writing, debugging service as we are a small team. "

              If your strategy does not compile, please see this tip: https://ninjatrader.com/support/help...jascript_p.htm

              If your strategy compiles, then you can easily verify if your strategy is working correctly by applying it to your instrument and using the SIM101 account and enabling the strategy. If there are no errors shown in the "log" tab of the control center then that would mean the strategy has not generated any run time errors.

              If when you run the strategy there are errors then it would be up to you to debug your strategy. Debugging is a process to determine what errors are occuring in your script. We have assembled some tips to assist you in the debugging effort: https://ninjatrader.com/support/help...script_cod.htm

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              41 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              124 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              64 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              41 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X