Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Turning off AutoScale using a custom indicator

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

    Turning off AutoScale using a custom indicator

    My apologies if this has been covered previously, but I couldn't find where it had.

    You can effectively turn off AutoScale in panel 1 by simply drawing a line at the upper and lower limits where you would like to restrict the chart plot movement. This doesn't actually "limit" anything, but, so long as the plot lies between the lines, it does eliminate the jumping around that your chart plot does when scrolling laterally.


    The easiest way to do this is to use the New NinjaScript Indicator Wizard. Name your indicator (say, AutoScaleOff) and be sure to check "Overlay on Price" . Create two double precision input parameters. I call mine "rangeUpper" and "rangeLower". You can set default values, if desired, but you'll be changing these almost every time you start your indicator. Next, create a couple of indicator plots, say, UpperLine and LowerLine. You don't need oscillator lines. Edit the NJ written code for your indicator like I've done below.

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "UpperLine"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "LowerLine"));
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    UpperLine.Set(rangeUpper);
    LowerLine.Set(rangeLower);
    }

    Notes:
    Be sure to use double precision input parameters or you'll be restricted to integer range values.
    Don't be tempted to color your limit lines to your background color. It's handy to see them.
    This isn't as useful as it sounds when viewing long periods of data that may have a large range. While the jumping around may be eliminated, much detail will be lost and you'll end up with just a long trace of data that gently slopes up and down.


    You can make your indicator reset to a broader range, should out-of-bounds values come through, by including some simple logic to change "rangeUpper" and "rangeLower" according to current data.

    #2
    Thank you Newton for this guide.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by edward_steve12, Today, 03:23 AM
    0 responses
    2 views
    0 likes
    Last Post edward_steve12  
    Started by edward_steve12, Today, 02:25 AM
    0 responses
    4 views
    0 likes
    Last Post edward_steve12  
    Started by joseph_kuruvilla12, Today, 01:01 AM
    0 responses
    6 views
    0 likes
    Last Post joseph_kuruvilla12  
    Started by joseph_kuruvilla12, Today, 12:40 AM
    0 responses
    4 views
    0 likes
    Last Post joseph_kuruvilla12  
    Started by joseph_kuruvilla12, Today, 12:13 AM
    0 responses
    5 views
    0 likes
    Last Post joseph_kuruvilla12  
    Working...
    X