Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Panel window compression through code

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

    Panel window compression through code

    Hi guys!

    I have an awesome oscillator that plots a few horizontal lines around the signal. Each time I apply it to a chart, I must drag the mouse over the oscillator panel's right scale and compress it to reveal the hidden upper and lower lines.

    Is there a way to code some control of the height of the panel window from the same code that plots the oscillator?

    #2
    Yes. Override OnCalculateMinMax and include those lines in the scale. Or, if they are Draw.HorizontalLine type drawing objects, use an override signature that lets you set AutoScale to true.

    Syntax


    Draw.HorizontalLine(NinjaScriptBase owner, string tag, double y, Brush brush)
    Draw.HorizontalLine(NinjaScriptBase owner, string tag, bool isAutoScale, double y, Brush brush, DashStyleHelper dashStyle, int width)
    Draw.HorizontalLine(NinjaScriptBase owner, string tag, bool isAutoscale, double y, Brush brush, bool drawOnPricePanel)

    Draw.HorizontalLine(NinjaScriptBase owner, string tag, double y, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)
    Draw.HorizontalLine(NinjaScriptBase owner, string tag, double y, bool isGlobal, string templateName)
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello Gianpiero,

      Thank you for your note.

      As Bruce mentioned, drawing the horizontal lines with isAutoScale set to true should resolve this item. For more details, please see the help guide page here:
      https://ninjatrader.com/support/help...zontalline.htm

      Edit: I do see you are posting this in the Technical Support section of the forum rather than a NinjaScript development topic. That means it is likely that you simply using an indicator you have imported into the platform rather than developing it yourself. You may be able to double-click the horizontal lines to open the Drawing Objects window and then check the box for "Auto scale" in the properties. Then, click OK to save your changes. For more details on working with Drawing Objects:


      Otherwise, you may need to reach out to the developer of the indicator for assistance or the indicator script will need to be edited to set the lines to auto-scale by default if you have access to the source code.

      Thank you for using NinjaTrader. Please let us know if we may be of further assistance.
      Last edited by NinjaTrader_Emily; 05-18-2023, 09:53 AM.

      Comment


        #4
        I missed mentioning that the lines are not drawn; they are plotted with either one of these instructions:

        Code:
        AddLine(Brush brush, double value, string name)
        AddLine(Stroke stroke, double value, string name)
        I read these Language Reference pages:
        Code:
        OnCalculateMinMax()
        GetValueAt()

        I guess I could use this information to sort out a solution by myself, even though I don't hide that any hint or suggestion to the right path would be much appreciated! ;-)

        Comment


          #5
          If it's an oscillator that has a specific range e.g. it's always from -100 to 100, you can override OnCalculateMinMax like:
          Code:
          public override void OnCalculateMinMax()
          {
          MinValue = -101; // -100 to 100 with a little room to spare so you can read the axis labels
          MaxValue = 101; ​
          }
          What this will do is cause the scale to ignore the actual values of your plots and always scale that subgraph from -100 to +100.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            You are awesome! Thank you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            44 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X