BARDATE and GETDATA

Hi,

I am trying to retrieve from a data file the value on a certain date that I loaded with the function “GETDATA()”.

Here is my script:

// Get Real S&P 500 Monthly Data Since 12/01/1949
Line1 = GETDATA(CODE=S P 500 Real Monthly Long Term:UE, DATERANGE=Selected Date, DATETOLOADFROM=1949-12-01, TIMEFRAME=1 Month) ;

// Get Start Value from 12/01/1949
Line2 = BARDATE()==STRDATE(DATE=1949-12-01) ;
Line3 = VALUEWHEN(Line2) ;
Line3

Unfortunately, the file I loaded in “Line1” is not recognized in “Show View”! The value I get is the one of the data file that I have loaded in the main chart window but not the one I want as specified in “Line1”.

I tried many settings in “Line2” to place the “Line1” reference, but all solutions failed.

All suggestions are welcome.

Thanks,
Thomas

Thanks Thomas. When I use our data and ticker symbol it works fine, so it might be the spaces in your imported ticker symbol not working with GETDATA. Have you used it before? If you make the last line Close(Line1) to just show the closing values do you see any results?

Hi Darren,

Thanks for your efforts. I tried a new file name without spaces between words. It did not work!

As far as I understand the problem, the script works as long as the same data file is loaded in the main chart window that is used in the script.

But if a different data file is loaded in the main chart window than is used in the script, the script does not work!

So I think that the script does not recognize the GETDATA() function at all.

I have attached a workbook with some examples so you can better understand the issue.

Thank you very much for your efforts,
Thomas

BARDATE-and-GETDATA-Test-1.owb (48.6 KB)

Hi Thomas,

The VALUEWHEN function in Line3 gets the value of the chart in the main window, ie DJIA for the October 1949 quarter (if you just plot Line3 in a Show View it will draw a line at 200.52).

Are you saying that you want the Oct 1949 value of GDPC1 regardless of the main chart? Once way would be to do it as follows by only loading the GETDATA from October 1949 and using the FIRST() function:

// Get Real GDP Data from 10/01/1949
Line1 = GETDATA(CODE=GDPC1:FRED, DATERANGE=Selected Date, DATETOLOADFROM=1949-10-01) ;
// Get Start Value 
Line3 = FIRST(Line1);
// Calculating the Index Values
Line5 = 100 * (Line1 / Line3 ) ;
Line5

Here’s the breakdown of Lines 1, 3, and 5 showing the values:

Capture