Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need Help with Delta and Bollinger Bands

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

    Need Help with Delta and Bollinger Bands

    Hello,

    I was trying to code an indicator on my own and I am hoping you guys can help me get this put together. The code compiles successfully but nothing plots when I add it to the chart. I think this could be a useful indicator for the community.

    What I was essentially doing was placing a Bollinger Band on the Order Flow Cumulative Delta indicator that I have with the lifetime license of NT8 that I have. And on the Bollinger Bands I changed the input from Close to the Cumulative Delta Indicator to get the screenshot you see attached.

    I was trying to consolidate these two indicators in one because I need to have the plots of the upper and lower bands available as well as the delta of each bar. Also I tried to export as a NT8 zip but could not so attached it from and saved it as a note++ file (C# format).

    Again the code compiled without any errors but nothing plots and not sure where I went wrong. If you could please help and I don't mind sharing this indicator with the community!

    Thank you

    Peter
    Attached Files

    #2
    Hello peterp1127,

    Thank you for your post and for sharing your script with the community.

    Do you receive any error messages in the Log tab of the Control Center or the NinjaScript Output window when you apply your indicator to a chart? If so, what do these errors report?
    This information could help us to identify what might be causing the indicator to not plot so we may understand what resolution might be needed.

    I look forward to your reply.

    Comment


      #3
      Hello Emily, thank you for your reply, I checked the log this was the error:

      Indicator 'DeltaDeviationpp': Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range.

      Comment


        #4
        Here is the file looks like it it did not attach initially
        Attached Files

        Comment


          #5
          Hello peterp1127,

          Thank you for your reply.

          Based on that error message, it sounds as though you will need to add some logic to make sure that you have enough bars on your chart to load the data that your indicator is trying to access. For more information, please see the help guide page here:


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

          Comment


            #6
            Hi, I made that modification by adding this part:
            if (CurrentBar < MovAvgPeriod)
            return;

            but nothing is seen when inserting it.​

            Originally posted by NinjaTrader_Emily View Post
            Hello peterp1127,

            Thank you for your reply.

            Based on that error message, it sounds as though you will need to add some logic to make sure that you have enough bars on your chart to load the data that your indicator is trying to access. For more information, please see the help guide page here:


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

            Comment


              #7
              Hello juanfer,

              The current bar check for all data series before attempting to use data from a series is necessary.
              Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


              if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
              return;​

              The OrderFlow Cumulative Delta has some considerations to use properly.
              As it uses an added 1 tick series, the values on it need to be updated on each tick during BarsInProgress 1.

              The help guide provides sample code:
              Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


              // OnBarUpdate() logic
              if (BarsInProgress == 0)
              {
              // 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[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0]);
              }
              else if (BarsInProgress == 1)
              {
              // We have to update the secondary series of the cached indicator to make sure the values we get in BarsInProgress == 0 are in sync
              OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).Update(OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).BarsArray[1].Count - 1, 1);
              }​
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks for your help, while I fix these errors, can you tell me how to insert the Bollinger bands in the indicator like the image in the first post?
                I can only see them when the indicator is in session mode, if it is in bar mode the calculation stays at zero.​

                Originally posted by NinjaTrader_ChelseaB View Post
                Hello juanfer,

                The current bar check for all data series before attempting to use data from a series is necessary.
                Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


                if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
                return;​

                The OrderFlow Cumulative Delta has some considerations to use properly.
                As it uses an added 1 tick series, the values on it need to be updated on each tick during BarsInProgress 1.

                The help guide provides sample code:
                Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


                // OnBarUpdate() logic
                if (BarsInProgress == 0)
                {
                // 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[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0]);
                }
                else if (BarsInProgress == 1)
                {
                // We have to update the secondary series of the cached indicator to make sure the values we get in BarsInProgress == 0 are in sync
                OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).Update(OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).BarsArray[1].Count - 1, 1);
                }​

                Comment

                Latest Posts

                Collapse

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