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

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 Petrv333, Today, 02:03 PM
        1 response
        9 views
        0 likes
        Last Post NInjaTrader_MaxH  
        Started by stafe, Today, 12:34 PM
        2 responses
        23 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by asmmbillah, Today, 11:18 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by nickse2003, Today, 09:56 AM
        1 response
        30 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by ATMtrader0001, Today, 10:08 AM
        5 responses
        40 views
        0 likes
        Last Post ATMtrader0001  
        Working...
        X