NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 02-27-2011, 11:24 PM   #1
ErikHR
Senior Member
 
Join Date: Apr 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default Trading Live with MB Trading disconnects?

I was trying to turn on my first live trading strategy (Sunday morning) so it would start trading live when the market opens on Monday. I got the error: “unable to connect to order server”. I started a chat with MB Trading support and they said their live and demo servers were going to be turned on shortly at Sunday 4:59 pm EST. I asked when they turn them on and off and they replied, they are off from Friday at 5:01 pm EST - Sunday 4:59 pm EST. I want to turn on a strategy the places trades until all of the money in my account is in trades, periodically it looks for better positions to hold and sells the ill performing ones. So this is a strategy I want to leave running indefinably. Most positions are held (from back testing) 1 to ~3/5 months. I will make sure the strategy is flat the first time I start it with a date filter I have coded. After that it will be potentially be selling positions the first day of every month and buying the second day of every month (rebalancing). Since I will need to reboot my system periodically for software installs, and since I will be cut off from the order servers periodically with lost connections etc… I am trying to figure out how to best configure:
  • Wait until flat before executing live vs. Immediately submit live working historical orders
  • “Cancel entry orders when a strategy is disabled” and “Cancel exit orders when a strategy is disabled”.
  • Sync account position True/False
If I want to have this strategy keep running and tracking positions I think I need to do the following:
  • Use “Immediately submit live working historical orders” so if I have to reboot my computer for some reason it will pick up where it left off.
  • Uncheck “Cancel entry orders when a strategy is disabled” and “Cancel exit orders when a strategy is disabled” so I can shutdown and start up NinjaTrader for computer updates.
  • Sync account postion = true so if my strategy tried to rebalance when I had the system down it will rebalance when the system comes back up.
Am I setting this up right?
Thanks,
Erik
ErikHR is offline  
Reply With Quote
Old 02-28-2011, 05:57 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Erik, unfortunately first of all the following disclaimer has to be kept in mind when autotrading on the MBT connection - MB Trading position events are generated before orders are executed. Since NinjaTrader relies on execution events to come prior to position events, you will experience limitations with tracking positions from the Strategies tab of the Control Center and trying to rely on the standard sequence of events (order execution before position) in NinjaScript.

For your strategy setup 'immediately submit' is the correct option to pick up and not wait for a new signal, however the sync should be done then by as you manually as needed.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-28-2011, 06:39 PM   #3
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Bertrand,

That being the case, is there any sync options that should be initiated as soon as a 'position event' is received from MBT ??
Trader.Jon is offline  
Reply With Quote
Old 03-01-2011, 06:35 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

I'm not following you Jon - the autosync options would not be applicable in this scenario since the strategies tab position reports could not be used to judge whether you're in sync or not.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-01-2011, 09:07 AM   #5
ErikHR
Senior Member
 
Join Date: Apr 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

I am still a little confused on what to expect. Today is the first day of the month so I would expect my strategy will be placing market orders at the close of this bar. Will the orders be executed at tomorrow’s open?

What should I expect to see wrong in NinjaTrader because it is executing against MBT? Will my strategy not keep track of my positions and not close them? What will be wrong? What should I expect to see happen at the end of today and tomorrow morning?

Thanks,
Erik
ErikHR is offline  
Reply With Quote
Old 03-01-2011, 09:20 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Erik, the strategy should trigger tomorrow as the opening tick of the new day bar is received then. The trade order should execute correctly at MBT, but the strategies tab position shown can't be used to jusge whether or not it's in sync to the account begin executed to, as event ordering in which the events are received are mixed up.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-01-2011, 09:35 AM   #7
ErikHR
Senior Member
 
Join Date: Apr 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

I am still not sure I fully understand the ramifications of the events firing out of order, but I have one computer running the strategy using IQFeed and the SIM account and another computer running the strategy against MBT live account so I guess the differences will become clear to me soon. Or at least I will have more questions :-)

Thanks,
Erik
ErikHR is offline  
Reply With Quote
Old 03-04-2011, 04:06 PM   #8
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Question More on kind of disconnects

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
I'm not following you Jon - the autosync options would not be applicable in this scenario since the strategies tab position reports could not be used to judge whether you're in sync or not.
Taking an explicit scenario: MB forex trading intraday with no positions held at 5pm EST close ... should there be an account sync &/or trade in progress test of some type BEFORE each market position test for trade entry to verify if any disconnects have not 'neglected to report' altered trade status. I am speaking on use of managed orders.

