Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to prevent a plot line from influencing chart auto-scaling

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

    How to prevent a plot line from influencing chart auto-scaling

    Hello fabulous NT support staff!

    My custom VWAP indicator needs to plot two additional lines above and below VWAP.

    I have the functionality working properly but unfortunately my chart's auto-scaling functionality 'crunches down' the entire price action in order to include at all times my outer VWAP lines so they are visible at all times.

    Is there a way to prevent an indicator's plot from not participating in the chart's auto-scale functionality? (My indicator is with 'IsOverlay == true' so it draws over the main chart pane)

    Thanks for the awesomness!

    Jean-Pierre

    P.S. I have a comment I should leave at the link below but it's read-only... where should I put it? (I have found that 'Owner is Chart' does NOT work... (The only way I found that works to detect if a strategy runs in the context of a chart or the analyzer to interpret in interpret 'IsInStrategyAnalyzer' in State == State.Configure)

    #2
    Hello JPPoulin,

    From the description it sounds like OnCalculateMinMax could be used here to override and omit those plots from the autoscale. There is a sample in the help guide showing the general use for setting the min/max, in your use case you just would not use those two plots when finding the min/max for the scale.




    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse,

      Thanks again for the prompt and useful answer. You guys set the gold standard for tech support

      Yup that did the trick. Actually even simpler I just set 'IsAutoScale = false' for my custom indicator and now all its plots are ignored for chart auto-scaling.

      P.S. 'Owner Is Chart' has been broken since 8.0.20 came out... I seem to remember it working in .19

      Comment


        #4
        Hello JPPoulin,

        The Owner property is not currently a documented property so I am unsure of its specific expectation here, I can say that checking for a chart can be done with the ChartControl:

        Code:
        if(ChartControl != null) // in a chart/has a chart
        For the analyzer you can use the property you provided which is documented: https://ninjatrader.com/support/help...rategyAnalyzer

        I look forward to being of further assistance.

        Comment


          #5
          Cool thanks, didn't know about 'ChartControl'. I assume ChartControl and IsInStrategyAnalyzer are mutually exclusive?

          (You might want to place a copy of this answer in the (read-only) link above that recommends using 'Owner is Chart')

          Comment


            #6
            Hello JPPoulin,

            Yes these are separate objects with separate uses. The ChartControl is only present when a chart is available and the IsInStrategyAnalyzer is only there for the analyzer. You can use them in the same script but they would not be true at the same time. I am unsure if ChartControl is ever not null in the backtest, there is a ChartControl which can be viewed however that is not initially used in the analyzer.

            I won't be able to edit the old post as that is the beta forum which is locked now. A lot of the posts in there are no longer relevant so this section is locked but available for viewing. There is some older code in that sub forum which can cause problems so please be cautious in that section.


            I look forward to being of further assistance.

            Comment


              #7
              Thanks Jesse for the precisions... one last question I have and that might be helped with the new knowledge of 'ChartControl' is that there is one corner case where a strategy in hosted by the Analyzer yet displays in a chart.

              This occurs after the Analyzer has run and the user displays the chart of one of the simulation results. Currently the part of my code that attempts to optimize the fluff that doesn't need to run if the strategy is GUI-less (drawing on the chart etc) was testing for IsInStrategyAnalyzer but perhaps because of the above-mentioned corner case a test for ChartControl is best?

              Thanks again for your invaluable help!

              Comment


                #8
                Hello JPPoulin,

                Both could be used in that case to prevent drawing, the ChartControl is a more broad approach as this covers the ControlCenter as well.

                The ChartControl should always be null while the analyzer so that could be used to delegate visual logic, the IsInStrategyAnalyzer could also be used here because it would retain its value throughout the test.

                When the user opens the chart in the analyzer that wont actually do anything with the ChartControl and won't re run the logic. If a drawing object or visual item was used, the chart would just display it. This is part of what makes drawing objects still take resources when they are not being viewed in a chart. they still exist in memory they are just not drawn to a chart. By not running the logic by using the condition like you have that cuts the resource usage because they are no longer in memory or being visualized.




                I look forward to being of further assistance.

                Comment


                  #9
                  Thanks Jesse for taking the time.

                  I'll try to fix that last corner case with this approach and return my observations

                  Comment

                  Latest Posts

                  Collapse

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