Announcement

Collapse
No announcement yet.

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​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        621 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        566 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X