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
Trade Tracking
Collapse
X
-
Hello ballboy11,
You can loop through the orders in an account.
Below is a publicly available link to the help guide.
However, there is not a trade performance collection for account objects.
Please let me know if you would like to submit a feature request for the NinjaTrader Development to consider adding a trade performance collection to account objects.Chelsea B.NinjaTrader Customer Service
-
i have been going through your NT8 manual but I am confused how to retrieve myEntryOrder.
/* Example of subscribing/unsubscribing to order update events from an Add On. The concept can be carried over
to any NinjaScript object you may be working on. */
public class MyAddOnTab : NTTabPage
{
private Account account;
private Order myEntryOrder;
private Order profitTarget;
private Order stopLoss;
public MyAddOnTab()
{
// Find our Sim101 account
lock (Account.All)
account = Account.All.FirstOrDefault(a => a.Name == "Sim101");
// Subscribe to order updates
if (account != null)
account.OrderUpdate += OnOrderUpdate;
}
// This method is fired as the status of an order changes
private void OnOrderUpdate(object sender, OrderEventArgs e)
{
// Submit stop/target bracket orders
if (myEntryOrder != null && myEntryOrder == e.Order)
{
if (e.OrderState == OrderState.Filled)
{
string oco = Guid.NewGuid().ToString("N");
profitTarget = account.CreateOrder(e.Order.Instrument, OrderAction.Sell, OrderType.Limit, TimeInForce.Day,
e.Quantity, e.AverageFillPrice + 10 * e.Order.Instrument.MasterInstrument.TickSize, 0, oco, "Profit Target", null);
stopLoss = account.CreateOrder(e.Order.Instrument, OrderAction.Sell, OrderType.StopMarket, TimeInForce.Day,
e.Quantity, 0, e.AverageFillPrice - 10 * e.Order.Instrument.MasterInstrument.TickSize, oco, "Stop Loss", null);
account.Submit(new[] { profitTarget, stopLoss });
}
}
}
Comment
-
Hello ballboy11,
When using the Addon approach to find orders that are not submitted by the NinjaScript Strategy, you would need to loop through the orders collection from the account.
If you are trying to detect new orders, you would need an event handler added to the <Account>.OrderUpdate event.
Below is a public link to the help guide.
OnOrderUpdate only triggers for orders submitted from the NinjaScript Strategy that this is being checked from. Manual orders and orders submitted from outside of the strategy will not affect the strategy position, orders, or performance.
From your initial description, it sounds as if you would like all orders to an account and not only the orders submitted from a NinjaScript strategy, is this not the case?
If you are looking for the Strategy performance of a NinjaScript Strategy this can be found with SystemPerformance.
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by TheTradingMantis, 10-31-2017, 03:18 PM
|
5 responses
1,251 views
0 likes
|
Last Post
by TheAngryCube
Today, 04:06 PM
|
||
Started by Padan, Today, 02:02 AM
|
9 responses
23 views
0 likes
|
Last Post Today, 03:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
7 responses
22 views
0 likes
|
Last Post Today, 03:26 PM | ||
Started by nandhumca, Today, 03:15 PM
|
1 response
4 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by PopovDS, 03-11-2024, 12:49 PM
|
3 responses
17 views
0 likes
|
Last Post
by PopovDS
Today, 03:16 PM
|
Comment