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

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.
    BertrandNinjaTrader Customer Service

    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 timko, Today, 06:45 AM
      0 responses
      0 views
      0 likes
      Last Post timko
      by timko
       
      Started by JonesJoker, 04-22-2024, 12:23 PM
      7 responses
      41 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Waxavi, 04-19-2024, 02:10 AM
      2 responses
      37 views
      0 likes
      Last Post poeds
      by poeds
       
      Started by chbruno, Yesterday, 04:10 PM
      1 response
      44 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Max238, Today, 01:28 AM
      1 response
      24 views
      0 likes
      Last Post CactusMan  
      Working...
      X