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

ChartPanel attributes from inside a Strategy?

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

    ChartPanel attributes from inside a Strategy?

    Ok, I know this is unsupported stuff...

    The Plot() override provides a bounds rectangle and a min, max price value which is enough info to do all sorts of wonderful custom drawing in the panel.

    It appears that this function is only available in an Indicator.

    Does anybody know how I can get updates of this info from within my Strategy?

    Are these undocumented properties of ChartPanel that I can just grab?

    Failing any easy answer, has anybody worked out how to get this info into a strategy?

    thx,
    Dave

    #2
    Originally posted by BigWaveDave View Post
    Ok, I know this is unsupported stuff...

    The Plot() override provides a bounds rectangle and a min, max price value which is enough info to do all sorts of wonderful custom drawing in the panel.

    It appears that this function is only available in an Indicator.

    Does anybody know how I can get updates of this info from within my Strategy?

    Are these undocumented properties of ChartPanel that I can just grab?

    Failing any easy answer, has anybody worked out how to get this info into a strategy?

    thx,
    Dave
    Expose your indicator variables as public and declare it in your strategy in onstartup.

    Comment


      #3
      Eh, GetYByValue?

      May be able to work something out with that... GetValueByY will be needed as well which requires knowing what the min price currently is on the price axis.... which is why those values provided by Plot() would make the job easy.

      With a bit of work... this just *may* be enough. If/when I work something out I'll post it, though I'm sure this has been done before up here somewhere...

      I've got my own custom drawing objects. On each Paint, I'll need to check for a change in the scaling/scrolling (ie bar positions). Recalculate the x and y coords for my drawings and redraw.

      Again, I'm doing all of this in a Strategy, not an Indicator.

      Comment


        #4



        Originally posted by BigWaveDave View Post
        Eh, GetYByValue?

        May be able to work something out with that... GetValueByY will be needed as well which requires knowing what the min price currently is on the price axis.... which is why those values provided by Plot() would make the job easy.

        With a bit of work... this just *may* be enough. If/when I work something out I'll post it, though I'm sure this has been done before up here somewhere...

        I've got my own custom drawing objects. On each Paint, I'll need to check for a change in the scaling/scrolling (ie bar positions). Recalculate the x and y coords for my drawings and redraw.

        Again, I'm doing all of this in a Strategy, not an Indicator.

        Comment


          #5
          That may be the answer. Of course, this requires that I also have to create an indicator...

          That's a good idea though... If I fail with my other efforts, I may have no other choice.

          Thx.

          Comment


            #6
            Originally posted by BigWaveDave View Post
            That may be the answer. Of course, this requires that I also have to create an indicator...

            That's a good idea though... If I fail with my other efforts, I may have no other choice.

            Thx.
            Well, you will be at least able to use it in your next strategy with ease

            Comment


              #7
              Yeah, I guess it's not a huge deal to have the indicator.

              I appreciate the technique...

              Comment


                #8
                Originally posted by BigWaveDave View Post
                Ok, I know this is unsupported stuff...

                The Plot() override provides a bounds rectangle and a min, max price value which is enough info to do all sorts of wonderful custom drawing in the panel.

                It appears that this function is only available in an Indicator.

                Does anybody know how I can get updates of this info from within my Strategy?

                Are these undocumented properties of ChartPanel that I can just grab?

                Failing any easy answer, has anybody worked out how to get this info into a strategy?

                thx,
                Dave
                Not sure what you are asking here. You want to know the bounds of the chart?

                Comment


                  #9
                  I need to be able to convert from mouse coords to price and time from within a Strategy. That's the kicker.

                  I'm already aware of the ChartHelper class that provides such conversions (and the ChartControl undocumented members which I assume are relatively new).

                  But, to convert from a Price to a Y coord requires knowing what the min price value on the Y axis is as well as the current pixel/tick ratio. This info, as far as I can tell, is only available through overriding Plot() in an Indicator.

                  Sledge's suggestion is a good one. I can use an Indicator to cache the required values provided in the Plot override. And then access the cached values from my Strategy. The Strategy class doesn't implement Plot() from what I can tell.

                  Obviously having an Indicator just for that purpose is not optimal and complicates distribution of my Strategy. So basically, I'm trying to see if I can get it done with the ChartControl functions.

                  I'm new to NT, so any help would be appreciated.

                  Comment


                    #10
                    Originally posted by BigWaveDave View Post
                    I need to be able to convert from mouse coords to price and time from within a Strategy. That's the kicker.

                    I'm already aware of the ChartHelper class that provides such conversions (and the ChartControl undocumented members which I assume are relatively new).

                    But, to convert from a Price to a Y coord requires knowing what the min price value on the Y axis is as well as the current pixel/tick ratio. This info, as far as I can tell, is only available through overriding Plot() in an Indicator.

                    Sledge's suggestion is a good one. I can use an Indicator to cache the required values provided in the Plot override. And then access the cached values from my Strategy. The Strategy class doesn't implement Plot() from what I can tell.

                    Obviously having an Indicator just for that purpose is not optimal and complicates distribution of my Strategy. So basically, I'm trying to see if I can get it done with the ChartControl functions.

                    I'm new to NT, so any help would be appreciated.
                    Does playing with the objects help any? (not with plot).

                    NT_Ryanm has a link to his code in the indicator forum.


                    Comment


                      #11
                      Thanks Sledge. No.

                      I'm drawing and maintaining my own totally custom objects... completely separate from the built in objects, but displayed in the PricePanel just like the built in ones.

                      I've got them drawing fine... I just need to be able to handle changes in scaling of the Y axis.

                      The only issue I have is not having a GetValueByY type function.

                      That function already exists in ChartHelper (or can easily be created) knowing the actual bounds of the chart (which excludes the are beyond the axis) and knowing the current min and max value on the price axis... All of which are kindly provided by the Plot override... which isn't directly available from a Strategy... lol.

                      Comment


                        #12
                        Ok...

                        ... override Plot(Rectangle bounds, double _min, double _max)...


                        ChartControl.CanvasTop == bounds.Top
                        ChartControl.CanvasLeft == bounds.Left
                        etc...

                        So, the 'bounds' piece is available anywhere...

                        Now... about that _min and _max... the last pieces I need... hopefully without having to implement an Indicator to get them...

                        Still poking around...

                        Comment


                          #13
                          Ok, I give up.

                          The Plot override will do the trick.

                          Thanks all.

                          Comment


                            #14
                            Originally posted by BigWaveDave View Post
                            Ok...

                            ... override Plot(Rectangle bounds, double _min, double _max)...


                            ChartControl.CanvasTop == bounds.Top
                            ChartControl.CanvasLeft == bounds.Left
                            etc...

                            So, the 'bounds' piece is available anywhere...

                            Now... about that _min and _max... the last pieces I need... hopefully without having to implement an Indicator to get them...

                            Still poking around...
                            If you know bounds, then you know max and min. They are given by the height, derived from bounds.

                            ChartControl.Parent.Bounds.Height

                            Then there are ChartControl.GetYByValue() and ChartControl.GetXByBarIdx() functions.

                            Comment


                              #15
                              Thanks for the reply. But I don't follow.

                              Plot() max and min are price values are they not?

                              There's no way that I can think of to derive the min/max price from the bounds of the chart.

                              This is why I'm saying that I need a GetPriceByY type function... which doesn't exist from what I can tell...

                              Or am I missing something obvious?

                              If you have a way to get price min and price max from bounds... I'm quite interested in how that's done...

                              Thx...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by usazencortex, Today, 12:43 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post usazencortex  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              168 responses
                              2,262 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,429 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Working...
                              X