Announcement

Collapse
No announcement yet.

Barstate_newbar

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

  • Barstate_newbar

    Just to clarify . . . for calculations inside a loop using this bar state, do they execute on the first tick of a new bar and that's all? And, what happens when the next new bar is formed?

    I'm thinking that all ticks in a bar other than the first one would be ignored. It's not clear to me in reading the KB materials.

    Thanks.

  • #2
    Re: Barstate_newbar

    Hi AssetHound,

    You are correct, this conditional is met on the first tick of a new bar. You must be careful because the last tick before a new bar is the end of that bar. You can have issues with historical data loading and the technical indicator looking different between live conditions and the historical data if you are not careful...



    Originally posted by AssetHound
    Just to clarify . . . for calculations inside a loop using this bar state, do they execute on the first tick of a new bar and that's all? And, what happens when the next new bar is formed?

    I'm thinking that all ticks in a bar other than the first one would be ignored. It's not clear to me in reading the KB materials.

    Thanks.

    Comment


    • #3
      Re: Re: Barstate_newbar

      Thanks, Steve. Always good to make sure things are operating as you think they are operating.


      Originally posted by stevehare2003
      Hi AssetHound,

      You are correct, this conditional is met on the first tick of a new bar. You must be careful because the last tick before a new bar is the end of that bar. You can have issues with historical data loading and the technical indicator looking different between live conditions and the historical data if you are not careful...

      Comment


      • #4
        Hi Steve,

        What would be the best way to prevent the issues with the historical data?

        You must be careful because the last tick before a new bar is the end of that bar. You can have issues with historical data loading and the technical indicator looking different between live conditions and the historical data if you are not careful...
        Thanks

        wayne

        Comment


        • #5
          Re: Re: Re: Barstate_newbar

          Hi AssetHound,

          You are most welcome.

          Originally posted by AssetHound
          Thanks, Steve. Always good to make sure things are operating as you think they are operating.

          Comment


          • #6
            Hi Wayne,

            I believe this is covered in the tutorials, I'm not sure about the specific link, but I'm sure you could find it if you would like to pursue the subject area further. Regardless, what I was trying to do was to quickly confirm AssetHound's understanding of the different getBarState() return flags and their relationship with price behavior intra-bar.


            When live, BARSTATE_NEWBAR condition is met the first tick of a bar (ONLY once per bar), and close(0) tracks tick price intra-bar and represents the tick price which can change value every tick intra-bar. close(0) is not finalized until the last tick in the bar, at which time it represents the close of the bar (one tick before a BARSTATE_NEWBAR condition). Historical data is fixed and when a BARSTATE_NEWBAR condition is met, close(0) represents the closing price which is the value that corresponded to the last tick of the live data of the bar.

            Hope this helps.

            Originally posted by waynecd
            Hi Steve,

            What would be the best way to prevent the issues with the historical data?



            Thanks

            wayne

            Comment


            • #7
              Thanks Steve,

              I appreciate the clarification.

              wayne

              Comment

              Working...
              X