Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set ChartTrader Order Quantity via script

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

    Set ChartTrader Order Quantity via script

    Hi, is it possible to access the chart trader to set the order Qty per script, e.g. from an indicator?

    Click image for larger version

Name:	explorer_QtC6zjm3Xc.jpg
Views:	579
Size:	9.5 KB
ID:	1214799

    Code:
    chartTrader = chartWindow.FindFirst("ChartWindowChartTraderControl") as ChartTrader;
    chartTrader.OrderQty ???
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your question, yes this is possible.

    Please see the example attached for capturing ChartTrader controls for using in code.

    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.

    Let us know if there is anything else we can do to help.
    Attached Files

    Comment


      #3
      Thanks Jim, for your demo file. I'm trying to set a binding (Two Way) correctly so that via NotifyPropertiechanged event handler in the Base class, the propertie is updated both in the chart trader (UI) and the properties directly. Unfortunately, I can't quite get the binding right. Everything works except for setting the "quantitySelector.Value" directly via the binding. Do you have a tip for me?

      Code:
      // find the ChartTrader quantity selector by AutomationID
      quantitySelector = chartWindow.FindFirst("ChartTraderControlQuantitySelector") as QuantityUpDown;
      if (quantitySelector != null)
         {
             quantitySelector.ValueChanged += QuantitySelector_ValueChanged;
             currentQuantity = quantitySelector.Value;
              //set binding to our OrderQty property in base class
              quantitySelector.SetBinding(QuantityUpDown.ValueProperty, new Binding
                      {      
                              Source = ???
                              Path = new PropertyPath("OrderQty"),
                              Mode = BindingMode.TwoWay,
                              UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                          });
           }
      The OrderQty propertie is the property in the base class that is to update itself.
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        The closest example we have shows a class inheriting from INotifyPropertyChanged and uses XAML to describe bindings.

        This is a bit of an advanced example that goes beyond our scope of support, so we may recommend checking out other publicly available WPF resources on binding.

        If you happen to accomplish your goal, your feedback may be useful for the community, so please write back!
        Attached Files

        Comment


          #5
          For those who are interested, here is my solution:

          Base class:
          Code:
          public int SelectedOrderQty
          {
              get { return selectedOrderQty; }
              set
                   {
                       if (selectedOrderQty != value)
                       {
                           selectedOrderQty = Math.Max(1, value);
                           NotifyPropertyChanged();
                        }
                    }
          }
          
          
          [XmlIgnore, Browsable(false)] public object PropertyBase { get { return this; } }
          View class:
          Code:
          //find the ChartTrader quantity selector by AutomationID
          quantitySelector = chartWindow.FindFirst("ChartTraderControlQuantitySelector") as QuantityUpDown;
          if (quantitySelector != null)
          {
            //set binding to our OrderQty property in the base class
            quantitySelector.SetBinding(QuantityUpDown.ValueProperty, new Binding
               {
                     Source = PropertyBase,
                     Path = new PropertyPath("SelectedOrderQty"),
                     Mode = BindingMode.TwoWay,
                     UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });
          }
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          333 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X