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

Disable/Hide open orders using right clicking on chart

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

    Disable/Hide open orders using right clicking on chart

    Hello, just as the title says

    is it possible from ninjascript alter/modify the menu which appears after right-clicking on the chart?
    Click image for larger version  Name:	menu.png Views:	0 Size:	120.3 KB ID:	1198384

    For example, I want to modify it when the charttrader is still ON, but not showing buy or sell orders in the menu(when the charttrader is ON)

    is there something as:

    Code:
     //find chart trader from myChart's Chart Control by its Automation ID: "ChartWindowChartTrader"
      chartTrader = Window.GetWindow(myChart.ActiveCha rtControl.Parent).FindFirst("ChartWindowChartTrade rControl") as Gui.Chart.ChartTrader;
    For finding the elements in the menu window for "Buy limit" "buy MIT", etc? if so where can I find that documentation?

    Regards,
    Ale
    Last edited by alejandro888; 04-21-2022, 08:04 PM.

    #2
    Hello Ale,

    It is possible to alter the context menu. That menu is built dynamically so you would have to work with the context menu events. There is a sample of doing that in the following post: http://ninjatrader.com/support/forum...87&postcount=6


    For finding the elements in the menu window for "Buy limit" "buy MIT", etc? if so where can I find that documentation?
    Are you asking to find the existing menu items to use them in some way? The menu items would only exist in the context menu's collection of items while the chart trader is open.



    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse, thanks for the example, I was digging a bit on this, but I could not realize how to use existing items or ids to manipulate them

      Yes, I want to find the existing menu items when right-clicking on the chart then alter them, as hide or disable particularly for the ones to create orders

      Comment


        #4
        Hello alejandro888,

        I am not certain if you could modify the existing items, that depends on when those are being added. You can access the context menu from the events that are shown in that sample. The platform is using WPF controls so you can learn more about how the events for the context menu work along with how context menus are built by searching online for "WPF context menu and WPF dynamic context menu"

        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse, I am not used to working with WPF, but it seems something is not working correctly after acceding to object for the menuitem for the ones used for place orders.
          Click image for larger version

Name:	menu2.png
Views:	251
Size:	38.2 KB
ID:	1198643

          after acceding all the items on the menu, then disabling and hiding them, the ones in the red rectangle are not being affected by the changes

          also, after check all the items in the menu, I saw in the index 9 to 16 items that are not in the menu, but still after disabling/hiding them are still appearing some in the red rectangle
          Code:
          Index:0 header Instrument
          Index:1 header Intervals
          null at :2
          Index:3 header Alerts...
          Index:4 header Data Series...
          Index:5 header Indicators...
          Index:6 header Strategies...
          Index:7 header Strategy Performance
          null at :8
          Index:9 header Buy Limit 1 @ 14468.00
          Index:10 header Buy MIT 1 @ 14468.00
          Index:11 header Sell Limit 1 @ 14468.00
          Index:12 header Sell MIT 1 @ 14468.00
          Index:13 header Buy Stop Market 1 @ 14468.00
          Index:14 header Buy Stop Limit 1 @ 14468.00
          Index:15 header Sell Stop Market 1 @ 14468.00
          Index:16 header Sell Stop Limit 1 @ 14468.00
          null at :17
          Index:18 header Drawing Tools
          Index:19 header Paste
          Index:20 header Zoom In
          Index:21 header Zoom Out
          null at :22
          Index:23 header Always On Top
          Index:24 header Show Tabs
          Index:25 header Crosshair
          Index:26 header Show Data Box
          Index:27 header Save Chart Image
          Index:28 header Print
          Index:29 header Share
          null at :30
          Index:31 header Reload All Historical Data
          Index:32 header Reload NinjaScript
          Index:33 header Templates
          null at :34
          Index:35 header Properties
          Can you give me any suggestions to manipulate the items related to the orders? Because they are not being affected by my changes

          Regards,
          Ale

          Comment


            #6
            Hello alejandro888,

            Unfortunately I couldn't make any suggestions there. In general we do not suggest modifying the existing trading buttons to avoid any problems with the ability to manage your position/orders/account. The platform makes use of the context menu and other trading buttons for its own purposes which you won't be able to prevent. You may see style changes or updates to their visibility which you won't be able to change or you may see that changes you make don't stick because the platform is actively controlling them. The menu items you have shown are dynamically generated every time you open the menu based on the mouse position in the chart so it would be unlikely that changes you make to those items would be retained. In theory you would have to do your action every time the menu was opened but that also is assuming your script always does its action after the platform is done modifying the menu items which there is no guarantee.

            It would be best to just add your own items in the menu if you want to do something custom. Depending on when the platform adds those controls and how it manages them your script may or may not be able to affect them.



            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            6 responses
            26 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Kaledus, Today, 01:29 PM
            5 responses
            13 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Waxavi, Today, 02:00 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            17 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X