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

Problems with Volume

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

    Problems with Volume

    Hello,

    I'm trying to create a custom indicator for use with the Market Analyzer.

    I'm simply trying to have the cell display 1 or 0 depending if the volume of the current bar is greater than the prior bar or not.

    I've tried the following script:
    Plot0.Set(Volume[0] > Volume[1] ? 1 : 0);

    But all that happens in the Market Analyzer window is that the cell shows the Last Price which is making no sense to me at all.

    Any suggestions welcome!

    Thanks

    #2
    Please post the complete OnBarUpdate method of your indicator.

    Comment


      #3
      Code Update

      I'm really at a loss with this one as I'm getting the same error with price bar data as well now (eg High function) so I'm thinking it must be in the setup so I've included the whole lot for you.

      I have only been using Ninja for a week so a fundamental stuffup on my part is definately on the books.

      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      ///<summary>
      /// Enter the description of your new custom indicator here
      ///</summary>
      [Description("Enter the description of your new custom indicator here")]
      [Gui.Design.DisplayName("VTest1")]
      publicclass VTest1 : Indicator
      {
      #region Variables
      // Wizard generated variables
      // User defined variables (add any user defined variables below)
      #endregion

      ///<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.Bar, "Plot0"));
      CalculateOnBarClose = true;
      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.
      Plot0.Set(Volume[0] > Volume[1] ? 1 : 0);
      }

      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Plot0
      {
      get { return Values[0]; }
      }

      #endregion
      }
      }

      Comment


        #4
        Hi Tiger75,

        Please check the Control Center log tab for errors. I suspect your indicator would have generated an error along the lines of unaccessible data series.

        Please see this tip: http://www.ninjatrader-support.com/v...ead.php?t=3170
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh,

          The error in the control centre log is "Error on calling the 'OnBarUpdate' method for indicator 'VTest1' on bar 0:Index was out of range. Must be non-negative and less than the size of the collection".

          I'll give the suggested solutions a go and report back.

          Thanks again for the help its greatly appreciated!

          Comment


            #6
            Please see here: http://www.ninjatrader-support.com/v...ead.php?t=3170

            Comment


              #7
              Your suggestions worked so thanks alot for the help guys!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              148 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              5 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by tkaboris, Today, 05:13 PM
              0 responses
              5 views
              0 likes
              Last Post tkaboris  
              Started by GussJ, 03-04-2020, 03:11 PM
              16 responses
              3,283 views
              0 likes
              Last Post Leafcutter  
              Working...
              X