Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Canvas for ChartTrader, adding the simpliest type of WPF button?

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

    Canvas for ChartTrader, adding the simpliest type of WPF button?

    Hello,

    I'm converting from NT7 and have quite a few custom buttons on ChartTrader in NT7. I'm completely happy with the fixed position and how they work in Winforms

    And, want to avoid the complexity of the Ninja WPF examples I've seen .... :-)


    There is a WPF Canvas that has methods to add buttons very simply.





    1) Does ChartTrader have a Canvas?

    2) If yes, how do I address it to add buttons?


    Thx



    #2
    I built a custom chart trade w buttons, if there is a canvas object I would like to know about it.

    Comment


      #3
      Hello llanqui,

      Canvas is a WPF control which is not specific to NinjaTrader or the chart trader. All of NinjaTrader is built using WPF controls of various types. The ChartTrader uses a Grid to hold its content because that is the easiest control to position other controls within. It uses columns and rows to achieve that.

      If you wanted to make your own canvas and add that somewhere you could do that, you would need to follow any WPF guidelines for using a Canvas in a WPF application.

      I would suggest looking at the existing examples of modifying the chart trader in the following link. You will need to re use most of what the samples show due to how NinjaTrader works so that your items are added/removed correctly and don't cause errors.

      Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


      In addition to using that sample I highly suggest to do some learning in external resources about general WPF design in C# as that will greatly help if you plan to make custom WPF items in NinjaTrader. The platform is just executing the C# code you give it so adding WPF items can be done in the same way that the above sample shows for any general controls you wanted to make use of.

      Comment


        #4
        Thank you Jesse.

        Well, yes I have read that code...so much WPF code to just make simple buttons.

        I'll see if I'm able to add a Canvas to Chart Trader....

        Anyone in this forum have ideas?


        If not I'll start a new thread here or post on an external developer forum.

        Comment


          #5
          according to https://www.wpf-tutorial.com/panels/canvas/

          this is how simple it is, and how little code is needed to position three buttons and one ellipse

          <Window

          x:Class="WpfTutorialSamples.Panels.Canvas"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

          Title="Canvas" Height="200" Width="200">
          <Canvas>
          <Button Canvas.Left="10">Top left</Button>
          <Button Canvas.Right="10">Top right</Button>
          <Button Canvas.Left="10" Canvas.Bottom="10">Bottom left</Button>
          <Button Canvas.Right="10" Canvas.Bottom="10">Bottom right</Button>

          </Canvas>
          </Window>

          Comment


            #6
            Hello llanqui,

            What you are showing is a new empty WPF application, that of course is going to be very simple to add to because you have access to the xaml file and can use WPF elements in a compiled way. You would compile that code using visual studio and run the application to see the result.

            In NinjaTrader you are not doing that, you are modifying a running application to inject new elements into an existing control which takes a lot more effort. You don't have access to the xaml file for the chart trader so you cant simply use xaml to do what you are asking.

            When you edit an existing control there are more steps involved. You need to worry about finding the control, having a instance to the control as a variable so you can modify it, threading, managing resources for your own new controls based on the chart events etc. There are many more steps in editing an existing control.

            That sample that I linked to is complete meaning you can re purpose that and its already gone through all of the hard parts to make sure it works right in the chart.

            If you don't want to work with existing controls there are more simple ways to add elements to the chart, for example using the UserControlCollection: https://ninjatrader.com/support/help...ub=usercontrol



            Comment


              #7
              Ok, thanks....the UserControlCollection will give me what I need...I don't actually need the buttons on ChartTrader, on the Price Panel would be OK, but at the bottom right where I can get to it fast with the mouse.

              This is where I had it on ChartTrader in NT7, near the bottom.

              Comment


                #8
                Hello llanqui,

                Yes you can reposition that in the chart as needed. You can also see the indicator DrawingToolTile that comes with the platform. That uses the UserControlCollection for its movable window and shows off some more advanced positioning options.

                Comment


                  #9
                  Perfect, thank you.

                  With this I can probably do what I need without the "abundant" WPF code.... :-)

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  639 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  366 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  107 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  569 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  572 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X