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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        92 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        138 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        122 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        73 views
        0 likes
        Last Post PaulMohn  
        Working...
        X