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 WeyldFalcon, 08-07-2020, 06:13 AM
                11 responses
                1,422 views
                0 likes
                Last Post jculp
                by jculp
                 
                Started by RubenCazorla, Today, 09:07 AM
                0 responses
                4 views
                0 likes
                Last Post RubenCazorla  
                Started by BarzTrading, Today, 07:25 AM
                2 responses
                29 views
                1 like
                Last Post BarzTrading  
                Started by devatechnologies, 04-14-2024, 02:58 PM
                3 responses
                21 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by tkaboris, Today, 08:01 AM
                0 responses
                6 views
                0 likes
                Last Post tkaboris  
                Working...
                X