Objective: to replicate the native “Move Stop to Breakeven” hotkey - plus a configurable tick offset. (feature first requested 2017). Acting on whichever SuperDOM has focus.
I’ve tried three different approaches, each hitting a different wall:
1. SuperDomColumn
From a custom SuperDomColumn, I can read SuperDom.Instrument and SuperDom.Account directly (confirmed working). But I’ve found no way to determine whether that specific SuperDOM window currently has focus:
thisis not aDependencyObject—Window.GetWindow(this)fails to compile with CS1503.SuperDomis aSuperDomViewModel, also not aDependencyObject— same CS1503 failure.- The official Language Reference for SuperDomColumn lists only six methods (
OnMarketData,OnOrderUpdate,OnPositionUpdate,OnPropertyChanged,OnRender,OnRestoreValues) — no mouse-click or focus-related handler at all.
2. AddOnBase + Control Center menu
Separately (for a settings UI, not focus detection), I found that ControlCenter.MainMenu.Items fails to compile with CS0122 (“inaccessible due to its protection level”) — MainMenu returns an internal type. Walking the visual tree via VisualTreeHelper from ControlCenter downward does work for finding menu items by matching on visible Header text, and FindFirst("ControlCenterMenuItemNew") (an automation ID) also works reliably for attaching a custom menu item. So automation-ID-based lookups succeed on ControlCenter, but the two techniques above for identifying “which window has focus” don’t have an equivalent I’ve found for SuperDOM windows.
3. Regular Indicator applied to a SuperDOM
I found a past support answer to a similar question suggesting: “grab the window itself, find the SuperDom object, and access SuperDom.Account.” Based on that, I built an indicator that enumerates Application.Current.Windows (independent of the object itself, avoiding the DependencyObject problem) looking for a SuperDOM window matching the indicator’s own Instrument. Tested live: Application.Current.Windows.Count returns 0, consistently, even though real windows are open (Control Center, the SuperDOM itself, Charts, confirmed via other diagnostics), and even when the check runs on the UI dispatcher thread via Application.Current.Dispatcher.InvokeAsync.
My specific questions:
- Is there any supported, public way — from a
SuperDomColumn, a regularIndicatorapplied to a SuperDOM, or anAddOnBase— to determine which SuperDOM window currently has focus? - Why does
Application.Current.Windowsreturn an empty collection when queried from indicator/add-on code, even on the UI thread, when NinjaTrader’s own windows are demonstrably open? - Is the mechanism the native “Breakeven Position” hotkey uses to route to the focused DOM internal to the platform and not exposed via the NinjaScript SDK at all?
TIA
Kind regards,
Bruce