• 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 simjs, Yesterday, 08:11 PM
        0 responses
        3 views
        0 likes
        Last Post simjs
        by simjs
         
        Started by mrlucky1x, Yesterday, 06:01 PM
        0 responses
        3 views
        0 likes
        Last Post mrlucky1x  
        Started by dedouglas, Yesterday, 03:17 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Jugado, Yesterday, 02:22 PM
        2 responses
        30 views
        0 likes
        Last Post Jugado
        by Jugado
         
        Started by login_dejavu, 04-21-2019, 04:58 AM
        2 responses
        24 views
        0 likes
        Last Post login_dejavu  
        Working...
        X