Error: trace is not on graph

Hello! I am currently making a code in Igor that involves using cursors. I am not very familiar with them so I am in need of assistance. I am trying to use a cursor but I keep having the error: trace is not on graph. I have tried following the Igor cursor examples for help with this issue but to no avail. Any help would be appreciated. 

    // find x_value for corresponding y-half    //
                    AppendToGraph selection_fit
                    string tname = NameOfWave(selection_fit)
                    Cursor/P A tname 0
                    Print CsrXWaveRef(A)[100]

For context, selection_fit is the name of the wave that is created from a curve fitting. 

Cursor takes a trace name, not a string containing a trace name. So, with you command, it is looking for a trace named tname.

Use selection_fit instead of tname in the Cursor command.

You could use this:

Cursor/P A $tname 0  // $ converts a string containing a name to a name

but it is not necessary in this case.