Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        153 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        133 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X