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 burtoninlondon, Today, 12:38 AM
        0 responses
        5 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        13 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        13 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,982 views
        3 likes
        Last Post jhudas88  
        Working...
        X