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 futtrader, 04-21-2024, 01:50 AM
        4 responses
        41 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        8 views
        0 likes
        Last Post port119
        by port119
         
        Started by Philippe56140, Today, 02:35 PM
        0 responses
        7 views
        0 likes
        Last Post Philippe56140  
        Started by 00nevest, Today, 02:27 PM
        0 responses
        7 views
        0 likes
        Last Post 00nevest  
        Working...
        X