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

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 cls71, Today, 04:45 AM
      0 responses
      1 view
      0 likes
      Last Post cls71
      by cls71
       
      Started by mjairg, 07-20-2023, 11:57 PM
      3 responses
      213 views
      1 like
      Last Post PaulMohn  
      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      544 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      3 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      12 views
      0 likes
      Last Post XXtrader  
      Working...
      X