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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X