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

Bars disappearing

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

    Bars disappearing

    My custom indicator bars are disappearing when I zoom out and won't come back when I zoom in. What could the problem be?

    Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.


    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion
    
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        /// <summary>
        /// summary
        /// </summary>
        [Description("blah")]
        public class MyIndie : Indicator
        {
            #region Variables
            // Wizard generated variables
                //private int myInput0 = 1; // Default setting for MyInput0
            // 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>
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orchid), PlotStyle.Bar, "Val"));
                Overlay				= false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void 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 somenumber = somecalculation;
                Val.Set(somenumber);
    			
            }
    
            #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 Val
            {
                get { return Values[0]; }
            }
    
            [Description("")]
            [GridCategory("Parameters")]
            public int MyInput0
            {
                get { return myInput0; }
                set { myInput0 = Math.Max(1, value); }
            }
            #endregion
        }
    }

    #2
    Hi JoshDance,

    Are there any error messages noted in log tab of control center? Do you have a file / snippet we can use that will show this on our end? Unfortunately it's not clear what somecalculation is in the snippet you provided.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for sending in the snippet. You have potential divide by zero issue. You can try something like the following to call reset during these cases. Our built in Ultimate indicator also has some divide-by-zero handling you can use for reference.

      ratio = Volume[0] / ((High[0]-Low[0])*10);;

      if (High[0] - Low[0] == 0)
      Plot0.Reset();

      else
      Plot0.Set(ratio);
      Last edited by NinjaTrader_RyanM1; 04-19-2011, 10:35 AM.
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        Makes perfect sense, duh can't believe I didn't think of that. Just fixed and it worked, thank you!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Yesterday, 05:46 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        32 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        7 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by merzo, 06-25-2023, 02:19 AM
        10 responses
        823 views
        1 like
        Last Post NinjaTrader_ChristopherJ  
        Started by frankthearm, Today, 09:08 AM
        5 responses
        22 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X