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

AutoScale OnRender() Without AutoScale for AddPlot() plots

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

    AutoScale OnRender() Without AutoScale for AddPlot() plots

    Hello all,

    As the title suggests, I am developing an indicator for which OnRender() is used to render part of the visual and AddPlot() is used to render the rest. I am pretty much done, but the last issue I'm facing is that my custom rendered candlesticks are not AutoScaled and I want them to be. In addition, I would like the moving averages I have added through AddPlot NOT to be AutoScaled. How can I achieve this?

    Additional Info:
    - Using a fixed scale is not an option
    - I am using base.OnRender() within my OnRender() method to ensure AddPlot() calls work
    - Lastly, not sure if it's relevant here, but I am also calling OnCalculateMinMax() using the standard tmpHigh/tmpLow approach using the variables for the high and low of my custom rendered candlesticks.

    Thanks in advance for any help you all can offer!

    #2
    In OnCalculateMinMax you should be setting MinValue and MaxValue to the high and low of your rendered candlesticks. You don't call OnCalculateMinMax - it's an event that is called that you override to set your own desired high and low for the scale.

    Refer to this example: https://ninjatrader.com/support/help...lateminmax.htm
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello, thanks for writing in. With IsAutoScale = true, OnCalculateMinMax will be called so you can customize the auto scaling behavior of your indicator. You would need to customize this event to center the chart around the highest/lowest values of your custom rendered chart objects. Here is one example that performs this scaling:

      NinjaTrader 8 natively provides Heiken Ashi as a bar type for most common bar types (minute, tick, volume, second, day, week, month, year). This Heiken Ashi indicator is provided for the Range, Renko and any custom bar types that may be added. The indicator performs in the same manner as the NinjaTrader 7 version. 4-27-18 […]


      The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hi Bruce and Chris,

        Vernacular aside, I believe my custom call to OnCalculateMinMax is correct for what I am trying to accomplish. Perhaps one of you can take a look and tell me if anything is off?

        I would add two things....
        - my custom rendered candlesticks were able to scale just fine before I added the AddPlot() plots
        - I am using base.OnRender(chartControl, chartScale) in OnRender(), does this somehow interfere with my OnCalculateMinMax override?

        And question -- Bruce, are you telling me I should set AutoScale = true even though I don't want the AddPlot() plots to AutoScale? AutoScale just asks OnCalculateMinMax() where the min and max should be?

        Thanks again for any help you can offer, code down below.

        Code:
        public override void OnCalculateMinMax()
        {
        base.OnCalculateMinMax();
        
        if (Bars == null || ChartControl == null)
        return;
        
        for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
        {
        double tmpHigh = CDHigh.GetValueAt(idx);
        double tmpLow = CDLow.GetValueAt(idx);
        
        if (tmpHigh != 0 && tmpHigh > MaxValue)
        MaxValue = tmpHigh;
        if (tmpLow != 0 && tmpLow < MinValue)
        MinValue = tmpLow;
        }
        }

        Comment


          #5
          ....because when I set AutoScale = true the min and max are the ma plots, not the rendered candlesticks

          Comment


            #6
            UPDATE:

            All set, the issue as I'm sure you would have spotted is that I was calling base.OnCalculateMinMax() which was causing the AddPlot() plot scaling to override my custom scaling.

            When I removed this line the panel scaled to the rendered candlesticks and NOT the plots while AutoScale = true in properties.

            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by realblubb, Today, 09:28 AM
            0 responses
            2 views
            0 likes
            Last Post realblubb  
            Started by AaronKoRn, Yesterday, 09:49 PM
            1 response
            18 views
            0 likes
            Last Post Rikazkhan007  
            Started by ageeholdings, Today, 07:43 AM
            0 responses
            12 views
            0 likes
            Last Post ageeholdings  
            Started by pibrew, Today, 06:37 AM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Working...
            X