Something like GetBar(BarsArray[1], Time) ???
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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
-
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
-
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 samish18, Yesterday, 12:20 PM
|
1 response
12 views
0 likes
|
Last Post Today, 12:54 PM | ||
Started by Lancer, 01-29-2020, 10:15 PM
|
6 responses
460 views
1 like
|
Last Post
by neveral0n3
Today, 12:53 PM
|
||
Started by Rogers101, Today, 11:30 AM
|
1 response
13 views
0 likes
|
Last Post Today, 12:50 PM | ||
Started by AndreiBig, Yesterday, 12:30 AM
|
1 response
11 views
0 likes
|
Last Post Today, 12:47 PM | ||
Started by nicthe, Today, 07:38 AM
|
2 responses
15 views
0 likes
|
Last Post Today, 12:46 PM |
Comment