Something like GetBar(BarsArray[1], Time) ???
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetBar on multiseries
Collapse
X
-
GetBar on multiseries
While I'm working with primary 1min bars (BarsInProgress = 0) how can I get the number of the bar with GetBar()? but i need the number of the bar for secondary 1hour timeframe? I have the time of the bar as input. I can't wait for BarsInProgress = 1 to happen to do my calculations.
Something like GetBar(BarsArray[1], Time) ???Last edited by BankRobber; 01-18-2012, 06:27 PM.Tags: None
-
Another question not related to the previous one.Originally posted by NinjaTrader_Bertrand View PostUnfortunately GetBar() would not allow to pass in another series - you would need to custom code this.
Lows[1][0] gives me previous hour low, where [1] = 60 minutes time frame.
How can i get the current hour just forming 60min bar highs or lows.
All calculations are done on lower time frame after FirstTickOfBar of lower time frame.
Comment
-
It seems to me that Lows[1][0] gives me past hour on historic and current hour realtime.Originally posted by NinjaTrader_Bertrand View PostDo you ask for realtime trading or backtesting here BankRobber? If Realtime, do you run the script with CalculateOnBarClose = false?
Im running the script with CalculateOnBarClose = false, but calculations are done on FirstTickOfTheBar of the lowest timeframe
Comment
-
Hello.
This is my function to get bar index from any timeframe.
It works good for me.
(If to uncomment strings in the end of function, it will return exactly first bar after target_time.)
Code:int fGetBarMtf( int serie, DateTime target_time ) { int ix_future = 0; int ix_past = CurrentBars[serie]; int ix_current = (ix_past - ix_future)/2; while( ! (Times[serie][ix_current] <= target_time && target_time <= Times[serie][ix_current-1]) ) { // if target_time is earlier that new center if( target_time < Times[serie][ix_current] ) { ix_future = ix_current; ix_current = ix_past - (ix_past - ix_future)/2; } // if target_time is later that new center if( target_time > Times[serie][ix_current] ) { ix_past = ix_current; ix_current = ix_past - (ix_past - ix_future)/2; } } //if( target_time < Times[serie][ix_current+1] ) while( !( target_time > Times[serie][ix_current+1] ) && ix_current < CurrentBars[serie] ) ix_current++; //else while( !( target_time < Times[serie][ix_current] ) && ix_current > 0 ) ix_current--; return( ix_current ); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
627 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
359 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
562 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