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

button for drawingtool

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

    button for drawingtool

    Hello, I would like to add a button to an area in a drawingtool i have.
    I have checked chelseas wpf examples but i dont think this is quite what i need.

    Im not sure if i need the System.Windows.Controls.Button as i want to :
    handle the click event (which i believe is there)
    set the text/label or image of the button
    set to location/position
    and if visible or not

    some of these methods dont appear to be available.
    This button would belong to the drawingtool class and managed within there

    Can you offer guidance on which button control i need as i want to position the button but the location will be updated as the drawing shifts if moving with the current right hand bar.

    thanks

    #2
    Hello explorer101,

    Do you mean to have the WPF control somewhere in the chart area by where the tool is drawn or just in the same chart such as a toolbar? Adding items to the same chart outside of the chart panel should not be difficult, however if you are trying to add items into the chart panel that would be difficult.

    If you mean within the panel, part of the code you need would be in the DrawingToolTile indicator which comes with the platform. That shows how to use the UserControlCollection and the positioning withing the chart panel. This collection is not exposed to a drawing object as far as I am aware, it is part of IndicatorRenderBase so that would be the difficult part to locate something that works in the same way. A more simple approach may be to add a panel to the chart and then append your controls into your own panel.

    The type of button would be the same as other examples, there is only one wpf Button type. The way you add it and the way you position it would be vastly different than any other sample due to where you are trying to add the button from. A drawing tool is not as simple as an indicator where you can use the inherited property for UserControlCollection or just the parent window to add items.






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

    Comment


      #3
      thanks for quick reply. Just out of curiosity is the office closed tomorrow to support. I can wait til friday.
      yes i figured from surveying the class and methods this was not going to be straightforward.

      I would have thought there would be the ability to simply add a button to a user defined coordinate location on the price chart.
      If is difficult to manage via the drawingtool class and have it owned there would it be better or rather more manageable to have it maintained outside of the drawingtool
      In this case the drawingtool and the instances are owned by an indicator i have. So i could add it to a collection i have for each instance and manage there and the click event handler.

      Just ideas. There must be someway to do this and render the button or even some other control like a button if is possible.

      To perhaps visualise as an example - with the ninja supplied fib retracements when added to a chart ; in order to remove you select the fib instance right click and select 'remove' to delete.
      What if i wanted to add a button in one of the corners of the fib region which when clicked would do the same ie remove/delete the fib drawing.
      That is along the lines of what i am trying to achieve if that helps. So is there somewhere in the fib drawingtool class this could be accomplished and positioning the button within the region at one of the corners? Ie we know where the anchors are for the drawing tool and could figure out coordinates?

      thanks
      Last edited by explorer101; 07-03-2019, 03:38 PM.

      Comment


        #4
        Hello explorer101,

        Correct tomorrow is the US holiday, we will have limited support but will still be in the office. You can post on the forum at any time though, there are no hours to the forum, you may just not get a reply back until someone has a chance to reply.

        I would have thought there would be the ability to simply add a button to a user defined coordinate location on the price chart.
        There is, this is shown in the DrawingToolTile indicator however this is for indicators. You would need to do a little work to manage a WPF control by X/Y values as that is not how WPF normally works when appending controls.

        If is difficult to manage via the drawingtool class and have it owned there would it be better or rather more manageable to have it maintained outside of the drawingtool
        In this case the drawingtool and the instances are owned by an indicator i have. So i could add it to a collection i have for each instance and manage there and the click event handler.
        Very likely, if you want to also include the GUI elements which are not native to either type, the indicator would handle this better and in more ways. Indicators have some inherited properties that can be used along with existing samples which makes it an easier startup choice. In a drawing object, you can access the overall chart but accessing the user control collection to get inside of the chart is another question on its own.

        To perhaps visualise as an example - with the ninja supplied fib retracements when added to a chart ; in order to remove you select the fib instance right click and select 'remove' to delete.
        One idea is to avoid using a button and use the right click menu, that can be modified very easily. A complimentary indicator could be used to watch for your type of drawing tool and then append custom menu items if it is right clicked. There is an existing sample of that concept here using indicator plots: http://ninjatrader.com/support/forum...87&postcount=6


        So is there somewhere in the fib drawingtool class this could be accomplished and positioning the button within the region at one of the corners? Ie we know where the anchors are for the drawing tool and could figure out coordinates?
        Inside the chart panel we still run into the same problem of locating a user control collection that overlays the chart panel, This is built into the chart but there are no obvious ways to access it from the drawing object context. If a corner of the chart would work, I believe the most simple thing to do would be to add a panel instead of trying to append to the actual chart. You can very likely access the overall chart using the ChartControl.Parent for that use case.


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

        Comment


          #5
          thanks for reply i will review your comments. Your suggestion to add custom menu items when right clicking the selected drawing tool; this is something i already do and use extensively. And have an option here for the action i want. I was trying to eliminate a step without needing to right click the drawing and just select the button within the drawing region. But thanks for the suggestion.
          I will review and get back if i have more questions. Enjoy your 4th July across pond there
          thanks

          Comment


            #6
            So i used the approach of having indicator manage the drawingtools and details of position and created Grid for each and adding rows columns along lines of example.
            So looks good and achieved what i wanted ; is interesting is a fair bit of code/work to accomplish but now i have a template for this will be easier to add and do in future.
            Needed to handle the cleanup and deletes of drawingobjects as well which is all good.
            Just now reading on the alignment positioning margin padding parts to get the alignment and positioning of the button in the right location as i resize chart.
            This part probably needs more work to get it better aligned in the region.
            but thanks for the direction. I use grids the XAML so this is the c# equiv of this which i see needed in this instance to dynamically overlay and render
            thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            834 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,290 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            9 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            62 views
            0 likes
            Last Post halgo_boulder  
            Started by Option Whisperer, Today, 09:55 AM
            0 responses
            8 views
            0 likes
            Last Post Option Whisperer  
            Working...
            X