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

CumulativeDelta Values at Swing Highs and Lows

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

    CumulativeDelta Values at Swing Highs and Lows

    Dear Support,

    I am developing a Delta Swing indicator using Draw.Text to print the cumulativedelta value at swing highs and lows on the chart. Simply, I want to be able to compare the price and cumulative delta values at swing highs and lows for possible divergences. I am not sure which one of the following codes (Session or Bar) do I need to use when calling for cumulative delta.

    Code:
    cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0);
    Code:
    cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0);
    Many thanks.

    #2
    Hello aligator,

    The Period controls how the volume is being stored. This can accumulate and reset at the end of the session or reset for each new bar.

    The default value for this is Session.

    Below is a link to the help guide.
    https://ninjatrader.com/support/help...eltaParameters
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by aligator View Post
      Dear Support,

      I am developing a Delta Swing indicator using Draw.Text to print the cumulativedelta value at swing highs and lows on the chart. Simply, I want to be able to compare the price and cumulative delta values at swing highs and lows for possible divergences. I am not sure which one of the following codes (Session or Bar) do I need to use when calling for cumulative delta.

      Code:
      cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0);
      Code:
      cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0);
      Many thanks.
      I bet you are looking for the second one.

      Session delta is what people usually use for divergences. It's the running delta since the open and you see it plotted at the bottom of charts as a running total - and is commonly used for divergences.

      Bar delta only applies to that one bar. I've seen people use it for divs as well but that is very rare. Let me know if that clears it up I can post a chart if you want.

      The session delta is a fluid value that increases and decreases throughout the session, the bar delta is just a positive/negative histogram.

      Both can be used but its really up to you.

      The most common would be session.

      Comment


        #4
        Originally posted by butt_toast View Post

        Let me know if that clears it up I can post a chart if you want.
        Thanks butt_toast. I think I got it, and wrote the code but waiting for live session data to test it (No historical Bid/Ask data on NT). Yes, would be nice if you post a picture (perhaps a delta swing applied to a chart). Better yet, do you know of a delta swing indicator already done for NT8?

        Thanks.

        Comment


          #5
          Originally posted by aligator View Post

          Thanks butt_toast. I think I got it, and wrote the code but waiting for live session data to test it (No historical Bid/Ask data on NT). Yes, would be nice if you post a picture (perhaps a delta swing applied to a chart). Better yet, do you know of a delta swing indicator already done for NT8?

          Thanks.
          Not at my desk yet but:
          FRom control center select connections
          Disconnect if connected
          Tools-history
          Tab at bottom, load
          under market replay select contract/date, download
          Back to connections, connect to market replay

          that's how you can get historical level one and two data

          I can post a chart later showing what Delta looks like if that's what you're asking?

          Edit:
          NT actually not only has historical bidask data but also depth. Just download it as I outline here.
          Last edited by butt_toast; 07-22-2021, 06:07 AM.

          Comment


            #6
            Here's a chart showing session cvd and div.

            Is this what you were looking to see?

            Do note that you do not have to wait for anything to test code that requires historical bid/ask data.

            You can download an insane amount of historical bid/ask tick data if connected to your data provider. Otherwise the Market Replay I described above is a good option because it is even better quality and has level 2 data - anything you write should treat it as if it's live data coming in. The downside with that route is there is "only" six months available to download on a rolling basis. I know some people that download it regularly and have years worth tho.

            Comment


              #7

              Comment


                #8
                Thanks @butt_toast,

                I am very well familiar with divergence and how it works for any indicator. I was basically looking for an swing indicator that plots the cumulative delta values at swing highs and lows (i.e. on Swing indicator) or a chart that shows the plot of that indicator. I am not a big fan of replay, specially that for cumulative delta one needs a huge amount of Bid/Ask data for every single tick.

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello aligator,

                  The Period controls how the volume is being stored. This can accumulate and reset at the end of the session or reset for each new bar.

                  The default value for this is Session.

                  Below is a link to the help guide.
                  https://ninjatrader.com/support/help...eltaParameters
                  Thank you ChelseaB,

                  So far I am not able to print the value of Cumulative Delta (CD) at swing points, here is the code I am using to get the values of CD to plot as text.

                  Code:
                   #region Variables
                       private     OrderFlowCumulativeDelta         delta;
                       private Series<double> CD;
                  
                  if (State == State.Configure)
                      {
                       // A 1 tick data series must be added to the OnStateChange() as OrderFlowCumulativeDela runs off of tick data
                       AddDataSeries(Data.BarsPeriodType.Tick, 1);
                      }
                  
                   else if (State == State.DataLoaded)
                       {
                       delta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Session, 0);
                       CD   = new Series<double>(this);
                       }
                  
                   protected override void OnBarUpdate()
                  
                       CD[0] = delta[0];
                  
                      Draw.Text(this,"TextCD",IsAutoScale, CD.ToString(), CurrentBar-lasthibar, lasthi, 20,
                      Brushes.Blue, textFont, TextAlignment.Center, Brushes.Blue, Brushes.Transparent, 0);
                  As you see I am treating the OFCD as an indicator. The code compiles with no error, however noting will print. I am able to print the swing Total Volume and Swing Points but not the OFCD. Am I referencing the OFRD correctly? The bar indexing in the code work fine for the zigzag indicator, although the zigzag itself will not print when I add the above OFCD code.

                  Many thanks.
                  Last edited by aligator; 08-26-2021, 12:04 PM.

                  Comment


                    #10
                    Hello aligator,

                    I'm not sure the correct code... I'm not seeing any calls to Print() in this code...

                    Are you seeing errors on the Log tab of the Control Center?

                    Are you wanting the example code from the help guide added to an indicator to demonstrate?

                    protected override void OnBarUpdate()
                    {
                    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: " + cumulativeDelta.DeltaClose[0]);
                    }
                    }

                    If you have conditions in the script are you wanting assistance printing the values in the condition to see if these are evaluating as true?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello aligator,

                      I'm not sure the correct code... I'm not seeing any calls to Print() in this code...

                      Are you seeing errors on the Log tab of the Control Center?

                      Are you wanting the example code from the help guide added to an indicator to demonstrate?

                      protected override void OnBarUpdate()
                      {
                      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: " + cumulativeDelta.DeltaClose[0]);
                      }
                      }

                      If you have conditions in the script are you wanting assistance printing the values in the condition to see if these are evaluating as true?
                      https://ninjatrader.com/support/foru...121#post791121
                      Sorry, my bad. I did not mean print, I meant Draw.Text. See the Draw.Text statement and references to OFCD in the code above.

                      I t would be nice to have an example code to Draw the value of OFCD in a chart, say on a hh bar.

                      Thanks
                      Last edited by aligator; 08-26-2021, 01:16 PM.

                      Comment


                        #12
                        Hello aligator,

                        Try printing this on every bar
                        Code:
                        protected override void OnBarUpdate()
                        {
                        if (BarsInProgress == 0)
                        {
                        // Draw the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period 3 ticks above the high of the bar
                        Draw.Text(this, "DeltaClose" + CurrentBar, cumulativeDelta.DeltaClose[0].ToString(), 0, High[0] + 3 * TickSize);
                        }
                        }
                        If you have a condition that you want to know if it is evaluating as true or false, above the condition print the time of the bar and print all values in the condition with labels so we know what every is and how they are being compared.
                        Save the output to a text file and include this with your next post.
                        Have a look at the video in the link provided in post #10.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello aligator,

                          The Period controls how the volume is being stored. This can accumulate and reset at the end of the session or reset for each new bar.

                          The default value for this is Session.

                          Below is a link to the help guide.
                          https://ninjatrader.com/support/help...eltaParameters
                          Hi,
                          Sorry, I know its an OLD thread, but could not find anything relevant anywhere else.

                          A question, if I may here OR I can start a new thread.

                          I want to chart the CVD indicator, but instead of RESET at SESSION or BAR, I would like to RESET it at a INTERVAL, say 1 min(variable).

                          -------
                          #region Variables
                          private OrderFlowCumulativeDelta OFCDelta;
                          private CumulativeDeltaType OFCDeltaType=CumulativeDeltaType.BidAsk;
                          private CumulativeDeltaPeriod OFCDeltaPeriod=NinjaTrader.NinjaScript.Indicators. CumulativeDeltaPeriod.Session;
                          private DateTime lookBackTime;
                          -------

                          Any ideas?

                          Thanks

                          Comment


                            #14
                            Hello SuperDriveGuy,

                            OrderFlowCumulativeDelta only has Session or Bar for the period. There are no other options for this enum.


                            You could use a 1 minute input series and set the Session to Bar.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello SuperDriveGuy,

                              OrderFlowCumulativeDelta only has Session or Bar for the period. There are no other options for this enum.
                              https://ninjatrader.com/support/help...ive_delta2.htm

                              You could use a 1 minute input series and set the Session to Bar.
                              Hi ChelseaB,
                              Thanks for getting back to me.
                              Appreciate your help, as I am a bit lost here...

                              I am trying to achieve the same as the screenshot below but in NinjaTrader. The Idea is I can draw lines, maybe even have alerts when the CVD goes above say 1000 etc etc
                              Any example of a similarly written code which and replace and use for my purpose?
                              Many Thanks,
                              Click image for larger version  Name:	Capture.JPG Views:	0 Size:	248.7 KB ID:	1204575
                              Last edited by SuperDriveGuy; 06-09-2022, 11:14 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              26 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 04-23-2024, 09:53 PM
                              2 responses
                              49 views
                              0 likes
                              Last Post wzgy0920  
                              Started by Kensonprib, 04-28-2021, 10:11 AM
                              5 responses
                              193 views
                              0 likes
                              Last Post Hasadafa  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,235 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X