NewsDays

246

More exclusive indicators from nilstrades_

Subscribe to Sir Pickle Indicators for $49.00/month to get exclusive indicators by this author. You pay right on TradingView and can use them on your charts straight away.

Explore Sir Pickle Indicators
NewsDays is a small open-source library with a fixed calendar of news days from 2007 to 2026 for nine jurisdictions: Australia, Canada, Switzerland, the euro area, Japan, New Zealand, Singapore, the United Kingdom and the United States. For every New York calendar date and jurisdiction it holds one code: a bank holiday or scheduled early close, a "big 3" day (the consumer price index, the employment report or the central bank's rate decision) with the New York time of the day's last such release, a day with other high-impact news, or a day without any. It needs no external data or requests: the days are built into the library.

It is published as a library so that any script can use the same days, and so that the days can be checked.
__________________

What it contains

  • Bank holidays and scheduled early closes: per jurisdiction, the days its markets are closed or close early (for the United States, for example, Thanksgiving, Christmas and the day after Thanksgiving). Two kinds reach other markets than the rest: Columbus Day and Veterans Day, when US banks close but the exchanges trade, are holidays only for forex pairs and currency futures with the US dollar, and the day after US Thanksgiving is also a holiday for every stock index, of any country.
  • Big 3 days: the days of a jurisdiction's consumer price index, its employment report and its central bank's scheduled rate decision, each with the New York time of the day's last such release. For the euro area the consumer price index is the euro-area flash estimate. Minutes of a central bank meeting and unscheduled decisions are not big 3 days.
  • High-impact news days: days with at least one other scheduled release of that jurisdiction that economic calendars commonly rate as high impact ("red folder" news). Big 3 days count as such days too.
  • Everything else: days without high-impact news.


Only one code per day and jurisdiction is stored: no event names, no list of releases, no forecasts or results.

How it works

  • Each jurisdiction's year is one text: the year's big 3 release times, then one character per weekday (Saturday and Sunday are never a candle's day, see below). The character says which of the cases above the day is, and on big 3 days it also selects the release time. A second text lists only the weekdays whose code is different by trading day (for daily and higher charts), and two short lists hold the holidays of forex pairs and of stock indices.
  • On intraday charts each release counts on its New York date: a release in the Tokyo morning falls on the New York evening before, and a release on a Saturday or Sunday in New York counts on Monday. On daily and higher charts each release counts for the trading day that contains it: the trading day ends at 17:00 New York time, so a release in the Tokyo morning counts for the next day's daily candle.
  • A market's jurisdictions come from its currencies: its quote currency, and its base currency when that is a currency (so both currencies of a forex pair or a currency future; prices in US cents or pence count as their currency), plus Japan for the Nikkei future quoted in US dollars. A market whose currencies are none of the nine follows the United States.
  • For a candle, the library takes its New York date (Saturday and Sunday count as the next Monday, so a session that opens on Sunday evening counts as Monday; on daily and higher charts the trading day you pass), and combines the codes of the market's jurisdictions: a holiday in any of them, high-impact news in any of them, and the latest big 3 release among them. The big 3 days of the United States count for every market. The symbol's type tells forex pairs (and currency futures, which carry both currencies) and stock indices (index symbols, CFDs without a base currency quoted in another currency than the US dollar, and the main index futures by their root) for their own holidays.
  • On a big 3 day, a candle that opens before 15 minutes after the day's last big 3 release counts as "before the release"; from then on, the day counts as "after the release".


Functions

jurisdictions(base, quote, root)
The jurisdictions whose news and holidays apply to a market: those of its quote currency and of its base currency when that is a currency (a forex pair both, a CFD its quote currency; US cents and pence count as their currency), plus Japan for the Nikkei future quoted in US dollars and the currency of a currency future; the United States when none of the nine applies.
Parameters:
base (string): The base currency, usually syminfo.basecurrency.
quote (string): The quote currency, usually syminfo.currency.
root (string): The symbol's root, usually syminfo.root (a future's root, else the ticker).
Returns: Their codes separated by spaces, for example "EU US".

dayCode(t, tday, base, quote, root, symType)
The news of a candle's day for a market: its own jurisdictions' holidays, high-impact news and big 3 days, and the big 3 days of the United States for every market. The day: on intraday charts the New York date of the candle's open, Saturday and Sunday counting as the next Monday (so a Sunday-evening session counts as Monday); on daily and higher charts its trading day, which holds the news released from 17:00 New York the evening before. Columbus Day and Veterans Day are US holidays only for forex pairs and currency futures; the day after US Thanksgiving is a holiday for every stock index too.
Parameters:
t (int): The candle's open time (UNIX time in milliseconds), usually time.
tday (int): The trading day on daily and higher charts (time_tradingday), na on intraday charts.
base (string): The base currency, usually syminfo.basecurrency.
quote (string): The quote currency, usually syminfo.currency.
root (string): The symbol's root, usually syminfo.root.
symType (string): The symbol's type, usually syminfo.type (forex pairs, currency futures and stock indices have their own holidays).
Returns: The sum of: 1 high-impact news of the market's jurisdictions that day (their big 3 days count), 2 a big 3 day (of the market's jurisdictions or the United States), 4 a bank holiday or scheduled early close, 8 high-impact news on a day of its Monday-to-Friday week, 16 a big 3 day and the candle opens before 15 minutes after the day's last big 3 release. na outside 2007 to 2026.

