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)
I'm trying to do an inline if with multiple statements. I'm not sure this is possible?
int divisor = 1;
data = (!string.IsNullOrEmpty(symbol01) ? Closes[1][0] * Symbol01weight : 0) / divisor;
This is the simplest example, the actual condition is more complex.
What I want to do is change the 'true' condition to multiple statements:
Closes[1][0] * Symbol01weight; divisor++;
But I can't figure out a way to do this. At least not inline...
Thoughts? I tried Google but perhaps I am not wording it correctly, or it is impossible, because I can't find a solution (without rewriting the entire code block to not use an inline if).
You could stick it into a loop like for each symbol is empty reduce divisor by one.
But I think it would not be any more efficient, so it would probably only be for the looks.
could you consider changing symbol01..symbol10 to string[] symbols = new string[10] ? it would simplify above to "divisor = 1 + symbols.Count(s => !string.IsNullOrEmpty(s));" :P
Give some thought to how many times this test needs to be made and where this code is located.
Does it need to execute on every tick, on every bar, or just once (which is what it looks like to me, in which case it should be located in OnStartUp. Looks like that would require a different approach regarding what to do in response to the test.