Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fixed scaling on indicator panels

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

    Fixed scaling on indicator panels

    Is there a way to set the scaling in my code for example if I want the indicator panel to always be +/- 1000 ?

    Also can you point me to some help or a code example showing how to use the value of other symbols? For example my ES chart may have my custom indicator below it which is based on some market breadth symbol. What do I substitute for <<?>> below to get the current value of data feed symbol IRNT.Z?


    protectedoverridevoid Initialize()
    {
    Add(
    "IRNT.Z", BarsPeriod.Id, BarsPeriod.Value);
    Add(
    new Plot(new Pen(Color.DarkCyan,3), PlotStyle.Bar, "AddDecRatio"));
    DrawOnPricePanel = false;
    Overlay =
    false;
    }

    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBarArray[1] > 0)
    {
    x = <<?>>;
    // do some math on x here

    AddDecRatio.Set( x
    );
    }
    }


    #2
    Hello valiantthor,

    Unfortunately there is no way to set the indicator scale by code. It's based on the highest and lowest values of the indicator.

    One work around to this is setting upper / lower bound plot values that are the same color as the chart background.

    For your multiseries question, you can access the closing price of secondary series with:

    Closes[1][0]
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      I was running into the same problem with an indicator. I just tried your work around, but it doesn't seem to work. I have a price oscillator that oscillates around ZERO, and i want the scale to be bound between 50 and -50.

      So, i added this to my Initialize Method:

      Add(new Plot(Color.FromKnownColor(KnownColor.Transparent), PlotStyle.Line, "UpperScale"));
      Add(
      new Plot(Color.FromKnownColor(KnownColor.Transparent), PlotStyle.Line, "LowerScale"));

      then added this to the OnBarUpdate Method:

      UpperScale.Set(
      50);
      LowerScale.Set(-
      50);

      But the indicator is still scaling, as it was before i tried that work-around.

      Any ideas why that wouldn't work?

      Thanks!!


      Comment


        #4
        Hello MrOrange,

        Thanks for the snippet. Here are a couple things you should look into for this:
        Transparent plots aren't included in chart scale. You have to manually match the color of your plots with the color of the chart background - Black plot with black chart background.

        You may also still need the code for the properties region for these plots. If you added through the indicator wizard, this is created automatically. If not, the format will be something like this. The Values[] index increases by one for each plot you add.

        Code:
         [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries UpperScale
        {
        get { return Values[COLOR="Red"][0][/COLOR]; }
        }
        
        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries LowerScale
        {
        get { return Values[COLOR="red"][1][/COLOR]; }
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Thanks for your response.

          It must be the transparent thing. I do have the region stuff in my code, i just didn't include it because... it seemed a bit obivous

          I guess there is no way to do a 'getbackgroundcolor' type of command, so that i don't have to manually match it, eh?

          Cheers!

          Comment


            #6
            It may be possible, but unfortunately no supported way of reading the chart back color. The supported property for this only works to assign the back color.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            574 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X