Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I want to do something very easy but cannot figure it out
I want while BACKTESTING as soon as the price >= upperBowlingerBand go long
I have e-mailed back and forth a lot with Ninjatrader
they came up with the following code
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
many tx
Yeshe
protected override void Initialize()
{
CalculateOnBarClose = true;
// this adds the tick secondary data series
Add(PeriodType.Tick, 1);
protected override void OnBarUpdate()
{
// this makes sure that the script is processed with tick data
if (BarsInProgress != 1)
return;
"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[0][0] < Bollinger(Closes[0], 2,14).Upper[0] &&
Closes[1][0] >= Bollinger(Closes[0], 2,14).Upper[0])
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.