Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetBar on multiseries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    Unfortunately GetBar() would not allow to pass in another series - you would need to custom code this.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Unfortunately GetBar() would not allow to pass in another series - you would need to custom code this.
      Another question not related to the previous one.

      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


        #4
        Do you ask for realtime trading or backtesting here BankRobber? If Realtime, do you run the script with CalculateOnBarClose = false?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Do you ask for realtime trading or backtesting here BankRobber? If Realtime, do you run the script with CalculateOnBarClose = false?
          It seems to me that Lows[1][0] gives me past hour on historic and current hour realtime.
          Im running the script with CalculateOnBarClose = false, but calculations are done on FirstTickOfTheBar of the lowest timeframe

          Comment


            #6
            Hi BankRobber,

            Yes this is expected. Multiseries bars are referenced differently in historical compared to real time bars, COBC = false. This is detailed in the following link (Section How Bar Data is Referenced)
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              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 );
              		}
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              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 Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              359 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              562 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              568 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X