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

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

            Comment


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

              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 BarzTrading, Today, 07:25 AM
                  2 responses
                  26 views
                  1 like
                  Last Post BarzTrading  
                  Started by devatechnologies, 04-14-2024, 02:58 PM
                  3 responses
                  20 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by tkaboris, Today, 08:01 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post tkaboris  
                  Started by EB Worx, 04-04-2023, 02:34 AM
                  7 responses
                  163 views
                  0 likes
                  Last Post VFI26
                  by VFI26
                   
                  Started by Mizzouman1, Today, 07:35 AM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Working...
                  X