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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        35 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        13 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        19 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X