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

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 arvidvanstaey, Today, 02:19 PM
            2 responses
            6 views
            0 likes
            Last Post arvidvanstaey  
            Started by jordanq2, Today, 03:10 PM
            0 responses
            2 views
            0 likes
            Last Post jordanq2  
            Started by traderqz, Today, 12:06 AM
            10 responses
            18 views
            0 likes
            Last Post traderqz  
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            46 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by mmckinnm, Today, 01:34 PM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X