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

How to call the Plot method?

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

    How to call the Plot method?

    Hello,
    I've implemented an indicator with some custom graphic code in the Plot() method following the example in CustomPlotSample. However, I am updating the indicator data asynchronously and I need to have it displayed immediately to the user. Is there any way I can programmatically induce a call to Plot() to achieve that?
    Thanks

    #2
    Hello,

    Unfortunately this is more general C# then NinjaScript therefore falls out of my ability to support. I do know that everything in NinjaTrader is driven by ticks recieved however and we do not support manually updating the chart. You would need to check out or post in this thread for unsupported Tips and Tricks:



    Good Luck!

    Let me know if I can be of further assistance.

    Comment


      #3
      Brett,
      I can't find the information in that thread. I understand this is unsupported but can you at least point me out to some direction? Or maybe someone in the community knows?

      Comment


        #4
        Would have to leave open for someone form the community to assist.

        Comment


          #5
          Plot is an override, and I presume that that is what you have done, One way to call the Plot() method without calling the actual overridden function is to duplicate your custom Plot() code and call it by a different name.

          Code:
          private void PaintBars(Graphics graphics, Rectangle bounds, double min, double max)
          {
          //duplicate of custom Plot() code here
          }
          In the indicator, when you want to force a plot, make a call to PaintBars().
          Last edited by koganam; 01-16-2011, 08:17 PM.

          Comment


            #6
            Koganam,
            I don't have access to the Graphics and Rectangle objects needed to be passed to the drawing method (whether Plot or your PaintBars method) so I can't directly call it. I tried storing them on a first call of Plot but it's not working if I call Plot directly with these values. Only the subsystem has them so I guess I would need to invoke a refresh of the indicator panel or the entire window so it subsequently calls Plot. Does anybody knows how can I get a reference to the indicator panel or the window containing it from the indicator's code? (or any other way to achieve a call to Plot by the subsystem)
            Last edited by supernatural; 01-17-2011, 08:54 AM.

            Comment


              #7
              Originally posted by supernatural View Post
              Koganam,
              I don't have access to the Graphics and Rectangle objects needed to be passed to the drawing method (whether Plot or your PaintBars method) so I can't directly call it. I tried storing them on a first call of Plot but it's not working if I call Plot directly with these values. Only the subsystem has them so I guess I would need to invoke a refresh of the indicator panel or the entire window so it subsequently calls Plot. Does anybody knows how can I get a reference to the indicator panel or the window containing it from the indicator's code? (or any other way to achieve a call to Plot by the subsystem)
              I do not understand. Your very first post in the thread starts with:

              I've implemented an indicator with some custom graphic code in the Plot() method following the example in CustomPlotSample.
              How then did you implement your custom Plot()?

              Comment


                #8
                Is there a problem with things like GC lifetime? Can you squirrel away a GC and expect it to be valid later? How about the other information passed in to Plot() as parameters -- is it guaranteed to still be valid when he does his ersatz Plot()? What about if the user has resized the screen in the meantime?

                --EV

                Comment


                  #9
                  Originally posted by koganam View Post
                  How then did you implement your custom Plot()?
                  Plot() is overridden and called by the subsystem which provides it with the necessary graphics objects. It is called at each new bar when a graphic event occurs in the graph window. I don't call Plot directly (but I'm trying to).

                  Comment


                    #10
                    I agree that would not be a clean way, and anyway it's not working. Probably the proper way to achieve a call to Plot would be to call a refresh on the window containing the indicator panel, which would then force a call to Plot. The problem is how can I get a handle to that window from the indicator's code...


                    Originally posted by ETFVoyageur View Post
                    Is there a problem with things like GC lifetime? Can you squirrel away a GC and expect it to be valid later? How about the other information passed in to Plot() as parameters -- is it guaranteed to still be valid when he does his ersatz Plot()? What about if the user has resized the screen in the meantime?

                    --EV

                    Comment


                      #11
                      Originally posted by supernatural View Post
                      Plot() is overridden and called by the subsystem which provides it with the necessary graphics objects. It is called at each new bar when a graphic event occurs in the graph window. I don't call Plot directly (but I'm trying to).
                      So is your original statement then incorrect? Have you or have you not written a custom plot that overrides the default Plot() method? Your initial statement implies that you have. Am I missing something here ?

                      Comment


                        #12
                        Originally posted by supernatural View Post
                        ... achieve a call to Plot would be to call a refresh on the window containing the indicator panel, which would then force a call to Plot. ...
                        The unsupported ChartControl.Refresh() ?

                        Comment


                          #13
                          Yes I did override Plot and it works. But it is called (implicitely) at each bar. And I want to call (explicitely) it between bars, at any time I want. This is because I am updating my indicator with data that is downloaded from the internet and that data is updated asynchronously.


                          Originally posted by koganam View Post
                          So is your original statement then incorrect? Have you or have you not written a custom plot that overrides the default Plot() method? Your initial statement implies that you have. Am I missing something here ?

                          Comment


                            #14
                            Originally posted by supernatural View Post
                            Yes I did override Plot and it works. But it is called (implicitely) at each bar. And I want to call (explicitely) it between bars, at any time I want. This is because I am updating my indicator with data that is downloaded from the internet and that data is updated asynchronously.
                            Then from the signature of the Plot() method, your custom plot must have a graphics input.

                            Why do you think that a copy of that method, with the same signature, cannot access a graphics object?

                            Comment


                              #15
                              That's it! This is what I was looking for. Thanks a lot Koganam. What a relief. Very useful this ChartControl, too bad this is undocumented.

                              Originally posted by koganam View Post
                              The unsupported ChartControl.Refresh() ?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 01:16 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              3 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by samish18, Today, 01:01 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by WHICKED, Today, 12:56 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by WHICKED, Today, 12:45 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X