Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
CurrentBar and Multi Time Frame
Collapse
X
-
I have a similar problem
I hope you're looking at old threads.Originally posted by NinjaTrader_Josh View PostYes. Just do it under the bars context you want.
Code:if (BarsInProgress == 1) Print(CurrentBar);
Above doesn't solve my problem. I'm implementing a multi - frame strategy with the same instrument, where Closes[0] are time based, Closes[1] are range.
I have a code snippet in OnBarUpdate:
double d = (Close[0] - Closes[1][0]) / TickSize ;
// Print(TickSize) ;
if (d >= 0)
StrategyPlot(0).Value.Set(d);
else
StrategyPlot(1).Value.Set(d);
I don't see any data on plots. I assume that at the first bars of of series 0 , there is no Closes[1][0] available yet, an exception is thrown and the strategy stops to work.
I may try to use a brute force, at the first lines of OnBarUpdate like :
if ((BarsInProgress == 0) && (CurrentBar <100))
return ;
Assuming that after first 100 time based bars I have a range bar availble, but I really don't like it.
Please advice.
Comment
-
If no bars exist yet you will not be able to access it. I suggest you first start off and just print from within the two BarsInProgress to see what kind of data you have when. Then after you get a feel for the bars then you should be able to access them after they exist.
Also note that StrategyPlot has limited functionality and NT7 will bring about multi-instrument/time frame indicators which will be able to handle plotting.Josh P.NinjaTrader Customer Service
Comment
-
Thank a lot for a rocket-fast answer !!! You guessed properly I'm using a multiframe strategy instead of non-existent multiframe indicator.Originally posted by NinjaTrader_Josh View PostIf no bars exist yet you will not be able to access it. I suggest you first start off and just print from within the two BarsInProgress to see what kind of data you have when. Then after you get a feel for the bars then you should be able to access them after they exist.
Also note that StrategyPlot has limited functionality and NT7 will bring about multi-instrument/time frame indicators which will be able to handle plotting.
I don't want to wait for NT7, I'm trying to implement a solution now.
The following doesn't work either, and I think it should :
bar1Ready = false ;
is set in Initialize()
and
.......................
protected override void OnBarUpdate()
{
string sDbg ;
Print("BP , cBar : " + BarsInProgress.ToString() + CurrentBar.ToString()) ;
if (!bar1Ready)
{
return ;
}
if (BarsInProgress == 1)
{
// Print(CurrentBar);
if (CurrentBar > 1)
{
if (!bar1Ready)
bar1Ready = true ;
}
}
double d = (Close[0] - Closes[1][0]) ;
// Print(TickSize) ;
if (d >= 0)
StrategyPlot(0).Value.Set(d);
else
StrategyPlot(1).Value.Set(d);
}
Surprisingly, nothing isn't printed in output window, it means OnBarUpdate fails at the beginning.
Should I implement my own exception mechanism as long as Closes[1][0] is not ready ?
Comment
-
I didn't look at a log.
I was an idiot enough to forget about it.Originally posted by NinjaTrader_Josh View PostWhat errors are you receiving? Try using a try-catch block to figure out where you run into issues.
http://www.ninjatrader-support2.com/...ead.php?t=9825
The log says:
31/07/2009 21:33:06,Strategy,The strategy 'SampleMultiInstrument' has called the Add() method with an invalid instrument. Either 'ES 12-08' does not exist in the Instrument Manager or the specified exchange has not been configured.,
31/07/2009 21:32:03,Strategy,The strategy 'SampleMultiInstrument' has called the Add() method with an invalid instrument. Either 'ES 12-08' does not exist in the Instrument Manager or the specified exchange has not been configured.,
Of course, because I'm using a strategy as a substitute to a multiframe indicator, i have no choice, but to use a simulated feed.
So another, may be less stupid question is how to configure a simulated feed to provide a data for my real instrument , $EURUSD instead of ES 12-08. I'm sure it appears somewhere in the help, but I cannot find it.
Above is needed for debugging only. During a real trading, I'm getting a data from MB Trading.
Thanks.
Comment
-
SampleMultiInstrument error is a different error that can be safely ignored. The Simulated Data Feed provides a feed for any instrument setup for it in the Instrument Manager. What you need to do is setup a starting sim price for your instruments and then reconnect to the sim feed to get it flowing.Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
630 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
566 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment