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

two symbols have different bar times

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

    two symbols have different bar times

    I'm writing a strategy which uses two symbols. I need to look for a swing low in the first symbol and then record the lows for both symbols at that time.

    Both symbols are currently using a 15 second time interval. When I record the values, I get the correct value for the first symbol. However, I'm getting the low from the previous bar for the second symbol. I use the following to get the values.

    symbol 1: Lows[0][1]
    symbol 2: Lows[1][1]

    For symbol 2, I'm getting what I thought should be Lows[1][2] at that time instead of what I though should be Lows[1][1]. I verified the time difference in the bars using some print statements.

    This is all done inside a "if (BarsInProgress == 0)" if that matters.

    Is there a way to record the value from the same time bars?

    Thanks,

    Folls

    #2
    No there is not. The reason is, there is no way to ensure that the Low[1][0] is really closed when you get the event for Low[0][0].

    Bars are closed when a tick for the next time frame (lets say next minute) comes in.

    For example using 1 minute time frame. Current time is 9:00:01.

    BarA - A tick comes in which closes the 9:00 AM bar and now we are on the 9:01 bar and OnBarUpdate() is called.
    BarB - Last tick came in at 8:59:59

    So when OnBarUpdate() is called for BarA at 9:00:01, BarB has yet to close since it has not received a tick to confirm that the 9:00 bar is closed
    RayNinjaTrader Customer Service

    Comment


      #3
      I'm not sure I'm explaining this properly. The charts seem to print a bar every 15 seconds. Is there a way to get the same values that are being shown on the chart?

      I'd be happy to execute only when the bar prints every 15 seconds. Is there a way to do that?

      I'm trying to base my stretegy on what is printed on the screen. Any advice you can give me to accomplish that would be greatly appreciated.

      Thanks!

      Folls

      Comment


        #4
        Yes, you are explaining it correctly.

        The same concept I explained applies to a visual chart. The difference is, that the resolution programatically is at the event level where visually it may appear that both charts plot a bar at the same time, programatically that is not the case.

        Visually, chartA may complete a bar of the same interval before chartB. Most of the time you will not see this since it can happen in time intervals as small as a millisecond.
        RayNinjaTrader Customer Service

        Comment


          #5
          I understand now. Thanks. That will work out fine.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rtwave, 04-12-2024, 09:30 AM
          2 responses
          20 views
          0 likes
          Last Post rtwave
          by rtwave
           
          Started by tsantospinto, 04-12-2024, 07:04 PM
          5 responses
          67 views
          0 likes
          Last Post tsantospinto  
          Started by cre8able, Today, 03:20 PM
          0 responses
          6 views
          0 likes
          Last Post cre8able  
          Started by Fran888, 02-16-2024, 10:48 AM
          3 responses
          49 views
          0 likes
          Last Post Sam2515
          by Sam2515
           
          Started by martin70, 03-24-2023, 04:58 AM
          15 responses
          115 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X