Hello,
I am developing a NinjaTrader 8 AddOn called SDTGestorOrdenes.
The AddOn successfully detects the chart’s native ContextMenuOpening event and adds a custom menu item called “SDT Buy Limit”.
My goal:
I need to obtain the exact price level where the user right-clicks on the chart, so I can eventually place a Buy Limit order at that price using the ATM strategy selected in Chart Trader.
What I have confirmed:
-
The native context menu opens correctly.
-
The event sender is
NinjaTrader.Gui.Chart.ChartControl. -
ContextMenuEventArgs.CursorTopprovides a vertical coordinate. -
The chart has one panel and three scales: Right, Left, and Overlay.
The problem:
I attempted to use:
chartControl.ChartPanels[0].Scales[0].GetValueByYWpf(e.CursorTop)
The code compiled successfully, but opening the context menu caused an unhandled NullReferenceException.
My questions:
-
What is the correct and safe way to obtain the exact price at the right-click position from a NinjaTrader 8 AddOn?
-
How can I obtain the appropriate
ChartScaleoutside an indicator’sOnRender()method? -
Does
CursorTopuse the correct coordinate system forGetValueByYWpf(), or must the mouse position be converted relative to the chart panel? -
Is there an official example or working code demonstrating this functionality?
I would appreciate guidance from developers who have implemented this successfully.
Thank you.