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

Get last Bar object

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

    Get last Bar object

    I need to get latest bar object of some specified index in multi-timeframe strategy.
    Lets say I have 3 time-frames:
    //main time-frame, the one to which strategy is attached.
    Add(PeriodType.Minute, 3); //added in onIntialize
    Add(PeriodType.Minute, 1); //added in onIntialize

    How do I get latest Bar object for 3rd time-frame?
    I can obtain Closes[2][0],Highs[2][0], Lows[2][0], Opens[0],Times[2][0], Volumes[2][0], which is basically information stored in the object. But I need Bar object- it's just a matter of usage convenience. I could easily live without it, but since you do have Bar class in framework, I thought it might be possible. I just don't seem to be able to find how could I do that.
    I would assume that it should be accessible through Bars object and you do have
    GetDayBar function in this class. But its name suggests something different.
    So would BarsArray[2].GetDayBar[0] get me latest bar for 1 minute time-frame?

    #2
    Originally posted by Andreano View Post
    I need to get latest bar object of some specified index in multi-timeframe strategy.
    Lets say I have 3 time-frames:
    //main time-frame, the one to which strategy is attached.
    Add(PeriodType.Minute, 3); //added in onIntialize
    Add(PeriodType.Minute, 1); //added in onIntialize

    How do I get latest Bar object for 3rd time-frame?
    CurrentBars[2]

    Comment


      #3
      CurrentBars[2] would return me int, which is not a Bar object. I need to get hold of latest Bar object on 3rd time-frame, instance of class that implements IBar interface, like the one reutrned by Bars.GetDayBar(). I don't need it's index in sequence of bars.

      Comment


        #4
        BarsArray[2].Get(0) would get me latest Bar object
        Question is closed. Shame on me. Bring my apology for my blindness.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X