Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get "Delta Change" value of the current bar in OF volumetric bars

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

    Get "Delta Change" value of the current bar in OF volumetric bars

    Hi Ninjatrader Support, Need help for the following.
    When I display the volumetric chart I can see a lot statistic at the bottom of the chart(screenshot attached) and most of the values can be accessed using the functions/methods provided in the link, but I want the Delta Change value which is one of the statistics displayed, but I cannot access it using any function. Can anyone help how I can get it? I want the value so that I can display it on top/bottom of the bar in my custom indicator where I use the volumetric data series to pull them.
    https://ninjatrader.com/support/help...etric_bars.htm
    Attached Files

    #2
    Hello amul_shail2020,

    Thanks for your post.

    The delta change would be a subtraction of the current bar delta from the previous bar delta.

    barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar-1].BarDelta;

    Note: I deleted your NinjaTrader7 post as it was a duplicate in the wrong forum, no worries.

    Comment


      #3
      Hi PaulH,

      Thanks for your reply.
      I have tried it but does not work. I must be doing something wrong. Here is the code which I have . It works for Delta but not work the delta change.
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class AmolRevRatio3 : Indicator
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "AmolRevRatio3";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      AddVolumetric("",BarsPeriodType.Tick, 500, VolumetricDeltaType.BidAsk, 1);
      }
      }
      protected override void OnBarUpdate()
      {
      if(BarsInProgress == 1)
      {
      NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
      NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
      if(barsType == null)
      return;
      if(Close[0] < Open[0]){ //Down Red Bar
      // Draw.Text(this, "Bardlt"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, Low[0] - (2.5 * TickSize + 0.25), Brushes.White);
      Draw.Text(this, "Bardltchg"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, Low[0] - (2.5 * TickSize + 0.25), Brushes.White);
      }
      if(Close[0] > Open[0]){ //Up Green Bar
      Draw.Text(this, "Bardlt"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
      // Draw.Text(this, "Bardltchg"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
      }
      if(Close[0] == Open[0]){ //Doji
      Draw.Text(this, "Bardlt"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
      // Draw.Text(this, "Bardltchg"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
      }

      }

      }

      }
      }

      Comment


        #4
        Hello amul_shail2020,

        Thanks for your reply.

        Can you clarify what you mean by "I have tried it but does not work.". Do you mean the value is incorrect or you get no value at all?

        Do you see any error messages in the "Log" tab of the control center when you run the indicator?

        Comment


          #5
          There is no errors, but I get no values displaced at all for delta change.
          Last edited by amul_shail2020; 01-06-2021, 01:22 PM.

          Comment


            #6
            Hello amul_shail2020,

            Thanks for your reply.

            An issue may be trying to print in BarsInProgress =1, typically you would draw in the BarsInprogress = 0 as these are the chart bars and your text would align to these bar slots on the chart.

            You may want to use a Print() statement to print out the values you are calculating.




            Comment


              #7
              Here is the full attached indicator code as zip file
              Attached Files

              Comment


                #8
                Hello amul_shail2020,

                Thanks for your reply.

                What are you using for the chart bars?

                Can you provide a complete screenshot?

                Comment


                  #9
                  Thanks for your help PaulH. Looks like I understood. Just need to make sure that enough bars are created before the calculation is done. Here is the updated code which works and shows the delta change.
                  if(BarsInProgress == 1)
                  {
                  NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
                  NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
                  if(barsType == null)
                  return; //
                  if(CurrentBars[0] < 1)
                  return; //

                  Print("Delta for bar: " + barsType.Volumes[CurrentBar].BarDelta);
                  Print("Delta Change for bar: " + (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta));
                  if(Close[0] < Open[0]){ //Down Red Bar
                  Draw.Text(this, "Bardltr"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, Low[0] - (2.5 * TickSize + 0.25), Brushes.White);
                  Draw.Text(this, "Bardltchgr"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, Low[0] - (2.5 * TickSize + 0.75), Brushes.Green);
                  }
                  if(Close[0] > Open[0]){ //Up Green Bar
                  Draw.Text(this, "Bardltb"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
                  Draw.Text(this, "Bardltchgb"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, High[0] + (2.5 * TickSize + 0.75), Brushes.Green);
                  }
                  if(Close[0] == Open[0]){ //Doji
                  Draw.Text(this, "Bardltd"+ CurrentBar, barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, High[0] + (2.5 * TickSize + 0.25), Brushes.White);
                  Draw.Text(this, "Bardltchgb"+ CurrentBar, (barsType.Volumes[CurrentBar].BarDelta - barsType.Volumes[CurrentBar -1].BarDelta).ToString(), 0, High[0] + (2.5 * TickSize + 0.75), Brushes.Green);
                  }

                  }

                  Comment


                    #10
                    I am not 100% sure if this is the correct way, since the indicator now have started to hang/freeze...not sure why

                    Comment


                      #11
                      Hello amul_shail2020,

                      Thanks for your reply.

                      In order to assist, please advise what chart bars you are using and provide a complete screenshot of what you see.



                      Comment


                        #12
                        I use it on a 500 Tick chart and it works but keeps on freezing. Here is a screenshot.
                        Attached Files

                        Comment


                          #13
                          Hello amul_shail2020,

                          Thanks for your reply.

                          Based on the zip file you posted:

                          Set IsOverlay in OnStateChange() from false to true, this will eliminate the indicator panel that is not needed.

                          Here is all you need in OnBarUpdate():

                          Code:
                          if (BarsInProgress == 0)
                          {
                          if(Bars == null)
                          return; //
                          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
                          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
                          
                          if(barsType == null)
                          return;
                          
                          if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
                          return;
                          
                          long bDelta = barsType.Volumes[CurrentBars[1]].BarDelta;
                          long bDeltaChange = barsType.Volumes[CurrentBars[1]].BarDelta - barsType.Volumes[CurrentBars[1] -1].BarDelta;
                          
                          
                          if(Close[0] < Open[0])
                          { //Down Red Bar
                          Draw.Text(this, "Bardltr"+ CurrentBar, bDelta.ToString(), 0, Low[0] - 3 * TickSize);
                          Draw.Text(this, "Bardltchgr"+ CurrentBar, bDeltaChange.ToString(), 0, Low[0] - 6 * TickSize);
                          }
                          if(Close[0] > Open[0])
                          { //Up Green Bar
                          Draw.Text(this, "Bardltb"+ CurrentBar, bDelta.ToString(), 0, High[0] + 3 * TickSize);
                          Draw.Text(this, "Bardltchgb"+ CurrentBar, bDeltaChange.ToString(), 0, High[0] + 6 * TickSize);
                          }
                          if(Close[0] == Open[0])
                          { //Doji
                          Draw.Text(this, "Bardltd"+ CurrentBar, bDelta.ToString(), 0, High[0] + 3 * TickSize);
                          Draw.Text(this, "Bardltchgb"+ CurrentBar, bDeltaChange.ToString(), 0, High[0] + 6 * TickSize);
                          }
                          }
                          Note: I am unsure why the forum is adding a space in VolumetricBarsTy pe so please no that should not be a space there.


                          Click image for larger version

Name:	Amul-1.PNG
Views:	1421
Size:	84.9 KB
ID:	1135538

                          Comment


                            #14
                            Hi PaulH,
                            Thanks for your reply. I have updated my code and does work with some modification.

                            I am sharing my custom indicator which I coded and shows the following for anyone interested.
                            It has the following 1) It can be used with tick or Range bar charts just change the no of tick or range parameter value(default is 500, make sure to match your chart) 2) It displays the values at the top/bottom of bar depending if it is up/down bar 3) Shows Bar delta and Bar delta change 3) Shows stacked buying/Selling imbalance as bands colored in red /blue.(No of stacks imbalance to show can be specified with the parameter, default is 3, also Imbalance ratio can be changed with the parameter, default is 3) 3) Draws a rectangle at the end of the bars, if bar has more than 3 buy/sell imbalance and Small print(Small print value can be changed by the specified parameter, default is 25) 4) Shows the Ratio bound high and Ratio bound Low values which can be used to identify exhaustion or reversal.
                            Hope it help someone to make there trading/learning journey easy.
                            Note: I am not sure if Order flow volumetric license is required for this, since it uses the volumetric data series to pull the values. I already has the lifetime license which includes all the Order flow plus stuff so it works for me .
                            Thanks.
                            Attached Files
                            Last edited by amul_shail2020; 01-08-2021, 05:35 AM. Reason: Adding the Trading setup Idea which made me create it.

                            Comment


                              #15
                              Hello amul_shail2020,

                              Thanks for your reply.

                              Glad to hear it is meeting your needs.

                              Thanks for sharing your idea and final indicator.

                              Yes, anyone that uses it would need the Ninjatrader platform lifetime license to access the Volumetric data.

                              You are welcome (but not required) to add the indicator to the NT user apps section of the Ninjatrader ecosystem. If you do, please do make note of the license requirement in the description. Here is a link to the "user app submission" forum: https://ninjatrader.com/support/foru...app-submission
                              Last edited by NinjaTrader_PaulH; 01-08-2021, 07:21 AM. Reason: clarify the license.

                              Comment

                              Latest Posts

                              Collapse

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