• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Override Plot

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

    Override Plot

    Hi

    Quite a while back Roonius posted a simple Plot Override indicator that showed 12 static lines printed into the right margin using Plot Override. (I can't find that explicit post again, sorry). I understand how the Plot Override is working but I can't figure out how it is actually invoked.

    There is an OnBarUpdate() but it has no statements in it. There is an Initialize where the pens and brushes are defined. But that's it. The lines are made to show by selecting a user parameter to "true" and it all works beautifully, But I don't see how the Plot is "called".

    Can anyone shed any light on this, and/or point me in the direction of the C# explanation of this behaviour?

    thanks in advance

    #2
    Originally posted by I_Quant View Post
    Hi

    Quite a while back Roonius posted a simple Plot Override indicator that showed 12 static lines printed into the right margin using Plot Override. (I can't find that explicit post again, sorry). I understand how the Plot Override is working but I can't figure out how it is actually invoked.

    There is an OnBarUpdate() but it has no statements in it. There is an Initialize where the pens and brushes are defined. But that's it. The lines are made to show by selecting a user parameter to "true" and it all works beautifully, But I don't see how the Plot is "called".

    Can anyone shed any light on this, and/or point me in the direction of the C# explanation of this behaviour?

    thanks in advance
    There is a Plot() function that is called by default on OnBarUpdate or chart refresh. You can define your own Plot() routine to override the default function. IOW, all you have to do to use a custom Plot() function is to specify said Plot() function as an override.

    There is no Plot() statement in the OnBarUpdate() event handler, because the code was written to call the default Plot() function. It is just like any other event handler/function, where you can define a new function that calls another function, so that the new function when called shows no explicit call to the called function.
    Last edited by koganam; 03-18-2012, 09:31 PM.

    Comment


      #3
      many thanks for the explanation Koganam.

      I'm sure with a bit more C# experience I will understand it, lol. I get the gist though, many thanks.

      Can I mix this type of plot override with the usual Ninja Plot functions ? for example I would like to show 3 or 4 Ninja plots together with my own custom label plots... say by "Calling" specific instances of the custom label plot under certain circumstances.

      (Edit: I will leave that question in to provide context but I think I see the answer is that I can do anything providing my C# skills are up to the mark! unlucky me then :-)

      However may I ask where the arguments for the Plot Override are created?
      public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

      The reason I ask is so that if I create my own customPlot( arguments ) I know how to create the bounds, min and max values ...

      thanks again

      your help is appreciated.
      Last edited by I_Quant; 03-18-2012, 11:33 AM.

      Comment


        #4
        Originally posted by I_Quant View Post
        many thanks for the explanation Koganam.

        I'm sure with a bit more C# experience I will understand it, lol. I get the gist though, many thanks.

        Can I mix this type of plot override with the usual Ninja Plot functions ? for example I would like to show 3 or 4 Ninja plots together with my own custom label plots... say by "Calling" specific instances of the custom label plot under certain circumstances.

        (Edit: I will leave that question in to provide context but I think I see the answer is that I can do anything providing my C# skills are up to the mark! unlucky me then :-)

        However may I ask where the arguments for the Plot Override are created?
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

        The reason I ask is so that if I create my own customPlot( arguments ) I know how to create the bounds, min and max values ...

        thanks again

        your help is appreciated.
        That may not really be necessary, as bounds, max and min are defined properties of the chart. However, if you want to see some examples of custom Plots, NT itself ships with a CustomPlotSample.cs file. There are other examples in pivots.cs, pricealert.cs, regressionchannel.cs, and a few others besides.
        Last edited by koganam; 03-18-2012, 09:31 PM.

        Comment


          #5
          Tried to use the Plot overwrite in NT version 8. but failed.

          Any idea if there is a change to the function name? or has this method been obsoleted in NT8?

          Thanks

          Comment


            #6
            Hello ystan79,

            Thank you for your post.

            The name is now OnRender(), you can find information at the following link: http://ninjatrader.com/support/helpG...s/onrender.htm
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              You can also find an example in NinjaTrader 8 under the NinjaScript Editor window > Indicators > SampleCustomPlot.
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                Thanks for the response.

                In my script, I have 2 SMA lines, one fast and one slow. When the Fast line crosses above the slow line, I would like to paint/highlight the area between these 2 lines blue and if it crosses below, I would like to paint/highlight the area between these 2 lines pink.

                previously I was using Graphics class to drow paths along this lines (between crosses) and filling in the path with color after the path completes within the Plot() function.

                Understand that now NT8 is using SharpDx. Do you have any advise how I can do this (my guess is using DrawGeometry, but will need time to figure out the syntax.

                Do you have any advises, work arounds or sample codes I can refer to?

                Comment


                  #9
                  Hello,

                  Thank you for the question.

                  I don't believe there is a specific example of Geometry from NinjaTrader currently, I believe best example would likely be the Draw.Region tool.

                  I would suggest reviewing the DrawingTools -> Region file, The majority of the OnRender in this file is specifically dealing with Geometry in the way you are asking or a Region of space. This also accounts for some rendering problems so it would be the most full example I could provide.

                  Aside from that, you could see how the Pivots indicator loops through the Plots in the case you want to store data in a Plot and later use it from OnRender.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Vincere, Yesterday, 11:20 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Vincere
                  by Vincere
                   
                  Started by lMagi, 05-18-2019, 09:34 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_ChrisSch  
                  Started by uday12, Yesterday, 10:26 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post uday12
                  by uday12
                   
                  Started by uday12, Yesterday, 10:07 PM
                  0 responses
                  0 views
                  0 likes
                  Last Post uday12
                  by uday12
                   
                  Started by Nabil, Yesterday, 07:46 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X