PDA

View Full Version : how to detect (eliminate) holidays?


Lost Trader
01-27-2008, 11:37 AM
So I can use the example in "Strategy: Using a time filter to limit trading hours" to permanently exclude weekends (Sat/Sun).

But how do I exclude other non-trading days during an historical analysis?
Specifically holidays & half-days....

My other charting packages either automatically exclude holidays, or provide a software level option to exclude them (and clearly idenitfy what days are considered holidays to the user).

Real-time, I can use my head -- but in a strategy running on historical data, the code has to know which Mon-Fri days are not truly full market days. How?

NinjaTrader_Dierk
01-27-2008, 01:07 PM
You would need to cover this by custom coding, since NT does not provide a calender logic at this time.

Lost Trader
02-27-2008, 08:10 PM
So even though I've read that NT does not acknowledge holidays -- it appears that they ARE eliminated by NT code already when running a strategy backtest.

I ran this and the holidays were not listed...
protected override void OnBarUpdate()
{ if (Bars.SessionBreak) Print(ToDay(Time[0]) ); }

From previous replies, several of us had the impression that there was no holiday handling in NT. Is it just that you do not want to tell us which days are coded as holidays?
:)

NinjaTrader_Ray
02-27-2008, 08:38 PM
There is no holiday handling in NT. If OnBarUpdate() was not called on a Holiday it was because your historical data set did not have any data on that specific day.

forrestang
06-08-2011, 09:19 PM
Since there is no simple way around this, I would just like to put a "!=holidaydate."

By that I mean, I would like to insert a simple list of dates per each year I want to back test, and I will grab the list from CME's website. After all, it's only a handful of days I want to put in. Then put a != statement for each of these dates in a loop around my code.

What is the syntax for saying, "If not equal to a given date?"

forrestang
06-08-2011, 10:02 PM
Since there is no simple way around this, I would just like to put a "!=holidaydate."

By that I mean, I would like to insert a simple list of dates per each year I want to back test, and I will grab the list from CME's website. After all, it's only a handful of days I want to put in. Then put a != statement for each of these dates in a loop around my code.

What is the syntax for saying, "If not equal to a given date?"

Gonna try this:
if (ToDay(Time[0]) == 20100101 || ToDay(Time[0]) == 20100118 || ToDay(Time[0]) == 20100215 || ToDay(Time[0]) == 20100402
|| ToDay(Time[0]) == 20100531 || ToDay(Time[0]) == 20100705 || ToDay(Time[0]) == 20100906 || ToDay(Time[0]) == 20101025
|| ToDay(Time[0]) == 20101026 || ToDay(Time[0]) == 20101029)
return;

NinjaTrader_Bertrand
06-09-2011, 03:08 AM
That should do it forrestang, more dedicated holiday handling is on our suggested enhancements list already for consideration.