You might try:
print g
print f
print data[stock].close_price
% record(gf = g + f, close_price = data[stock].close_price)
If you get floats to the log output, then uncomment 'record' and it should work. Note however, that it is only set up for a single stock. Presumably, you have the call to record in a loop and you are trying to record values for multiple stocks?
Have a look at the help page and the example code there for the record function to get a better feel for how it works. Basically, you can plot up to five values, so if gf is common to all of your stocks, you could do something like:
record(gf = g + f, close_1 = data[sid_1].close_price,close_2 = data[sid_2].close_price,close_3 = data[sid_3].close_price,close_4 = data[sid_4].close_price)
Grant