Well that would be a question best answered by TD Ameritrade themselves. But since you posted the question here I will explain that this line of code does:
Taken from the RelativeStrength chart study in Thinkorswim
def sr = CompoundValue("historical data" = RS, "visible data" = if isNaN(sr[1]) then RS else sr[1]);
This is a recursive statement. This is used to initialize the sr variable. In the case that the previous value of sr is Double.NaN, the statement substitutes the value of the RS variable in its place (the first bar on the chart). The sr variable is used to plot the flat horizontal red line, via the plot named "SRatio". This plot merely shows the starting value for the RS plot. The RS plot is the actual value of relative strength and does not require recursive statements in its computation.