What do I call it to create a panic button?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
chat access
Collapse
X
-
Yes, of course, the fact is that I have a replicator that when an operation is left open in one of the replicated accounts it is detached from the addons and I can only close it from the close button of the chart, that is why I want to access that button from the code, that is:
foreach (var position in submissionAccountMaestra.Positions)
{
if (position.MarketPosition != MarketPosition.Flat)
{
if (position.MarketPosition == MarketPosition.Long)
{
ClosingOrder = submissionAccountMaestra.CreateOrder(instrumentSel ectorMaestra.Instrument, OrderAction.Sell, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, position.Quantity, 0, 0, string.Empty, "MANUAL CLOSE", Globals.MaxDate, null);
submissionMasterAccount.Submit(new[] { ClosingOrder });
}
if (position.MarketPosition == MarketPosition.Short)
{
ClosingOrder = submissionAccountMaestra.CreateOrder(instrumentSel ectorMaestra.Instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, position.Quantity, 0, 0, string.Empty, "MANUAL CLOSE", Globals.MaxDate, null);
submissionMasterAccount.Submit(new[] { ClosingOrder });
}
}
}
I have this close button to which I want to add if (position.MarketPosition == MarketPosition.Flat)
close all open orders
Comment
-
Replace all that with this,
Code:// instantiate a list of instruments Collection<Cbi.Instrument> instrumentsToClose = new Collection<Instrument>(); lock (submissionAccountMaestra.Positions) { // add instruments to the collection foreach (var position in submissionAccountMaestra.Positions) if (position.MarketPosition != MarketPosition.Flat) instrumentsToClose.Add(position.Instrument); } submissionAccountMaestra.Flatten(instrumentsToClose); submissionAccountMaestra.CancelAllOrders(instrumentsToClose);
Comment
-
-
Hey there! Wondering if anyone knows how to access the close button on the trade chart through addons? Thinking of creating a panic button feature! If you're into exploring new possibilities, check out https://omegle.fm/ for some fresh experiences!Last edited by AuroraForbes; 04-28-2024, 06:03 PM.
Comment
-
Hello AuroraForbes,
Welcome to the NinjaTrader forums!
Accessing the Close button and invoking this directly would not be directly supported by NinjaTrader (but is possible).
Instead we would suggest that you use an Account object to call <Account>.Flatten() as suggested in this forum thread, or submit orders to close the position with <Account>.Submit() and cancel orders with <Account>.Cancel().
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
599 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
345 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment