Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OFCumulativeDelta Dataseries

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

    OFCumulativeDelta Dataseries

    Hello,

    I need to calculate with OFCumulativeDelta for 2 instruments in an indicator that I run on a 15min chart with "Instrument1".
    So I add in State.Configure
    AddDataSeries("Instr1", BarsPeriodType.Tick, 1);
    AddDataSeries("Instr2", BarsPeriodType.Tick, 1);
    AddDataSeries("Instr2", BarsPeriodType.Minute, 15);

    and in OnBarUpdate I have

    if (BarsInProgress == 1) // This is the code example from the help guide, it runs when the 1 tick series calls OnBarUpdate and is needed to sync the values.
    {
    OrderFlowCumulativeDelta1.Update(OrderFlowCumulati veDelta1.BarsArray[1].Count - 1, 1); // note that I changed the name to what the strategy builder created.
    }

    if (BarsInProgress == 2) // This is the code example from the help guide, it runs when the 1 tick series calls OnBarUpdate and is needed to sync the values.
    {
    OrderFlowCumulativeDelta2.Update(OrderFlowCumulati veDelta2.BarsArray[2].Count - 1, 1); // note that I changed the name to what the strategy builder created.
    }

    But when adding the indicator to a chart I get in log tab an error-message
    10.08.2021 15:45:27 Default Indicator '': Error on calling 'OnBarUpdate' method on bar 1658: Index was outside the bounds of the array.
    but I cant figure out why the error-message occurs.What am I doing wrong please?

    Thank you!
    Tony

    #2
    Hello tonynt,

    Do you have other logic in OnBarUpdate besides what you have posted here? If so I would suggest to reduce the test and start by using only 1 added series and 1 orderflow indicator. Once you confirm the first series and indicator are working you could add the second. Once you confirm the second is working you could look at adding your third series.

    You can copy/paste the sample from the OrderFlowCumulativeDelta help guide page as the starting point for the first series. After confirming that works you would duplicate the logic for the second series like you have here omitting that third AddDataSeries you have shown.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello,

      thank you for your reply. Going step by step and modifying an indicator that is working for months and where I have only OFcumulativeDelta for the primary dataseries I think the reason for the error-message is how to add the dataseries for the 2nd instrument.

      In the indicator that is working I have to sync "AddDataSeries(Data.BarsPeriodType.Tick, 1);".
      How one can add the Dataseries for sync for instrument2 so that that both are working correctly please?

      AddDataSeries(Data, BarsPeriodType.Tick, 1);
      AddDataSeries(Data, BarsPeriodType.Tick, 1); // ???
      AddDataSeries("Instr2", BarsPeriodType.Minute, 15);

      "Data" & "Data"?


      Thank you!
      Tony
      Last edited by tonynt; 08-11-2021, 02:07 AM. Reason: translation error

      Comment


        #4
        Hello tonynt,

        an indicator that is working for months
        If you are modifying an existing indicator and adding more series there is a very high probability that you will break the code. Have you tried a more simple test which is not in an already developed script? I couldn't comment on the existing script you are testing, my comments from post #2 would still be my suggestion or to make a test script to work out the problems.

        What you had shown in post 1 is the general way to add another second instance of the indicator and target a specific series, you also need to replicate exactly what the help guide shows for each time you use that indicator on a new series.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Hello Jesse,

          I have made the indicator using OFcumulativeDelta and this works for months. In this indicator the OFcumulativeDelta is only use for the primary dataseries and in state configure with "AddDataSeries(Data, BarsPeriodType.Tick, 1);" and in OnBarUpdate "if (BarsInProgress == 1)
          {OrderFlowCumulativeDelta1.Update(OrderFlowCumulat i veDelta1.BarsArray[1].Count - 1, 1);}"

          How is the structure/logic when using the OFcumulativeDelta for an other instrument than the primary dataseries. I can not be "AddDataSeries(Data, BarsPeriodType.Tick, 1);" because how could NT know if primary or other dataseries. I know how to add dataseries (Minute, Range, Tick, Volumetric. Of same instrument or also other instrument) but I do not find how to have correctly OFcumulativeDelta for the other instrument. There is no sample or snippet in the helpguide how to do.

          Thank you!
          Tony

          Comment


            #6
            Hello tonynt,

            I have made the indicator using OFcumulativeDelta and this works for months.
            I have no concept of how your existing script works to advise on the error in contrast to that. You can try to debug that if what you are trying is not working but I won't be able to advise there. My comment in post 2 would still be my suggestion or to make a new simplified test and work from there.

            The code you provided in post 1 looks like it would be correct but I don't know what other code you have in your existing script. Starting from scratch would be the best starting point so you can explore the problem further.

            If you are working with the help guide sample it adds only 1 series so you would have indexes 0 and 1 for the two series. The code shown in the sample uses BarsArray[0] and [1]. If you are adding another indicator you would have to replace those values on the second instance with the respective series you had used. If you added another instrument as the 3 series and the 1 tick as the 4th series then it would be [2] and [3] for the second instance.


            Please let me know if I may be of further assistance.


            Comment


              #7
              Hello,

              I understand what you mean and I work with added dataseries in scripts for years now. But there´s no sample or snippet how to use OFcumulativeDelta for different instruments.

              I reduced the code to the very minimum, this is only few lines and less text than writing and describing the problem. What is there wrong and causing the error-message please?

              Thank you!
              Tony
              Attached Files

              Comment


                #8
                Hello tonynt,

                But there´s no sample or snippet how to use OFcumulativeDelta for different instruments.
                The sample that I linked from the help guide does show how to work with multiple instruments because it specifies a direct BarsArray in the code. If you want to use one of the other instruments that you have added you would specify that instruments BarsArray. The file you provided is not following along with the help guide sample, you are using Closes so that may be more difficult for you to follow with, I would suggest to just copy.paste from the help guide as that already works.

                The order you added the series is also going to make it more difficult to follow the help guide, if you reverse the series then the index's will match the help guide, then you just need to increment the indexes and use the exact same code.
                Code:
                AddDataSeries("NQ 09-21", BarsPeriodType.Minute, 15);
                AddDataSeries("NQ 09-21", BarsPeriodType.Tick, 1);
                Code:
                if (BarsInProgress == 2)
                {
                    // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
                    Print("Delta Close: " + OrderFlowCumulativeDelta(BarsArray[2], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0]);
                }
                else if (BarsInProgress == 3)
                {
                    OrderFlowCumulativeDelta(BarsArray[2], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).Update(OrderFlowCumulativeDelta(BarsArray[2], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).BarsArray[3].Count - 1, 1);
                }
                In the script you provided you are trying a lot of other things at once but the code doesn't work yet so you are likely going to have a hard time with that script. Please try using only the same from the help guide without the conditions you added, pay specific attention to the BarsInProgress conditions and where the code for each section is placed.

                Please let me know if I may be of further assistance.

                Comment


                  #9
                  Hello,

                  thank you for your reply. With no sample and no snippet I was referring to "AddDataSeries(Data,..." as this is clear when working with one instrument and OFdelta.

                  I dont know what you mean with Closes in my code. I´m not a programmer, all I have done is from helpguide, informations in forum and reply from support. I was told with Closes[x] I can refer to a dataseries (when using more dataseries in an indicator, and it is working with OFdelta and eg 4 dataseries for one instrument. I can access everything and it works).

                  Moreover I´m confused now from your code with BIP2 and BIP3.

                  My code is working for months with 1 or 2 or more dataseries and with OFdelta. Please see this - reduced to the very minumum - basic code I have and please tell me how I can add there the NQ eg with 5 min and the OFcumulativeDelta for the NQ. I dont know what is wrong with my code now when I built it from the replies I got and I can access every pricebar, deltabar, close, high....everything. Whats wrong with this and my closes? Maybe I do not understand correctly with my english. I dont know, please simply show how to add NQ 5 min and OFcumulativeDelta NQ. This might be for you less lines than this parapgraph here. I´m lost now.


                  Thank you!
                  Tony
                  Attached Files
                  Last edited by tonynt; 08-12-2021, 06:43 AM. Reason: translation error

                  Comment


                    #10
                    Hello tonynt,

                    I dont know what you mean with Closes in my code. I´m not a programmer,
                    We are speaking about one of the more advanced indicators and it does require manual programming to use it, if you have difficult with programming I would suggest to seek an outside developer for assistance. Our support can provide guidance but you ultimately are in control of creating what you want, if that is not within your scope then please seek an outside developer to create this.

                    My code is working for months with 1 or 2 or more dataseries and with OFdelta
                    If you used the sample from the help guide then it would be expected to work. Your script needs to be programmed in a certain way when you start using multiple series or instruments, if you have a hard time with basic programming concepts then this is going to be a very difficult section of NinjaScript to work with. Most of the code involved when using multiple series requires knowing about how Arrays and Indexes work so you can pick the correct series for the code you wanted to run.

                    basic code I have and please tell me how I can add there the NQ eg with 5 min and the OFcumulativeDelta for the NQ
                    I provided a sample of what you would do to add a second orderflow for the NQ in post 8. I don't see that you tried that in the test script.

                    The sample you provided again is deviating from the help guide sample, if you are making changes to that sample its going to make it difficult for you to reproduce it a second time. I would suggest to copy and paste the sample from the help guide as a starting point. For instance you are using Closes, the help guide uses BarsArray which is the correct way to use this indicator per the documentation:
                    Code:
                     OrderFlowCumulativeDelta[B](Closes[0][/B]
                    Code:
                     OrderFlowCumulativeDelta(BarsArray[0]
                    Its best to keep consistent with the working help guide sample if you plan to try and duplicate that code for other series. The only changes needed when working with other series is to use the correct BarsInProgress to call Update and to supply the correct BarsArray indexes where needed.

                    Please let me know if I may be of further assistance.


                    Comment


                      #11
                      Hello,

                      here is the thread where I got the information how to do with dataseries "Closes[2]" and so I work for long time now
                      https://ninjatrader.com/support/foru...ve-delta/page2 (see post #20 please)

                      I dont understand why this is wrong now. If some crucial part is wrong then of course there will be no agreement here, or misunderstanding from my side.

                      Thank you!
                      Tony

                      Comment


                        #12
                        Hello tonynt,

                        I was not aware you had another thread open for a similar question to know where that code came from. It does not match the help guide sample which is why I mentioned it. That's not wrong but when using Closes and then trying to compare the help guide sample the code is going to be different between the two. If you don't have a lot of experience to feel comfortable using the different series in a script its going to make it hard to figure out whats wrong because you have two different sets of code.

                        If you copy the help guide sample like I had mentioned you can duplicate that code and everything is consistent, the sample I provided in post 8 matches the help guide sample and not the forum post you had linked. I would suggest to try and copy the help guide code as a starting point and then make the modifications we had previously discussed.

                        Please let me know if I may be of further assistance.

                        Comment


                          #13
                          Hello,

                          I wrote that all I have done is from helpguide, forum or support-reply. I had to search where I got the information. Now there´s a new question: why do I have a thread "open". This sounds as this should not be. I give up. I dont know what to do when I work for years with that logic. Even more you have in your code 2 added dataseries and then BIP2 and BIP3. I dont understand this. Cant you please add the few lines in the basic sample NTxOFDeltaBasic.cs l I reduced for you to show and attached here above. If you would have given me hints/replies/snippets how to add with this logic I work for years I would have understood but I can not change all (indicators and scripts) to another logic. I have to give up with this.

                          Thank you!
                          Tony

                          Comment


                            #14
                            Hello tonynt,

                            Now there´s a new question: why do I have a thread "open"
                            I am not certain what you are asking, A thread is "open" when you ask a question and create a thread on the support forums.

                            Even more you have in your code 2 added dataseries and then BIP2 and BIP3. I dont understand this.
                            To use the orderflow indicators on another secondary series you have to use the additional BarsInProgress indexes to specify those series. Thats what I was referring to if you are not copying the help guide sample exactly then its going to be much more difficult when referring back to that sample. The help guide sample shows how to use BarsInProgress and BarsArray which are both required concepts to use this indicator.

                            Cant you please add the few lines in the basic sample NTxOFDeltaBasic.cs
                            Our support cannot keep making modifications to your scripts for you but we can try to assist with question you may have. I already provided a sample in post 8 with the indexes changed for the secondary series. If you are having trouble understanding that concept we can cover that in more detail but you need to ask questions about what you don't understand.

                            As mentioned this is one of the more complex indicators and you do need to have a general understanding of how concepts like BarsInProgress and BarsArray work when using extra series. As a starting point you could research the Multi Series documentation if you are not sure how AddDataSeries/BarsArray/BarsInProgress all fit together. https://ninjatrader.com/support/help...lightsub=multi

                            If you would have given me hints/replies/snippets how to add with this logic I work for years I would have understood but I can not change all (indicators and scripts) to another logic. I have to give up with this.
                            Please see the help guide sample and also my sample in post 8, we already went over creating a sample of what you need. If you are not clear on part of that then ask about what you are not clear with. We provide a sample in the help guide that you can directly copy and paste into a script that works with the primary. My sample goes along with that and uses the same variable names that the help guide did to avoid any confusion, the code is just duplicated and the BarsInProgress indexes are changed.

                            if you feel this is outside of your comfort zone please seek an external developer to continue your project.


                            Please let me know if I may be of further assistance.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            600 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            347 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            103 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            558 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            558 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X