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

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
            BertrandNinjaTrader Customer Service

            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 DanielTynera, Today, 01:14 AM
                0 responses
                2 views
                0 likes
                Last Post DanielTynera  
                Started by yertle, 04-18-2024, 08:38 AM
                9 responses
                40 views
                0 likes
                Last Post yertle
                by yertle
                 
                Started by techgetgame, Yesterday, 11:42 PM
                0 responses
                12 views
                0 likes
                Last Post techgetgame  
                Started by sephichapdson, Yesterday, 11:36 PM
                0 responses
                2 views
                0 likes
                Last Post sephichapdson  
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,615 views
                0 likes
                Last Post aligator  
                Working...
                X