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 draw indicator panel on chart

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

    How to draw indicator panel on chart

    I have attached a screen shot from MT4 that I would like to duplicate in NinjaTrader. It's a 'dashboard' type panel you see in the upper right. Notice it has different fonts/colors and the values can change from tick to tick. I don't think this can be done with the DrawTextFixed function. I'm not sure where to start though with drawing this on the main chart panel. Would this be something with System.Drawing.Graphics, maybe? Or System.Drawing.Drawing2D namespace? Or do I have to override the Plot function, maybe?

    I just need a little help to steer me in the right direction on what method/function I need to study to be able to put something like this on a chart. I can handle setting text and calculating the values and setting colors and whatnot -- I just need a little pointer with whatever C# or .Net namespace I need to use to do it.

    Thanks!
    Bryan
    Attached Files
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Originally posted by cassb View Post
    I have attached a screen shot from MT4 that I would like to duplicate in NinjaTrader. It's a 'dashboard' type panel you see in the upper right. Notice it has different fonts/colors and the values can change from tick to tick. I don't think this can be done with the DrawTextFixed function. I'm not sure where to start though with drawing this on the main chart panel. Would this be something with System.Drawing.Graphics, maybe? Or System.Drawing.Drawing2D namespace? Or do I have to override the Plot function, maybe?

    I just need a little help to steer me in the right direction on what method/function I need to study to be able to put something like this on a chart. I can handle setting text and calculating the values and setting colors and whatnot -- I just need a little pointer with whatever C# or .Net namespace I need to use to do it.

    Thanks!
    Bryan
    Bryan, I believe that I already answered this in another thread, but here goes again, just in case I am drunk from too much hopium in these dang markets.

    You need to use a Custom Plot that uses DrawString(). Look at the CustomPlotSample.cs file for ideas on how.
    Last edited by koganam; 02-05-2013, 08:06 AM. Reason: Corrected grammar.

    Comment


      #3
      Oh, yes I'm sorry - you did koganam. My mistake. Thank you - I will look at the DrawString and that sample .cs file.

      Bryan
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        OK, I have made a copy of the CustomPlotSample and am modifying it -- looks great so far, thanks! I have the dashboard rectangle drawn like this:

        Code:
                    ChartOnly            = true;
                    DrawOnPricePanel    = true;
        [...]
                    SolidBrush tmpBrush = new SolidBrush(Color.Black);
                    if (!InHitTest)
                        graphics.FillRectangle(tmpBrush, new Rectangle(500, 0, 100, 200));
                    tmpBrush.Dispose();
        Now, if I want to 'float' that rectangle in the upper right of the chart even when you resize the chart window, what events do I need to add to adjust the rectangle placement on the chart panel?

        Is there already a thread somewhere that I can find info on this custom Plot function and different ways to use it?

        Thanks!
        Bryan
        cassb
        NinjaTrader Ecosystem Vendor - Logical Forex

        Comment


          #5
          Oh, nevermind, that was a dumb question. lol Here's the code to anchor it to the right side of the chart panel. This does what I wanted:

          Code:
                      SolidBrush tmpBrush = new SolidBrush(Color.DimGray);
                      if (!InHitTest)
                          graphics.FillRectangle(tmpBrush, new Rectangle(bounds.X + bounds.Width - 175, 0, 160, 230));
                      tmpBrush.Dispose();
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Originally posted by cassb View Post
            OK, I have made a copy of the CustomPlotSample and am modifying it -- looks great so far, thanks! I have the dashboard rectangle drawn like this:

            Code:
                        ChartOnly            = true;
                        DrawOnPricePanel    = true;
            [...]
                        SolidBrush tmpBrush = new SolidBrush(Color.Black);
                        if (!InHitTest)
                            graphics.FillRectangle(tmpBrush, new Rectangle(500, 0, 100, 200));
                        tmpBrush.Dispose();
            Now, if I want to 'float' that rectangle in the upper right of the chart even when you resize the chart window, what events do I need to add to adjust the rectangle placement on the chart panel?

            Is there already a thread somewhere that I can find info on this custom Plot function and different ways to use it?

            Thanks!
            Bryan
            You need to anchor the origin relative to bounds, measuring from the right of the chart.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Today, 09:29 PM
            0 responses
            7 views
            0 likes
            Last Post Belfortbucks  
            Started by zstheorist, Today, 07:52 PM
            0 responses
            7 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            151 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            6 views
            0 likes
            Last Post mattbsea  
            Working...
            X