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

Range Indicator

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

    Range Indicator

    I am trying to build an indicator that merely plots the absolute value of the open and close of the current bar. It compiles, but then doesn't plot anything. here is what I have:

    public class AttemptRange : Indicator
    {
    /// <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.Blue, PlotStyle.Bar, "RangeValue"));
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()

    {

    Math.Abs(Open[0] - Close[0]);
    }
    }
    }

    #2
    Originally posted by aldenstout View Post
    I am trying to build an indicator that merely plots the absolute value of the open and close of the current bar. It compiles, but then doesn't plot anything. here is what I have:

    public class AttemptRange : Indicator
    {
    /// <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.Blue, PlotStyle.Bar, "RangeValue"));
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()

    {

    Math.Abs(Open[0] - Close[0]);
    }
    }
    }
    How is your Plot identified in the Properties listing for the indicator?

    All you have done is performed a calculation. If you have not set any value for the Plot, then nothing can nor will be plotted.

    Comment


      #3
      Originally posted by koganam View Post
      How is your Plot identified in the Properties listing for the indicator?

      All you have done is performed a calculation. If you have not set any value for the Plot, then nothing can nor will be plotted.

      Comment


        #4
        Range bar code

        Originally posted by aldenstout View Post
        I am trying to build an indicator that merely plots the absolute value of the open and close of the current bar. It compiles, but then doesn't plot anything. here is what I have:

        public class AttemptRange : Indicator
        {
        /// <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.Blue, PlotStyle.Bar, "RangeValue"));
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()

        {

        Math.Abs(Open[0] - Close[0]);
        }
        }
        }


        Your maths is correct but you need to set you plot to the value. Like below.

        RangeValue.Set(Open[0] - Close[0]);

        Also, you will find that depending on whether you have an up bar or a down bar, 50% of the time you will have a negative value. You can deal with this by using the code below instead.

        double tmp;

        tmp = Open[0] - Close[0];

        if (tmp < 0) tmp /= -1;

        RangeValue.Set(tmp);

        Also.... Set Overlay to false to ensure you get a fresh window and the range will not plot well with the values of the market you are looking at.

        protected override void Initialize()
        {
        Add(new Plot(Color.Blue, PlotStyle.Bar, "RangeValue"));
        Overlay = false;
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        2 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        40 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X