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!
See more
See less

Partner 728x90

Collapse

GetBar() missing an overload

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

    GetBar() missing an overload

    Hi guys,
    I note that in strategies, GetBar() has an overload to select the BarsSeriesIndex.
    Unfortunately in indicators, despite them now being multi timeframe, we don't have that overload.
    It would be nice to have.

    Cheers,
    saltminer

    #2
    Hello,

    Thanks for the forum post.

    Here is what we have documented for GetBar().



    It seems that we have an extra overload in strategies. This extra overload would be unsupported and I will have development check into this.

    Thanks again.

    Comment


      #3
      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 pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,283 views
      0 likes
      Last Post Leafcutter  
      Working...
      X