Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Improper use of Value.Set for ratio indicator

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

    Improper use of Value.Set for ratio indicator

    I am trying to use the code below to produce a Relative Volume (with VOLMA) indicator. When I try and display this on the chart it is blank. What am I doing wrong?


    protected override void OnBarUpdate()
    {

    Value.Set(VOLMA(FastPeriod)[0] / VOLMA(SlowPeriod)[fastPeriod]);

    }

    #2
    Originally posted by Chris001 View Post
    I am trying to use the code below to produce a Relative Volume (with VOLMA) indicator. When I try and display this on the chart it is blank. What am I doing wrong?


    protected override void OnBarUpdate()
    {

    Value.Set(VOLMA(FastPeriod)[0] / VOLMA(SlowPeriod)[fastPeriod]);

    }
    What is the error in your log?

    Comment


      #3
      there isn't one

      Comment


        #4
        Plot0.Set(VOLMA(slowPeriod)[fastPeriod])

        will display a blank plot like the code from my original post:

        Value.Set(VOLMA(fastPeriod)[0] / VOLMA(slowPeriod)[fastPeriod])

        but:

        Plot0.Set(VOLMA(slowPeriod)[0])

        will display data on the plot

        for some reason non zero values for [bars ago] is not working

        so I tried:

        Value.Set(VOLMA(fastPeriod)[0] / VOLMA(slowPeriod)[0])

        and it still will show a blank plot

        I'm sure I am missing something quite simple, but this seems so bizarre,

        Comment


          #5
          Another note, I have been thinking about this strategy and I think a look back period might be necessary for the calculation. I think there might be a problem where over the [bars ago] duration [fastPeriod] to [0] the indicator values will be 0 so VOLMA / 0 will create a problem. I am not sure how NT treats this are null values created?

          so would something like

          Value.Set(VOLMA(fastPeriod)[0] / (VOLMA(slowPeriod)[fastPeriod]) // and somehow include a look back period of fastPeriod for the denominator.

          I have attached an image to hopefully help me not sound so confusing. The indicator on the bottom plot was created using the code below. Note [-5] was used since any positive value will not work for this.

          Plot0.Set((VOLMA(slowPeriod)[-5]));
          Attached Files

          Comment


            #6
            Chris, anything negative would not be supported and not be meaningful, since it would not work like this on the rightmost side / bar of the chart, you cannot plot / use something now you would only have in x bars from now.

            You likely miss a check for enough CurrentBars at your OnBarUpdate() start for working with higher index values than 0 - http://www.ninjatrader.com/support/f...ead.php?t=3170

            Comment


              #7
              Thanks Ray. Something is being plotted when I use the code below. I will QC this later and ensure it is calculating what I want, I will post again if there are any problems.

              Value.Set((VOLMA(fastPeriod)[0]) / (VOLMA(slowPeriod)[Math.Min(CurrentBar, fastPeriod)]));

              Comment


                #8
                I mean Bertrand, I was referring to the support guy on the link provided.

                Comment

                Latest Posts

                Collapse

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