RDPoS
11-23-2010, 02:07 PM
Would love to know what code and where it goes in order to receive an email when the API loses connection with the broker, or when an order is canceled.
NinjaTrader_Tim
11-23-2010, 03:00 PM
You can use OnConnectionStatus() and SendMail when reconnecting:
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?OnConnectionStatus
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?SendMail1
Cancelled orders can be tracked with IOrder: http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?IOrder
RDPoS
12-17-2010, 04:48 AM
I was trying to get a handle on how to receive an email when an order was filled. I understand the SendMail() part, but I don't quite follow the order filled part.
Taking a part of my existing strategy
// Condition set 1
if (DefaultInput[0] < ChandelierSAR(6, 4).Chandelier[0])
// && Time[0].DayOfWeek != DayOfWeek.Friday)
{
EnterLongStop(DefaultQuantity, ChandelierSAR(6, 4).Chandelier[0], "");
DrawDot("My dot" + CurrentBar, false, 0, ChandelierSAR(6, 4).Chandelier[0], Color.Blue);
}
// Condition set 2
if (DefaultInput[0] > ChandelierSAR(6, 4).Chandelier[0])
{
ExitLongStop(ChandelierSAR(6, 4).Chandelier[0], "", "");
DrawDot("My dot" + CurrentBar, false, 0, ChandelierSAR(6, 4).Chandelier[0], Color.Blue);
}
Is it as simple as the following?
protected override void OnOrderUpdate(IOrder order)
{
if (order.OrderState == OrderState.Filled)
{
SendMail("XXX@gmail.com", "XXX@gmail.com", "Orderfilled", "Position Stopped Out")
}
}
How can you distinguish between an entry fill and an exit fill?
NinjaTrader_Tim
12-17-2010, 07:27 AM
Hi RDPoS,
Not explicitly, as no specific order type is designated as an exit order.
You could check for position size with Market Position: http://www.ninjatrader.com/support/helpGuides/nt7/index.html?marketposition.htm
RDPoS
12-17-2010, 09:04 AM
Well I guess if I can somehow get it to recognize whether the strat has a position or is flat I can deduce which is which in the email. Is that possible to distinguish between 0 orders and 1 order (non-flat)?
NinjaTrader_Tim
12-17-2010, 09:35 AM
Hi RDPoS,
You would need to check for each OrderState explicilty: http://www.ninjatrader.com/support/helpGuides/nt7/index.html?iorder.htm