Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddDataSeries secondary series same as primary, duplicate bar events

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

    AddDataSeries secondary series same as primary, duplicate bar events

    When I add a 1 tick secondary series to a strategy that's running on a 1 tick primary series I'm getting twice as many OnBarUpdate calls as I should be when I am filtering for BarsInProgress == 1. You can test this with the attached strategy. If I set the primary series to 1 tick and print the Lows[1][0] of the secondary 1 tick series I get what you see in column A of the attached image. If I set the primary series to something else like 1 minute and print the Lows[1][0] of the secondary 1 tick series I get what you see in column B of the attached image. Note that for every timestamped event in column B there are 2 matching events in column A. This shouldn't be the case since the printing is only being done when BarsInProgress == 1.

    The reason I'm adding the duplicate series is because I'm trying to make a multi-time frame strategy/indicator foolproof for users who have no idea they're running it on a duplicate primary series. Is there a way to check if the primary series is 1 tick during State.Configure? If so I could choose to not load the 1 tick secondary.

    Thanks in advance.
    Attached Files
    Last edited by algotrading; 03-11-2019, 12:00 PM.

    #2
    Hello algotrading,
    Thanks for your post.

    I am not understanding how you could have compared historical times with your sample. Are you using replay? Where are your time stamps prints?

    What happens when you set the script to Calculate.OnBarClose?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      Hello algotrading,
      Thanks for your post.

      I am not understanding how you could have compared historical times with your sample. Are you using replay? Where are your time stamps prints?

      What happens when you set the script to Calculate.OnBarClose?
      I'm running this on replay. If you look at the print statement you'll see how I'm printing the timestamps:

      Print("BarsInProgress1 " + Lows[1][0] + " / " + ToTime(Time[0]) + "." + Time[0].Millisecond.ToString());

      You can see the prints with timestamps I copied form the oputput window into the spreadsheet image in the OP.

      That being said, changing to Calculate.OnBarClose fixed the duplicate problem. I can live with that but this still appears to be a bug. Calculate.OnEachTick shouldn't be calling OnBarUpdate twice for every tick. If a user changes the calculate mode manually they could get undesired results. Not a big deal since I can work around it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      64 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      139 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X