Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Set ChartTrader Order Quantity via script
Collapse
X
-
Set ChartTrader Order Quantity via script
Tags: None
-
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
- Likes 2
-
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?
The OrderQty propertie is the property in the base class that is to update itself.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 }); }
Comment
-
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
- Likes 1
Comment
-
For those who are interested, here is my solution:
Base class:
View 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; } }
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 }); }
- Likes 4
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
563 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
329 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment