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 llanqui, Today, 03:53 AM
        0 responses
        4 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        14 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        14 views
        0 likes
        Last Post strategist007  
        Working...
        X