blocked(t, tday, base, quote, root, symType, big3, big3Day, holidays, red, redWeek)
Why a candle's setups are blocked by the chosen news rules.
Parameters:
t (int): The candle's open time (UNIX time in milliseconds), usually time.
tday (int): The trading day on daily and higher charts (time_tradingday), na on intraday charts.
base (string): The base currency, usually syminfo.basecurrency.
quote (string): The quote currency, usually syminfo.currency.
root (string): The symbol's root, usually syminfo.root.
symType (string): The symbol's type, usually syminfo.type.
big3 (bool): Block big 3 days (those of the market's jurisdictions and of the United States): until 15 minutes after the day's last big 3 release, or with big3Day for the entire day.
big3Day (bool): With big3: block the entire day.
holidays (bool): Block the bank holidays and scheduled early closes of the market's jurisdictions (Columbus Day and Veterans Day only for forex pairs and currency futures; the day after US Thanksgiving for every stock index too).
red (bool): Require high-impact news of the market's jurisdictions: on the candle's day (their big 3 days count), or with redWeek in its Monday-to-Friday week.
redWeek (bool): With red: any day of the week will do.
Returns: The reason ("bank holiday", "big 3 news", "no red folder news"), or "" when the candle isn't blocked or its date is outside 2007 to 2026.

How to use it

  1. Import the library in your script, after the indicator() or strategy() line.
  2. Call blocked() once per candle with your settings, or read dayCode() for your own rules.
  3. Skip your signals while the result says the candle is blocked.


Pine Script®


The library's own chart shows the same: a gray background on the candles these settings block, and the chart's jurisdictions in the corner (with "forex pair" or "stock index" when the symbol is one).

Notes and limitations

  • Covers 2007 to 2026. Outside these years dayCode() returns na and blocked() blocks nothing. The calendar is extended once a year with a new version of the library; a script keeps the days of the version it imports until it imports the new one.
  • Scheduled releases only. Unscheduled events (for example an emergency rate decision) are not included, and a release that is moved after a version was built keeps its old date in that version.
  • Some release times are the usual time of that release rather than a recorded one. Other high-impact days carry no time: the whole day counts.
  • Singapore has no high-impact news apart from its big 3 days. Other currencies (for example the Mexican peso) have no calendar here.
  • The jurisdictions come from the symbol's currency information, the forex pairs and stock indices from its type: a broker that gives an index CFD another type, or a currency future without its base currency, gets the holidays of an ordinary market. A CFD quoted in another currency than its market's takes that currency's jurisdiction instead (a Japanese index CFD quoted in US dollars follows the United States), and a symbol without currency information follows the United States.
  • The ratings follow common economic calendars at the time each version was built. Which releases count as high impact is a convention, not a fact.
  • The library describes calendar days. Whether a news filter improves a trading method is not something it can show.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.