Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CurrentBar[1]?

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

    CurrentBar[1]?

    Howdy--

    This is probably a softball question (at least I hope it is), but when you call "CurrentBar", the current bars int value is returned (i.e., first bar on chart is 0 and next is 1 and next is 2 etc).

    If I wanted to call the previous bar number, is "CurrentBar[1]" the correct way to do that?

    For instance, I am trying to record the previous bar into a list. Therefore, would my code be something like this:

    listSignalBar.Add(CurrentBar[1]);

    or something like this:

    listSignalBar.Add(CurrentBar - 1);


    Thanks,

    Aventeren
    Last edited by aventeren; 11-27-2013, 12:26 PM.

    #2
    Hello Aventeren,

    If you want to get the previous bars values you would use something like "Close[1]", "Open[1]", etc... depending on what price data you are looking for. Here is a few other examples of this that you may view.



    For the bar number itself you may just subtract 1 from the CurrentBar to get this.

    Let me know if you have any questions.
    JCNinjaTrader Customer Service

    Comment


      #3
      Cool, so in my context, I would use:

      listSignalBar.Add(CurrentBar - 1);

      Correct?

      Comment


        #4
        Hello Aventeren,

        Yes, that is correct.
        JCNinjaTrader Customer Service

        Comment


          #5
          Thanks for the quick response, JC.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, Yesterday, 09:41 PM
          1 response
          27 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, Today, 02:41 AM
          0 responses
          10 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, Yesterday, 11:44 PM
          0 responses
          21 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          37 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          34 views
          0 likes
          Last Post CarlTrading  
          Working...
          X