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

Y-Axis, Scale individual plots in panel

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

    Y-Axis, Scale individual plots in panel

    I've read threads that mention Y-Axis scale options would be available in NT7, but after 30 minutes of searching forums I can't find any reference, probably because I don't know the proper terminology.

    I have 2 plots in the same panel.
    1st plot has values 0-100
    2nd plot has values 0.01 to 0.16

    Q1:
    Is there a programming method to "overlay" the 2nd plot, ignoring it's scale, so the 2nd plot is viewable against the wider range of the 1st plot?

    or would I need to multiply the 2nd plot by a ratio to "scale it up" to match the range of the 1st plot?

    Q2:
    Then I would need to find the highest and lowest values of the 2nd plot, to determine the min max, for the scaling ratio multiplier.

    How do I get a count of the number of bars displayed in the current view?

    Q3:
    How to update this min max after scrolling left or right (event triggered)?

    thanks

    #2
    Hello balltrader,

    Thanks for your questions.

    I see that you have opened the thread in the NT8 forums, but your post is referencing NT7.

    Before I answer your questions, could you confirm which platform you are using?

    I look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      NT8,
      the threads I was reading were for NT6, and the NT staff mentioned this featured would be available when NT7 was released

      Comment


        #4
        Thanks balltrader,

        Indicators can set a ScaleJustification parameter but this would be for the indicator and all of its plots rather than being set for individual plots. Separate scales would be possible in both NT7 and NT8, but would have to be done in separate indicators. Scaling your plot values would be a valid solution as well.

        Updating the min and max would involve updating MinValue and MaxValue in OnCalculateMinMax(). It would be advised to loop through ChartBars.FromIndex and ChartBars.ToIndex to go through the visible bars and use the bar-indexes (not barsAgo indexes) from those bars to reference the values from your indicator plots.

        I'll include a snippet from an indicator's OnCalculateMinMax() method that updates the MinValue and MaxValue based on indicator plot values for demonstration. (This would likely need to be altered for your implementation.)

        Code:
        for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
        {				
            if (High2.GetValueAt(idx) > MaxValue)
                MaxValue = High2.GetValueAt(idx);
        	
            if (Low2.GetValueAt(idx) < MinValue && Low2.GetValueAt(idx) != 0)
        	MinValue = Low2.GetValueAt(idx);
        }
        I'll include publicly available documentation resources on these items, as well.

        ScaleJustification - https://ninjatrader.com/support/help...tification.htm

        OnCalculateMinMax() - https://ninjatrader.com/support/help...lateminmax.htm

        Additional resources for further reading:

        If there is anything else I can do to assist, please let me know.
        JimNinjaTrader Customer Service

        Comment


          #5
          thank you.

          One thing I am not sure of :

          If I get min and max using that sample of iterate fromindex toindex
          does it need to be done from within the OnCalcMinMax override,
          because that callback is fired whenever the view is scrolled horizontally left or right?
          and if I did this from within OBU, it would not update until next bar, even if view was scrolled?

          or, if indicator panel is set to use autoscale, this is called on each new bar?

          if I override OCMM, does it still get fired if indicator panel has autoscale turned off?

          Comment


            #6
            Hello balltrader,

            OnCalculateMinMax() will be called as the chart scrolls when the NinjaScript object is set to AutoScale. It is not called in relation to OnBarUpdate().

            Through some quick tests, I could not set MinValue and MaxValue in OnBarUpdate(). I would only recommend setting this in OnCalculateMinMax() as that would be the place to properly keep your chart scaled when interacting with the chart.

            I'm happy to be of any further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by tsantospinto, 04-12-2024, 07:04 PM
            5 responses
            67 views
            0 likes
            Last Post tsantospinto  
            Started by cre8able, Today, 03:20 PM
            0 responses
            6 views
            0 likes
            Last Post cre8able  
            Started by Fran888, 02-16-2024, 10:48 AM
            3 responses
            48 views
            0 likes
            Last Post Sam2515
            by Sam2515
             
            Started by martin70, 03-24-2023, 04:58 AM
            15 responses
            114 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by The_Sec, Today, 02:29 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X