PINE LIBRARY

forex_factory_decoding

Updated
Library "forex_factory_decoding"
Supporting Utility Library for the Live Economic Calendar by toodegrees Indicator; responsible for formatting and saving Forex Factory News events.

isLeapYear()
  Finds if it's currently a leap year or not.
  Returns: Returns True if the current year is a leap year.

daysMonth(M)
  Provides the days in a given month of the year, adjusted during leap years.
  Parameters:
    M (int): Month in numerical integer format (i.e. Jan=1).
  Returns: Days in the provided month.

MMM(M)
  Converts a month from a numerical integer format to a MMM format (i.e. 'Jan').
  Parameters:
    M (int): Month in numerical integer format (i.e. Jan=1).
  Returns: Month in MMM format (i.e. 'Jan').

array2string(S, FWD)
  Converts a string array to a simple string, concatenating its elements.
  Parameters:
    S (string[]): String array, or string array slice, to turn into a simple string.
    FWD (bool): Boolean defaulted to True. If True the array will be concatenated from head to tail, reversed order if False.
  Returns: Returns the simple string equivalent of the provided string array.

month2number(M)
  Converts a month string in 'MMM' format to its integer equivalent.
  Parameters:
    M (string): Month string, in 'MMM' format.
  Returns: Returns the integer equivalent of the provided Month string in 'MMM' format.

shiftFWD_Days(D)
  Shifts forward the current Date by N days.
  Parameters:
    D (int): Number of days to forward-shift, default is 7.
  Returns: Returns the forward-shifted date in 'MMM %D' format (i.e. Jan 8, Sep 12).

ff_dow(D)
  Converts a numbered day of the week string in format to 'DDD' format (i.e. "1" = Sun).
  Parameters:
    D (string): Numbered day of the week from 1 to 7, starting on Sunday.
  Returns: Returns the day of the week in 'DDD' format (i.e. "Fri").

ff_currency(C)
  Converts a numbered currency string in format to 'CCC' format (i.e. "1" = AUD).
  Parameters:
    C (string): Numbered currency, where "1" = "AUD", "2" = "CAD", "3" = "CHF", "4" = "CNY", "5" = "EUR", "6" = "GBP", "7" = "JPY", "8" = "NZD", "9" = "USD".
  Returns: Returns the currency in 'CCC' format (i.e. "USD").

ff_t(T)
  Converts a time of the day in 'hhmm' format into an intger.
  Parameters:
    T (string): Time of the day string in 'hhmm' format.
  Returns: Returns the time of the day integer in 'hhmm' format, or -1 if all day.

ff_tod(T)
  Converts a time of the day from an integer 'hhmm' format into 'hh:mm' format.
  Parameters:
    T (int)
  Returns: Returns the N Forex Factory News array with time of the day string in 'hh:mm' format, or 'All Day'.

ff_impact(I)
  Converts a number from 1 to 4 to a relative color based on Forex Factory Impact types.
  Parameters:
    I (string): Impact number string from 1 to 4, where "1" = Holiday, "2" = Low Impact, "3" = Medium Impact, "4" = High Impact.
  Returns: Returns the color associated to the impact number based on Forex Factory Impact types.

ff_tmst(D, T)
  Parameters:
    D (string)
    T (string)

decode(ID)
  Decodes TOODEGREES_FOREX_FACTORY_SLOT_n Symbols' Pine Seeds data into Forex Factory News Events.
  Parameters:
    ID (int): Identifier of the Forex Factory News Event, in "DCHHMMI%T" format (D = day of the week from 1 to 7, C = currency from 1 to 9, HHMM = hour:minute in 24h, I = impact from 1 to 4, %T = event title ID) [See library for more information].
  Returns: Returns the Forex Factory News Event.

method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/1): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/1): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/1): Forex Factory News array.
    S (string[]): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v2

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/2): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/2): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/2): Forex Factory News array.
    S (string[]): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v3

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/3): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/3): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/3): Forex Factory News array.
    S (string[]): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v4

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/4): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: ffUtil.News[]
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/4): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (News[] type from toodegrees/forex_factory_utility/4): Forex Factory News array.
    S (string[]): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v5

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/5): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/5): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/5): Forex Factory News array.
    S (array<string>): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v6

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/6): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/6): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/6): Forex Factory News array.
    S (array<string>): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v7

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/7): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/7): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/7): Forex Factory News array.
    S (array<string>): String array containing the Pine Seeds daya from the missing day.
    S1 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_1.
    S2 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_2.
    S3 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_3.
    S4 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_4.
    S5 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_5.
    S6 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_6.
    S7 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_7.
    S8 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_8.
    S9 (string): Data coming from TOODEGREES_FOREX_FACTORY_SLOT_9.
  Returns: Updated string array containing the Pine Seeds daya from the missing day.
Release Notes
v8

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/8): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/8): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void

Removed:
marketClosed(N, S, S1, S2, S3, S4, S5, S6, S7, S8, S9)
  If the current ticker's market is closed, Pine Seeds data will be pushed twice upon new day. This function saves the data pushed from the missing day.
Release Notes
v9

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/9): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/9): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v10

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/10): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/10): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v11

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/11): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/11): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v12

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/12): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/12): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v13

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/13): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/13): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v14

Updated:
method pullNews(N, n)
  Decodes the Forex Factory News Event and adds it to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/14): Forex Factory News array.
    n (float): imported data from custom feed.
  Returns: void

method readNews(N, S)
  Pulls the individual Forex Factory News Event from the custom data feed format (joint News string), decodes them and adds them to the Forex Factory News array.
  Namespace types: array<ffUtil.News>
  Parameters:
    N (array<News> type from toodegrees/forex_factory_utility/14): Forex Factory News array.
    S (string): joint string of the imported data from custom feed.
  Returns: void
Release Notes
v15
Release Notes
v16
Release Notes
v17
Release Notes
v18
Release Notes
Fixed Local Scope Error
Release Notes
v20
Release Notes
v21
Release Notes
v22
Release Notes
v23
Release Notes
v24
Release Notes
v25
Release Notes
v26
inputs

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.


homo faber fortunæ suæ
Also on:

Disclaimer