• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsAgo by date from a different data series

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

    BarsAgo by date from a different data series

    I want to get the bars ago value at a specific date, however not from my current chart but from a different data series.
    For example, my strategy runs on a 10 range chart and I want to get the barsAgo value at 05-05-18 10:00:00 on a 200 range chart.

    Thanks

    #2
    Hello kiss987,

    Thank you for your note.

    Attached is an example which loops over a secondary series and prints to the output window how many bars ago a defined Datetime variable was, in this case I used 5-4-2018 10AM.

    The sample uses a 1 minute secondary series, however if you were to use a range series you would need consider that range bars may not close exactly at a time of say 10AM. What you might do is write an if statement which checks if the bar time was between X time and Y time, rather exactly a specified time. This custom if statement would go on line 68 of the sample.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.

      Although I did understand your solution, I still have a question.
      In the link below, a different approach is used to get the barAgo value (when using a single data series). Is there a way to somehow use the same approach with a multi data series?

      https://ninjatrader.com/support/help...us/?getbar.htm

      Comment


        #4
        Hello kiss987,

        To force the Bars.GetBar method to use the secondary bar series you could use the following if statement,

        if(BarsInProgress==1)
        {
        int barsAgo = CurrentBar - Bars.GetBar(new DateTime(2006, 12, 18, 9, 0, 0));
        }

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by vjnrggbx, Today, 06:35 AM
        0 responses
        2 views
        0 likes
        Last Post vjnrggbx  
        Started by U0000999, Today, 05:44 AM
        0 responses
        3 views
        0 likes
        Last Post U0000999  
        Started by lakman184, Today, 05:41 AM
        0 responses
        5 views
        0 likes
        Last Post lakman184  
        Started by lilupwab, Today, 04:50 AM
        0 responses
        4 views
        0 likes
        Last Post lilupwab  
        Started by MarkFrench1991, Today, 03:47 AM
        0 responses
        9 views
        0 likes
        Last Post MarkFrench1991  
        Working...
        X