Checking for Not A Number (NAN)
Author: thetraderman
Creation Date: 6/27/2011 12:21 PM
profile picture

thetraderman

#1
Is there a way I can check for an NAN error. Sometimes my script disappears and on the next bar reappears. In other words the indicators come and go. Does not happen often but sometimes. I wonder if that is related to the script being out of synch with WL at times as well.
profile picture

Cone

#2
QUOTE:
Sometimes my script disappears and on the next bar reappears
I think you mean that your indicators disappear...

First thing to do when that happens is to look at the bottom of the Editor for the runtime error, click on it, and see where it takes you.
profile picture

Eugene

#3
Do a PrintDebug on your indicators while looping bar by bar. The debug window will most likely indicate a NaN somewhere.
profile picture

thetraderman

#4
Well, it happened again and I did check the bottom of the editor and so no runtime errors. As a matter of fact it was blank as if everything was fine. I hesitate to put debug statements because it is like looking for a needle in a haystack which could be anywhere. Just as a reminder, I never saw this in the previous version of WL. Since I uploaded the new version, it already happened about 3 times.
profile picture

Eugene

#5
Could you point me where did I say to look at the "bottom of the editor"?

I'm sure the suggestion was to call PrintDebug in the loop to output the indicator's value on each bar to the Debug window.

As a quick alternative you might try mousing over the indicator's value on a bar and noticing its value in the Data window.
profile picture

Cone

#6
QUOTE:
Could you point me where did I say to look at the "bottom of the editor"?
You didn't, I did :)

Runtime errors are another reason that indicators (and panes and anythign else) won't show up in a chart, but it sounds like the NaN scenario here.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).