View Full Version : Next Bar Open
bradypreston
07-10-2007, 09:27 AM
How do obtain the next bars open? I am unable to use the opening of the market in my calculation because the program calculates the signals on the close.
NinjaTrader_Ray
07-10-2007, 09:38 AM
You can't get next bar's open since NinjaTrader does not allow you to "peek" into future data as it's not yet know.
If I misunderstand, please clarify.
bradypreston
07-10-2007, 09:50 AM
You should lnow the open at the open. Why does it calculate it at the close. Why not the open? How would you then code this (next bar open + range ) or ( if next bar open < close)
NinjaTrader_Ray
07-10-2007, 09:56 AM
Of course you know the open at the open. If that's what you want, see the CaclulateOnBarClose property so that you can run tick by tick.
During a backtest, you know the OHLC of the final bar which is the close of the bar.
We have no concept of "next bar open" since you can only evaluate your program logic at the point of evaluation which is at the close of a bar or on every tick. With NinjaTrader, you don't get access to future data.
Therefore, if next bar open < close is not valid since you are comparing a future's bar open price to the current bar open price.
Here is some documentation - http://www.ninjatrader-support.com/HelpGuideV6/CalculateOnBarClose1.html
bradypreston
07-10-2007, 10:04 AM
Then ninja trader can't code this - buy at the opeing + 7
NinjaTrader_Ray
07-10-2007, 10:14 AM
If you run tick by tick, then yes, you would submit the order on the very first tick of the opening bar.
NinjaTrader_Ray
07-10-2007, 10:19 AM
I forgot to add, in backtest, you are correct, NinjaTrader can not place an order using the next bar's open price.
bradypreston
07-10-2007, 11:12 AM
how hard would it be to add this function?
NinjaTrader_Ray
07-10-2007, 12:20 PM
Hi Brady,
Will add this request to our list for future consideration. You could use the current Close price as a subsitute for next open. In intraday, both values are more often than not, one tick within each other.
bradypreston
07-10-2007, 12:23 PM
Not when using the pit open. When do you think this feature will be add and do you have anymore work arounds
pcijoin
01-14-2011, 06:03 AM
Hi Ray/Brady, Have you find the way to make it work?
I also need to have next bar open in backtest.
It seems that when running backtest, if I do enterlong(), the market price of it will be assumed to be the next bar open price. My strategy will need to limited price to the next bar open price such that it will have more guarantee performance in real time.
I hope NT7 already has this implemented or in any way of coding I can make it to work. (I am a programmer).
NinjaTrader_Bertrand
01-14-2011, 06:37 AM
pcijoin, there are unfortunately no changes here, we still do not allow peeking into the future - which exact order / signal are you trying to implement? In Market Replay you could work with CalculateOnBarClose = false and just submit a tick after the open then.
pcijoin
01-14-2011, 09:07 AM
Hi Bertland, thanks for your reply!
Here is the detail problem I am having with NT Backtesting:
First of all, the NT backtesting of my strategy showed good performance.
During NT backtest as the attachment image shown, I assume NT run the stategy as:
When the bar closed, the next open price will be assumed to be the market price of enterlong() or entershort().
But during the real time, if the same strategy do enterlong() or short(), the price it filled may not be the next bar open price as the NT backtesting shows. Therefore, in order to make backtesting to be more similar to the real time running of this strategy that is already working good in backtesting, I am thinking to limit the price to the next bar open price. If it can't get the price of the next bar open, it should not enter the position.
I hope I explain well here, if not, please let me know.
Again, is there anyway I can implement this? Is my concept of NT backtesting is correct or not? Please guide and help! Thank you!
P.S. See attachment picture for detail
pcijoin, there are unfortunately no changes here, we still do not allow peeking into the future - which exact order / signal are you trying to implement? In Market Replay you could work with CalculateOnBarClose = false and just submit a tick after the open then.
NinjaTrader_Bertrand
01-14-2011, 09:21 AM
Thanks for the detailed clarification - while you would unfortunately not have access to the future open price, you could add bid / ask series to your strategy and submit against those (NT7 only), which will give you a more realistic picture of your market order fills.
http://www.ninjatrader.com/support/helpGuides/nt7/multi_time_frame__instruments.htm
pcijoin
01-14-2011, 09:38 AM
Will this feature of NT backtesting be implemented? Is it in the list of development already? Many thanks!
NinjaTrader_Bertrand
01-14-2011, 09:59 AM
This is available right now in NT7, you would Add() Bid and Ask marketdata series to your script and then submit your orders against those barsobjects.
You can download NT7 from here - http://www.ninjatrader.com/download-registration.php
pcijoin
01-14-2011, 10:06 AM
Sorry what I meant is if the Next Bar Open in Backtesting will be available in NT or not. If not, I probably may need to switch to other platform that support it. Thanks!
NinjaTrader_Bertrand
01-14-2011, 10:12 AM
Your feedback has been noted on our list for future consideration, but unfortunately I could not give your an ETA or commitment for implementation - I would simply submit a stoplimit / limit order + / - a tick to limit the downside of high slippage fill.