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 judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
57 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment