Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Numbers

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

    Bar Numbers

    While coding in Strategy Builder if you are using the close of a bar then Bar 1 will be the latest closed bar and Bar 2 before it and so on, correct? In back testing is a trade taken a bar later? Like say when a new bar opens and the conditions are met I see the trade taken on the following bar.
    Thank you.

    #2
    Hello Trader17,

    Thanks for your post.

    To clarify how the strategy performs under different conditions:

    If your strategy is set to Calculate.OnBarClose (which is the default behavior unless you select otherwise) then the strategy code is executed at the end of the just closed bar which is identified by [0]. The previous bar is [1] and the bar before that is [2] and the bar that is forming is unknown to the strategy. The strategy would perform the same on live data or historical data.

    If your strategy is set to Calculate.OnPriceChange or Calculate.OnEachTick, then the strategy code is executed on each change in price or on each incoming tick and this changes the references so [0] is now pointing to the currently forming bar, [1] is pointing to the just closed bar, [2] the bar before that, etc. This is how the strategy would perform on live or market replay data. In terms of Historical data, even though the strategy would be set to Calculate.OnPriceChange or Calculate.OnEachTick, it will perform the same as Calculate.OnBarClose.

    When a strategy is operating under Calculate.OnBarClose, the code is executed at the end of the bar and if the code places an order, the order would be filled on the next bar. You may want to use a Draw.Dot() in your code section where you place an order as this would show the bar where the code placed the order and then on the next bar you would see the order filled.

    Comment


      #3
      Now it makes sense. I thought the bar that just closes is one and the one before it 2 and so on. That is why I was seeing the skip of a bar before execution.
      Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      66 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      141 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      76 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      47 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X