Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading Days vs Calendar days

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

    Trading Days vs Calendar days

    I want to be able to build an average of the last 2 trading days on a chart but I need to know when the start of 2 trading days ago was, preferably when I am receiving the bars as opposed to processing the bars backwards after the chart is completed to get the data. I can do it right to left but am hoping to process it left to right, drawing previous line plots is no fun.

    At the start of an indicator what is the best way to determine 2 trading days back? I want to pre-process the bar data before the indicator starts receiving bar data.

    I tried Bars.GetDayBar(2) but if the chart has not already built that past data I get a null. Right now I am using calendar days back from current date time to know when to start but this method is not perfect.

    #2
    Hi ct, thanks for the post. There isn't really a decidated function available here for trading days access, it would be Calendar based using the typical DateTime functions and then weekends / holidays would need to be figured in (holiday management is something on our lists for the next major platform upgrade). For the calcs you would need to work in OnBarUpdate() then and wait until you had two days of data seen to be able to calculate a meaningful average price for the last 2 sessions.

    Comment


      #3
      Bertrand

      Many thanks for the reply. I didn't know if there was some slick way to do it I didn't know about. I can do it the hard way, done it before.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X