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 AttiM, 02-14-2024, 05:20 PM
        12 responses
        213 views
        0 likes
        Last Post DrakeiJosh  
        Started by cre8able, 02-11-2023, 05:43 PM
        3 responses
        237 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        117 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        47 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by rocketman7, Today, 09:41 AM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X