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

can someone suggest what I'm doing wrong?

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

    can someone suggest what I'm doing wrong?

    Hello,

    Below is the code for an indicator which plots the volume histogram with a dot that projects end of bar volume. It compiles ok, but when I add it to a chart all I get is the pane. No volume and no indicator. I used the NT help file tutorial as a guide, I'm very new at this. Any ideas?

    ///<summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    ///</summary>
    protectedoverridevoid Initialize()
    {

    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "PRV"));
    CalculateOnBarClose = false;
    Overlay = false;
    PriceTypeSupported = false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.


    double perCom = Bars.PercentComplete;
    double volPRV = (1/perCom)*(Volume[0]);
    PRV.Set(volPRV);
    }

    #2
    Please check the Log tab, likely an error on this indicator at runtime.
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      Please check the Log tab, likely an error on this indicator at runtime.
      Nothing on Log tab, just the usual connection messages. Thank your for your help.

      Comment


        #4
        I just noticed that in the data window, the Volume field says "InfinityM".

        ????

        Comment


          #5
          Then your indicator values are infinite values. You will need to recheck your math.
          RayNinjaTrader Customer Service

          Comment


            #6
            OK, I started the whole thing over from scratch and played aroung with commenting out various portions to see what works and what doesn't.

            Every clue I get suggests I'm using Bars.PercentComplete in an incorrect manner.

            I assume, for example, on a 5 min chart that Bars.PercentComplete will return a value of 0.2 one minute into the bar, etc. Even if I just get rid of all my math and try and plot Bars.PercentComplete I get a nonsensical display.

            Comment


              #7
              I think the issue is that Bars.PercentComplete is returning a value of zero on historical bars. Might screw up your math? It should return a value of 1 on a historical bar. Either way, you should ensure that you are handling any potential divide by zero issues.
              RayNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Ray View Post
                I think the issue is that Bars.PercentComplete is returning a value of zero on historical bars. Might screw up your math? It should return a value of 1 on a historical bar. Either way, you should ensure that you are handling any potential divide by zero issues.
                Ray,

                I think I figured it out, but won't know until market opens tomorrow so I can run it live. It seems as the Bars.PercentComplete does NOT return the % completed, but rather the % remaining. I'll post again if this turns out to be true. If not, than I'm really baffled, because once I made the adjustment for this, everything looked correct.

                Thank you very much for your help.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rtwave, 04-12-2024, 09:30 AM
                2 responses
                20 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by tsantospinto, 04-12-2024, 07:04 PM
                5 responses
                68 views
                0 likes
                Last Post tsantospinto  
                Started by cre8able, Today, 03:20 PM
                0 responses
                7 views
                0 likes
                Last Post cre8able  
                Started by Fran888, 02-16-2024, 10:48 AM
                3 responses
                49 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by martin70, 03-24-2023, 04:58 AM
                15 responses
                115 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X