Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Start processing from X bars ago

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

    Start processing from X bars ago

    If I use the following the code below it only runs for real time data
    if (Historical)
    return;

    What if I want to start the processing starting X bars before the latest bar. How can I do that?
    Can't find the answer in the ver7 help guide.

    Peter
    Last edited by PeterBear; 04-15-2011, 08:56 AM.

    #2
    Hello Peter,

    Thank you for your post.

    Count will contain the current total number of bars on a chart. If you compare CurrentBar to Count you could start processing only so many bars from current. For example, if you only want to process the 20 most recent bars of a chart, you could use:

    if (CurrentBar > (Count - 20))

    Please let me know if I can assist with anything further.
    DexterNinjaTrader Customer Service

    Comment


      #3
      Thank you. Got it going now..

      OnBarUpdate()
      {
      if (Historical)
      return;
      run blah blah - real time here
      }

      OnBarUpdate()
      {
      if (CurrentBar < (Count - 20)) //note <
      return;
      run blah blah - starting at 20 bars from the latest bar
      }
      Last edited by PeterBear; 04-15-2011, 08:11 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      67 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      60 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X