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

ChartScale outside OnRender

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

    ChartScale outside OnRender

    Hello:

    I have issues using a copy of ChartScale from OnRender in CalculateMinMax

    Sometimes getting a Y value gives me a 0.

    MyChartScale.GetValueByY

    What could be the problem?

    Regards
    Waldo

    #2
    Hi Waldo, thanks for posting.

    Why is the pixel coordinate needed within OnCalculateMixMax? This method is used to scale the chart based on the highest/lowest visible values of the underlying data series. The pixel values should only be needed in OnRender where you need precise vector coordinates.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Waldo, the ChartScale can also be accessed through ChartControl:
      ChartControl.ChartPanels[0].Scales[0].GetValueByY
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hi Chris. thanks for your reply. I need it to convert a pixel size to a price range. I convert prices to Y coord, add the size in pixels and then convert back to prices. the way to "make it fit".

        Unfortunately is giving me a null this

        ChartControl.ChartPanels[0].Scales[0]

        however

        ChartControl.ChartPanels[0].Scales[1]
        ChartControl.ChartPanels[0].Scales[2]

        are not returning null.

        Comment


          #5
          I could access it


          but it gives me a zero value with GetValueByY

          Concurrency issue? I can't clone it as doesn't implements Icloneable
          Last edited by waldoalvarez; 01-10-2022, 04:14 PM.

          Comment


            #6
            Hi Waldo, thanks for your reply.

            Can you please export and post a reduced example that only demonstrates what you are trying to do? I still do not see why a pixel coordinate would be needed in a method that sets a min and max value for the price scale of a chart.


            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi Chris I am going to reformulate my question

              how can I have something like:

              chartControl.Properties.BarMarginRight

              but for the bottom of the chart where I can render lets say a 200px rectangle not occluded by candles.

              Or equivalent. I was trying to achieve that with CalculateMinMax with some limited results as it ended up working somehow after a number of iterations. Since I am changing a scale that changes.

              Comment


                #8
                Something like chartScale.Properties.AutoScaleMarginLower but with pixels I can set programmatically (currently only percent and price)

                Comment


                  #9
                  Hi, thanks for your reply.

                  This can be set up by saving the offset from the highest high price that is visible on the chart, Save the GetValueByY from OnRender each time the triangle is rendered. If you would like somebody to work through this with you, or develop it all together, consider the NinjaTrader Ecosystem Programmers page to find a NinjaScript consultant for one-on-one assistance.

                  Best regards,
                  -ChrisL
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chris, thanks for your note. You think it would be possible to shed some light on how works AutoScaleMarginLower with AutoScaleMarginType of type percent? Is not clear to me even when setting it using the interface.

                    Is not clear to me on what is based the percent.

                    I am trying to convert from screen to that percent with approx results but is not ok (seems is not based exactly on ChartPanel.H).


                    https://ninjatrader.com/es/support/h...properties.htm

                    I think it would be better than to use the scale since that creates sort of a loop.
                    Last edited by waldoalvarez; 01-06-2022, 06:56 AM.

                    Comment


                      #11
                      HI Waldo, thanks for the follow up.

                      If margin type is set to Percent, and "Based on" it will be a percentage of the range that we select with "Based On" (In our case the visible OHLC) added to that upper and lower value

                      As Margin values increase, the chart squeezes because we are increasing ChartScale.MaxValue, and decreasing ChartScale.MinValue.

                      Best regards,
                      -ChrisL
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Chris. I did managed to get to something that is not perfect since it takes some iterations but behaves a whole lot better than the one I had. Correction is only needed if screen size changes.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by nicthe, Today, 02:58 PM
                        1 response
                        8 views
                        0 likes
                        Last Post nicthe
                        by nicthe
                         
                        Started by percy3687, Yesterday, 12:28 AM
                        3 responses
                        30 views
                        0 likes
                        Last Post percy3687  
                        Started by SilverSurfer1, Today, 01:33 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post SilverSurfer1  
                        Started by ETFVoyageur, Today, 10:27 AM
                        2 responses
                        18 views
                        0 likes
                        Last Post ETFVoyageur  
                        Started by CommonWhale, Today, 01:12 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post CommonWhale  
                        Working...
                        X