The code seems not logical to me and sometimes it does not work.
In this forum i saw one of Mikes great videos, in which he mentions:
"NinjaTrader is not capable of submitting intrabar orders in backtesting. Live strategies can submit intrabar orders using calculate bar close = false. Trying to simulate IOG within a backtestable strategy in NinjaTrader requires writing custom code to use MTF and try to work-around the problem, and it adds a great deal of complexity, plus MTF doesn't even work in current beta's of NinjaTrader."
Can this simple condition be programmed in Ninjatrader (for Backtesting)?
Would love some expertise from this forum
protected override void Initialize()
CalculateOnBarClose = true;
// this adds the tick secondary data series
protected override void OnBarUpdate()
// this makes sure that the script is processed with tick data
if (BarsInProgress != 1)
"I've been getting assistance from our development, however, this is not a very common question. Intra-bar granularity is mostly used for getting proper exits in backtest. Finding a crossover using intra-bar granularity is not a question I've had to answer before."
The final code is
if (Closes < Bollinger(Closes, 2,14).Upper &&
Closes >= Bollinger(Closes, 2,14).Upper)
This will refer to the Upperbowlinger of the recently closed primary bar. But will not refer to the actual BB value (between two primary bars).
I am wondering if i am asking a strange question, also because of no reply in this forum, i must be the only one having this problem? I run into this problem with every indicator used as an entry- or exitsignal during backtesting.
answer from Multicharts:
primary data is weekly
secondary data is daily
"I have consulted once again with our developers regarding your inquiry.
The code is not able to (daily) refer to bb values between 2 (weekly) bars if the indicator is based on the weekly series.
When the indicator is based on the weekly series there are only two values and a connecting line between them for two weekly bars.
There are no values in-between.
If you want to have values on each daily bar then you need to base the study calculation on a daily series (Format->Study->Format->Properties->Base study on)."
Still would love to know how futures.io (formerly BMT) members deal with this.. or not??
So i can backtest and optimize correctly what seems only possible to do in real time( for now).
This code will only work if the bar CLOSES above the upper Bollinger band, not if it moves through it within a bar and closes back below it. To backtest that situation, you will need to use EnterLongStopLimit() for order entries. Sorry, I don't have time to write, debug and support a code sample for you at this time but that is something you or your contact at Ninjatrader can look at.