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 DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        12 views
        0 likes
        Last Post DanielSanMartin  
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        12 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        11 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        8 views
        0 likes
        Last Post nandhumca  
        Started by The_Sec, Today, 03:37 PM
        0 responses
        4 views
        0 likes
        Last Post The_Sec
        by The_Sec
         
        Working...
        X