pine-scriptpine-script-v5quandl

Pine script: recent data from FRED/GDPC1 are missing


I am trying to display the value of the actual GDP which is provided by FRED/GDPC1 in my chart, using request.quandl().

I applied my indicator and set the time frame of the chart to 3 month (3M) since the GDPC1 data were quarterly based. All the values of the actual GDP were displayed ok up till October 1st, 2021, but after October 1st, 2021, there was no value displayed (i.e. empty and no data obtained). On the actual website of FRED GDPC1(FRED/GDPC1), you can download the data in excel, and in the excel, it contains all the values of the actual GDP since January 1st, 1947, until July 1st, 2023. So the values after October 1st, 2021, do exist. Can anyone tell me if I am doing something wrong in my code or it is just an issue of the quandl data (i.e. they don't provide a complete data for FRED/GDPC1)?

Here is my code for your reference.

//@version=5
indicator("US-Real-GDP", overlay=false)

// Obtain "Real GDP"
real_gdp = request.quandl("FRED/GDPC1", barmerge.gaps_on, 0)
real_date = request.quandl("FRED/GDPC1", barmerge.gaps_on, 1) // According to Chat-GPT, index number "1" should provide the date information for a given GDP value, but not working...


// Plot
plot(real_gdp, "US Real Gap", color.blue, 5, plot.style_histogram)

Chart image

I tried to use request.security() instead of request.quandl() as follows, but the result was the same (i.e. still no values/data after October 1st, 2021.

real_gdp = request.security("QUANDL:FRED/GDPC1", timeframe.period, close, barmerge.gaps_on)

Solution

  • The issue might be on the QUANDL's side, seeing how opening the data set on their end leads to nothing, at least for me: https://data.nasdaq.com/data/FRED/GDP-gross-domestic-product

    It should be noted that TradingView has FRED data natively, without QUANDL as the middleman, and it can be accessed via the FRED: exchange prefix (write FRED: in search and you'll see top popular symbols from this dataset). And any symbol that's available on the chart can be requested via the regular request.security() function, so you can just do this instead:

    //@version=5
    indicator("US-Real-GDP", overlay=false)
    
    // Obtain "Real GDP"
    real_gdp = request.security("FRED:GDPC1", "3M", close)
    
    // Plot
    plot(real_gdp, "US Real Gap", color.blue, 5, plot.style_histogram)