I already test for iOrder != null, and cancel if order is open, before submit new order. I am wondering if same should be done for sENTRY != null as I have seen overfill notices in SIM on MB Trading. I understand I may be over reacting, so a response on whether a test such as this might cause problems with MB reporting is also appreciated. ... as in having partial fills of entrys or covers

Thanks for clarification,
Jon
Last edited by Trader.Jon; 03-04-2011 at 04:14 PM.
Trader.Jon is offline  
Reply With Quote
Old 03-05-2011, 01:56 PM   #9
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Jon, Bertrand will be back in on Monday and I will have him respond then.
NinjaTrader_Austin is offline  
Reply With Quote
Old 03-07-2011, 06:16 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Jon, I'm not following you - why are you attempting to test for any sync if you're working with a flat account and strategy position?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-09-2011, 09:46 AM   #11
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Jon, I'm not following you - why are you attempting to test for any sync if you're working with a flat account and strategy position?
Bertrand,

NT support has advised that the API from MB Trading sends position information before the entry is actually completed. ... your post here "event ordering in which the events are received are mixed up." ... re: IF I had submitted an order && position reported as no longer flat by MBT, but entry actually never completed before the new bar forms and another new order is sumitted, but there is an entry now made from the original order completed.

Jon
Trader.Jon is offline  
Reply With Quote
Old 03-09-2011, 09:51 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Jon, I'm sorry I do not follow you - the issue is: the position update will be send before the actual execution update which is from NT's point of view an 'illogical' event sequence which leads then to tracking issues.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-09-2011, 10:39 PM   #13
ErikHR
Senior Member
 
Join Date: Apr 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

So is this a common problem with using NT againt MBT. My strategy put in an order to buy an ETF. I did not check all of my symbols and it turns out this ETF could not be purchased in mixed and/or or odd lots. So the order was rejectect my MBT and showed as a reqected order in the order book. I had exit on close set to true and at the end of the day my strategy tried to short the ETF. This order was rejected by MBT as well (a good thing since I did not want to short this ETF).
ErikHR is offline  
Reply With Quote
Old 03-10-2011, 04:13 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Hi Erik, would you mind sending the logs and traces for this one via Help > Mail to Support?

Thanks,
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-10-2011, 05:57 PM   #15
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Jon, I'm sorry I do not follow you - the issue is: the position update will be send before the actual execution update which is from NT's point of view an 'illogical' event sequence which leads then to tracking issues.
Bertrand,

// OK ::
// I FEEL that the following line is an invalid test of actual position with MBT because
// it is potentially not correct (as in has invalid position information) and returns 'false'
// even before the trade has been completed, as position info is received here before
// the trade completion
if (Position.MarketPosition == MarketPosition.Flat)

// SO (I think) since I have orders managed within OnExecution()
// then I should check that entry has not succeeded and cancell/null out entry
// before even checking for position?!
if (iOrderL1 != null)
return;
{
if (iOrderL1 == null)
{ CancelOrder(iOrderL1);}
{

if (Position.MarketPosition == MarketPosition.Flat)
{ if ( conditions are STILL good = true )
{ iOrderL1 = ( LongOrder (sEntryL1);
//&& steps asap }

}
}
}

To my mind, IF I only check for 'Flat' I might submit an new order for when an entry confirmation is already on its way and get an 'overfill' or some other position issue.

???????????
Jon
Last edited by Trader.Jon; 03-10-2011 at 06:24 PM.
Trader.Jon is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to multiple live accounts with MB Trading raintree Connecting 2 10-15-2010 01:21 PM
NT 7.0.0.19 strategy positions not updating, MB Trading live Camdo Version 7 Beta General Questions & Bug Reports 9 08-31-2010 04:32 PM
micro trading on NT with MB trading shan777 Connecting 9 06-01-2010 02:24 PM
live Trading with MB Trading nigeleyre Automated Trading 1 04-13-2010 07:05 AM
How to connect Live to MB Trading jtrader1 Connecting 3 07-07-2009 12:51 PM


All times are GMT -6. The time now is 12:02 AM.