Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ZigZag indicator with custom series does not update

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

    ZigZag indicator with custom series does not update

    I'm trying to use zigzag indicator on cumulative volume delta using the deltaClose, but when i enable the strategy, the indicator doesn't update, it seems it works only on historical. The blue line should follow the rise of cvd

    Here how i create the indicator:

    HTML Code:
    _zigZagCvd = ZigZag(_cvd.DeltaClose, DeviationType.Percent, 10, false);
    here a screenshot

    #2
    Hello davider97,

    The zig zag uses high and low bar values in its code so it natively cannot support using a series with 1 datapoint. To create a zigzag on a different series you need to use BarsInProgress conditions.

    protected override OnBarUpdate()
    {
    if(BarsInProgress == 0)
    {

    }
    if(BarsInProgress == 1)
    {
    ZigZag myzigZag = ZigZag(DeviationType.Percent, 10, false);
    // get the values here​
    }
    Last edited by NinjaTrader_Jesse; 02-14-2025, 08:04 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you it works

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello davider97,

        The zig zag uses high and low bar values in its code so it natively cannot support using a series with 1 datapoint. To create a zigzag on a different series you need to use BarsInProgress conditions.

        protected override OnBarUpdate()
        {
        if(BarsInProgress == 0)
        {

        }
        if(BarsInProgress == 1)
        {
        ZigZag myzigZag = ZigZag(_cvd.DeltaClose, DeviationType.Percent, 10, false);
        // get the values here​
        }
        I'm sorry but unfortunally the problem persist.
        I've got this code _zigZagCvd = ZigZag(_cvd.DeltaClose, DeviationType.Percent, 1, false); in the data loaded and i put your code here OnBarUpdate, but after a short time it stops updating

        Comment


          #5
          Hello davider97,

          In the syntax provided you are trying to pass a specific series to the zig zag however that wont work, you can only access the zig zag values inside the series BarsInProgress. In the example I had provided that is using the data from the secondary series to get a secondary series zigzag value.
          JesseNinjaTrader Customer Service

          Comment


            #6
            i done it but now i get this error
            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. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

            Attached Files

            Comment


              #7
              Hello davider97,

              That may relate to when you call the indicator. You need at least the lookback period you are using loaded before executing that code. You could add if(CurrentBar < 999) return; before that to prevent it from processing before the period.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello davider97,

                That may relate to when you call the indicator. You need at least the lookback period you are using loaded before executing that code. You could add if(CurrentBar < 999) return; before that to prevent it from processing before the period.
                i think the indicator should load the historical cvd's bars.. or no ?
                Last edited by davider97; 02-14-2025, 09:42 AM.

                Comment


                  #9
                  Hello davider97,

                  When you load historical data the indicator still starts processing at bar 0 so at that point you won't have any data prior to that. That means if you are trying to look back in time you have to wait until you have enough data loaded for that. In the image you are trying to use a variable for the zig zag however that variable is from another series so the bars processed on that series may not be enough when you call it. The sample I had shown is the correct way to access zig zag in a multi series, you won't be able to call a different series zig zag in a different bars in progress context due to how it works. It would need to go in the bars in progress that you want the value for.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Jesse View Post
                    Hello davider97,

                    When you load historical data the indicator still starts processing at bar 0 so at that point you won't have any data prior to that. That means if you are trying to look back in time you have to wait until you have enough data loaded for that. In the image you are trying to use a variable for the zig zag however that variable is from another series so the bars processed on that series may not be enough when you call it. The sample I had shown is the correct way to access zig zag in a multi series, you won't be able to call a different series zig zag in a different bars in progress context due to how it works. It would need to go in the bars in progress that you want the value for.
                    I followed your example, but the indicator doesn't update

                    Comment


                      #11
                      Hello davider97,

                      It looks like you missed the takeaway in the example I provided. The code ZigZag(_cvd.DeltaClose won't work, _cvd.DeltaClose is not going to be used. You can only calculate the zigzag on bar series and it would have to specifically be used like this:


                      Code:
                      protected override OnBarUpdate()
                      {
                          if(BarsInProgress == 0)
                          {
                      
                          }
                          if(BarsInProgress == 1)
                          {
                               ZigZag myzigZag = ZigZag(DeviationType.Percent, 10, false);
                               // get the values here​
                          }
                      }
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Jesse View Post
                        Hello davider97,

                        It looks like you missed the takeaway in the example I provided. The code ZigZag(_cvd.DeltaClose won't work, _cvd.DeltaClose is not going to be used. You can only calculate the zigzag on bar series and it would have to specifically be used like this:


                        Code:
                        protected override OnBarUpdate()
                        {
                        if(BarsInProgress == 0)
                        {
                        
                        }
                        if(BarsInProgress == 1)
                        {
                        ZigZag myzigZag = ZigZag(DeviationType.Percent, 10, false);
                        // get the values here​
                        }
                        }
                        Copied. Now the error is the following
                        Error on calling 'OnBarUpdate' method on bar 25: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart

                        There is also this check
                        if(CurrentBar < 999) return;

                        Comment


                          #13
                          Hello davider97,

                          You may have used that in the wrong location. If you are using multiple series you can make a general check like the following:

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

                          You can edit that to change the amount of series or also the number of bars for each series. In the code I pasted you would have to wait for 10 bars on CurrentBars[1]
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            i send you a sample of the code, if you can give it a look i'll appreciate, thank you very much.
                            Try it on NQ on 15 sec

                            It should create cvd plot and below another plot with zig zag deltaClose based.
                            The problem is the zigZag plot doens't update..

                            Thank you again
                            Attached Files

                            Comment


                              #15
                              Hello davider97,

                              In that code you can remove the following lines, this will not calculate on the OrderFlowCumulativeDelta.

                              _zigZagCvd = ZigZag(_cvd.DeltaClose, DeviationType.Percent, 1, false);

                              _zigZagCvd.DrawOnPricePanel = false;
                              _zigZagCvd.IsOverlay = false;
                              _zigZagCvd.Calculate = Calculate.OnBarClose;

                              Dp you still see an error after removing that? ​
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ybforex, 03-11-2025, 05:30 PM
                              12 responses
                              101 views
                              0 likes
                              Last Post rockmanx00  
                              Started by forgebench, Today, 02:22 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post forgebench  
                              Started by MamaKB, 02-14-2025, 03:38 PM
                              10 responses
                              84 views
                              0 likes
                              Last Post Fertryd2  
                              Started by Irukandji, Today, 03:46 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post Irukandji  
                              Started by HappyTrader76, Yesterday, 04:14 PM
                              8 responses
                              48 views
                              0 likes
                              Last Post HappyTrader76  
                              Working...
                              X