![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: Apr 2012
Posts: 16
Thanks: 3
Thanked 3 times in 2 posts
|
First situation: According to the NT7 Manual, OnBarUpdate is called either on the close of the current bar or on every tick, depending on the setting of CalculateOnBarClose.
Reading that literally, if CalculateOnBarClose is true, I would expect that OnBarUpdate would only be called once every time a bar is completed. So, if on a 5 minute chart, once every 5 minutes exactly at the 5 minute mark. First observation: I see trades being entered at intra-bar times even with CalculateOnBarClose set to true. First question: What is the correct behaviour to expect for OnBarUpdate in relation to CalculateOnBarClose and ticks? Second situation: According to the NT7 Manual, once a trade is entered with a managed entry method (e.g. EnterShort), it must be re-entered every time OnBarUpdate is called or the position will be cancelled. That implies that the conditions that were tested to initiate the entry must remain true throughout the life of the position. Second observation: Trades persist even after the initial entry conditions have changed. Second question: What is the actual behaviour of the managed approach in this respect? Thanks for your kind advice. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,416
Thanks: 252
Thanked 978 times in 961 posts
|
jeronymite, welcome to our forums:
Correct is that the bar update with CalculateOnBarClose = true would only be called once your bar is completed, it would not update with intrabar ticks seen then - however you would need to keep in mind NT is event based and not time based, so if you see no trade for example then there would also be no bar update seen. In a fairly liquid market though it would be hitting your time stamp expectations 99% of the time normally. Trades can be entered intrabar, as the order is send for example on the bar close, but would be working for the bar then, so you could definitely see an intrabar fill here. Trades will persist unless you exit them or the ExitOnClose handling set per default would take over, the will not be closed automatically by NT, the part of the manual you read concerns entries with non market orders - those would be expiring on the bar they were placed on if not filled. So that meaning then: if you trade condition for entry is still true and your limit order expires, you would need to resubmit then on the next bar until filled.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Apr 2012
Posts: 16
Thanks: 3
Thanked 3 times in 2 posts
|
Thanks, Bertrand. That's very helpful.
Now, if I want to completely duplicate the behaviour of Backtest in the Live environment, I would really be saying that I want all actions (enter, exit, stop loss, profit target,etc) to be calculated and therefore actioned ONLY at bar close, since that is the only information that Backtest has, right? So, how would I implement that in the live environment? I can set CalculateOnBarClose to be true at the start of Initialize() but is that sufficient? Thanks! |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,416
Thanks: 252
Thanked 978 times in 961 posts
|
You're welcome - CalculateOnBarClose in backtesting will always be 'true'.
This will not change how orders are filled live - there's simply a difference in backtesting vs live trading, backtesting being a close approximation, but of course market dynamics are always realtime only and not known in advance. You can backtest in Market Replay to be able to see how your strategy fares with recorded realtime data and thus having access to the tick formation of the replayed bars for better simulated fills, stops... http://www.ninjatrader.com/support/h...ket_replay.htm That would be the recommending cycle to go through before trading live with a script.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Bertrand for this post: |
|
![]() |
| Tags |
| calculateonbarclose, intrabar, onbarupdate |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Order methods | ohjob | Automated Trading | 3 | 03-07-2011 08:07 AM |
| Help with Order methods. | ts_gordo | Strategy Development | 4 | 01-27-2010 02:54 PM |
| Please add a Z-Order to most of the Draw... Methods | David Lean | Suggestions And Feedback | 1 | 01-09-2010 10:21 AM |
| The Source Code behind Order Methods | brima | Strategy Development | 2 | 07-29-2008 04:47 PM |
| Using StopLimit Order Methods | tquinn | Strategy Development | 1 | 01-14-2007 03:18 AM |