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!
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
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 FilesJimNinjaTrader Customer Service
- 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?
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 FilesJimNinjaTrader Customer Service
- Likes 1
Comment
-
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; } }
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 yertle, Yesterday, 08:38 AM
|
7 responses
28 views
0 likes
|
Last Post
by yertle
Today, 12:15 AM
|
||
Started by bmartz, 03-12-2024, 06:12 AM
|
2 responses
21 views
0 likes
|
Last Post
by bmartz
Today, 12:11 AM
|
||
Started by funk10101, Today, 12:02 AM
|
0 responses
4 views
0 likes
|
Last Post
by funk10101
Today, 12:02 AM
|
||
Started by gravdigaz6, Yesterday, 11:40 PM
|
1 response
8 views
0 likes
|
Last Post Yesterday, 11:49 PM | ||
Started by MarianApalaghiei, Yesterday, 10:49 PM
|
3 responses
10 views
0 likes
|
Last Post Yesterday, 11:33 PM |
Comment