Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
In some indicators there are null plots.
if(x)
Plot0.Set
else
Plot1.Set
...
If you call that indicator from a strategy, how do you tell if a plot is null, since it is assigned to a double?
Thanks, Ken.
Can you help answer these questions from other members on NexusFi?
It will vary depending on the code. It would be best to post a fully functional example.
Is this a commercial closed-source system? If so, you might have to just some more complex stuff for determining which plots to pay attention to. Sometimes unwanted plots will return 0 or will return the Close price.
I had worked with a closed-source system before that returned Close price for example on any plots it wasn't using at the time.
Thanks Mike,
It is more a theoretical question, since I have the source code and can program around it, but seems there should be a way to check for nulls, since in database programming (and in excel) it is necessary. Ken.
ps: It does return some value, perhaps the close, I didn't check it.
Well, I was just browsing around help and ran into this on the DataSeries Class help page:
//Checking for Valid Values
//It is possible that you may use a DataSeries object but decide not to set a value for a specific bar.
//Internally, a dummy value does exist which is the current bar close however,
//if you wanted to check to see if it was a valid value that you set, you can check the following method.
// test this for null values
// DataSeries.ContainsValue(int barsAgo)
//Returns a true or false value.
Also found something else interesting:
The Plot0.ContainsValue( index is intBarsAgo), so is the .Set
but the .Get is (index) or CurrentBar (may be CurrentBar plus or minus 1 - I'm not sure on this) but the inconsistency just floored me! Took me a while of frustration to realize what happened.
Hope this info is of some help to other coders. Ken.
Hi Kirk,
I don't have specific code handy, but here is something similar to what I was doing:
Say you have an indicator and the trend is shown by a Plot0 blue for an uptrend, and a Plot1 red for a downtrend, and you watch those values for a trend change. Similar to an EMA, but these come in two different plots.
if(Plot0.ContainsValue(0)) // true then not null
{
double dX = Plot0.Get(CurrentBar) // gotcha
}
// etc, (for compute on close)
I know you might not use Get that way unless you want the value of an offset way back (in my test case I only had values at the turns, not every bar).
Still learning this myself.
Ken.
ps: I forgot to say, I was calling the indicator from a strategy.