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

Updating Chart trader quantity from custom drawing tool

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

    Updating Chart trader quantity from custom drawing tool

    Hi, I'm new to Ninjatrader ecosystem and to C# to be honest (but I have knowledge in PHP, so it was easy to grab the principle fast with a few adjustments).
    I was able to create a custom drawing tool that works perfectly fine.
    But I wasn't able to find a way (even after reading/searching the forums here) to update dynamically the order quantity in ChartTrader based on the drawing tool calculations.

    I don't wan't to send an order and then to update it and I don't want to create a custom strategy.
    I just want to prepare the quantity without executing any order.
    I guess it should be something that is very simple, but I'm missing something out.

    I'm able to get the quantity via:
    Code:
    ChartControl.OwnerChart.ChartTrader.Quantity
    And I tried to use the following code from the forums here, but was unsuccessful:
    Code:
                        
    chartControl.Dispatcher.InvokeAsync(((Action) =>
    
    {
    NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector = System.Windows.Window.GetWindow(chartControl.Parent).FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown;
    
    quantitySelector.Value = quantityAmount;
    }));
    ​
    Would really appreciate your help with actual code and where to implement it (In OnRender function or somewhere else).

    #2
    Hello xfactscount,

    Welcome to the Forums and thanks for your post.

    Please see the example attached on the forum thread linked below for capturing ChartTrader controls for use in code.
    Hi, is it possible to access the chart trader to set the order Qty per script, e.g. from an indicator? explorer_QtC6zjm3Xc.jpg chartTrader = chartWindow.FindFirst("ChartWindowChartTraderControl") as ChartTrader; chartTrader.OrderQty ???


    If you want to programmatically change a property of this control, you will need to use ChartControl.Dispatcher.InvokeAsync() since the element would reside on the chart's UI thread.

    Multi-threading considerations for NinjaScript: https://ninjatrader.com/support/help...ing.htm​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Brandon.
      Was able to figure it out myself eventually. Just needed a good night sleep I guess lol.
      I attached the quantity update function to onMouseUp function within only building or editing state.

      Comment


        #4
        Originally posted by xfactscout View Post
        Thanks Brandon.
        Was able to figure it out myself eventually. Just needed a good night sleep I guess lol.
        I attached the quantity update function to onMouseUp function within only building or editing state.
        Hi! I'm trying to do the same, could you share your code please?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        5 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        61 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        4 responses
        3,289 views
        1 like
        Last Post jgualdronc  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        5 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        24 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X