Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Seasonal filter: Trading day of month

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

    Seasonal filter: Trading day of month

    I have novice question related to seasonal filters. Basically, I would like to filter for certain trading days in the month. For instance, say I only wanted to trade specific trading (business) days of the month.

    So instead of Time[0].Day == 15 referencing the 15th day of the month, I would like it to reference the 15th trading day of the month.

    Where do I begin? Does anyone have a ready function for this?

    #2
    Hello don_janeiro,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    You would need a reference for the "trading days" in the month. Potentially, you could use a filter that filters out specific days of the week and times of the day and then count the number of days since the beginning of the month.

    Below is an indicator that would count the trading days of the month based on the CME US Index Futures ETH trading hours.
    Code:
        public class TradingDayOfTheMonth : Indicator
        {
            #region Variables
            private DateTime 	CurrentDate;
    		private int			count = 0;
            #endregion
    
            protected override void Initialize()
            {
                Overlay				= true;
            }
    
            protected override void OnBarUpdate()
            {
                if (Time[0].Month > CurrentDate.Month || Time[0].Year > CurrentDate.Year)
    			{
    				CurrentDate = Time[0];
    				count = 0;
    			}
    			if (((Time[0].DayOfWeek != DayOfWeek.Saturday || Time[0].DayOfWeek != DayOfWeek.Sunday)
    				&& ToTime(Time[0]) >= ToTime(17,0,0)
    				&& ToTime(Time[0]) <= ToTime(16,15,0))
    				||
    				Time[0].DayOfWeek == DayOfWeek.Sunday
    				&& ToTime(Time[0]) >= ToTime(17,0,0))
    			{
    				count++;
    			}
    			
    			if (count == 15)
    			{
    				// do something
    			}
    				
            }
        }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X