I want to change this part of the code so that it calculated the PE ratio increase from the same quarter but one year previously (e.g Q4 to Q4, etc.). How would you change the code do do that? Thanks to anyone who helps!!
fwdpeGrowth(sym) =>
quarterlyResult = request.financial(sym, "PRICE_EARNINGS_FORWARD", "FQ", gaps = barmerge.gaps_on, ignore_invalid_symbol = true)
var float lastQuarterlyResult = na
var float result = na
if not na(quarterlyResult)
result := nz((quarterlyResult - lastQuarterlyResult)/lastQuarterlyResult)
lastQuarterlyResult := quarterlyResult
result
plot(fwdpeGrowth(syminfo.tickerid))