Hello, I’m currently working on a custom drawing tool that calculates the risk/reward of a position. It’s almost finished, however, there’s one part that has kept me from making progress for several weeks: how to access the ChartTrader “Order Qty” box through code so that the tool can use the number entered in that box to calculate the position size based on the number of contracts. Could you please tell me how, from a drawing tool, I can access that property through code so that my tool can read the value entered in that box?
Thank you very much
In one of mine you access it through:
ChartControl.Dispatcher.InvokeAsync((Action)(() => {
NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown);
CTQuantity = quantitySelector.Value;
}));
Several, THANK YOU VERY MUCH
With the information you gave me, I was able to understand the logic behind the procedure so I could have the correct code to access the value of the Quantity box.
I’m not an expert in programming, nor in the NinjaScript environment, so this is twice as difficult or more. I’d like to ask you a couple more questions now:
-
For the same drawing tool, I would like to be able to access the “Account” box to obtain the total value (CashValue or NetLiquidation) of the account selected in that box, and thus be able to calculate the percentage of the account at risk in the transaction.
-
For the same drawing tool, I can’t manage, in the NinjaScript environment, to make some of its features visible only when it’s selected or when the mouse is hovered over it. The problem is that this shouldn’t affect the entire drawing, but only part of it.
The drawing has two main parts: The background-colored rectangles, which don’t contain any information or text and should be visible at all times. The text rectangles, which do contain position information, are just the text rectangles. I want them to be visible only when the drawing is selected or when the mouse is hovered over it.
Thank you so much for the support you’ve already given me.
I hope you can help me with these two new questions as well.
Hugs.
NinjaTrader.Gui.Tools.AccountSelector accountSelector;
Is the account selector. If you search the old forum you will find some info on it. There’s a sample script somewhere that monitors everything in the chart trader for changes and outputs a print.
Why don’t you post it here so others can learn?
Hi Bill, The solutions are already posted here. In both cases, the solution was provided by Several.
Thanks. Sorry, I just was curious about this outcome.