I have programmed custom indicators for years, but I’m unable to use the UNDEFINED keyword.
In order to learn how to use in its simplest form, I’ve created the following indicator
1
2
3
4
5
6
ifclose>close[1]then
a=1
else
a=undefined
endif
returna
I would have expected the custom indicator to have returned One (1) if there is an increase in the closing price, or Zero (or unknown or error, but different from zero in any case) in any other case.
My indicator always returns One(1)
There must be something that I am missing. Could you please help me understand?
The “undefined” keyword can only be used one time in a prorealtime code. It’s mainly use to set a variable to “nothing” before giving it a value for the first time, but then you cannot revert the variable to nothing (undefined).
So, the best you can do is set your variable to 0 if you don’t want to see it on your chart or your oscillator.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue