From the code you posted, it should give you the result you're expecting.
The only thing I can think of is that you're looking at a different ATR value from your chart compared to what your code is reading. Run it through the debugger to make sure you're actually getting 0.034.
BTW, you don't need to check if it's <= in your else if statements. The check for <= was already performed in the previous if/else if statements when it failed the condition for >=
Before:
if(ATRCurrent <= 0.115 && ATRCurrent >= 0.093) pATRStrength = "VIX REVERSAL"; else if(ATRCurrent <= 0.092 && ATRCurrent >= 0.070 ) pATRStrength = "WEAKENING VIX-TREND"; else if(ATRCurrent<= 0.069 && ATRCurrent >= 0.047 ) pATRStrength = "VIX-TRENDING"; else if(ATRCurrent <= 0.046 && ATRCurrent >= 0.024 ) pATRStrength = "START VIX-TREND"; else if(ATRCurrent <= 0.023 && ATRCurrent >= 0.010 ) pATRStrength = "VIX REVERSAL";
After:
if(ATRCurrent <= 0.115 && ATRCurrent >= 0.093) pATRStrength = "VIX REVERSAL"; else if(ATRCurrent >= 0.070) pATRStrength = "WEAKENING VIX-TREND"; else if(ATRCurrent >= 0.047) pATRStrength = "VIX-TRENDING"; else if(ATRCurrent >= 0.024) pATRStrength = "START VIX-TREND"; else if(ATRCurrent >= 0.010) pATRStrength = "VIX REVERSAL";
-
Alexander showed how to simplify.
-
Always post all relevant code (using Code button) or attach the file. Your images show your ATR of bar zero. We have no idea what ATRCurrent is.
- How do you handle pATRStrength when none of those levels exist?
From the code you posted, it should give you the result you're expecting.
The only thing I can think of is that you're looking at a different ATR value from your chart compared to what your code is reading. Run it through the debugger to make sure you're actually getting 0.034.
BTW, you don't need to check if it's <= in your else if statements. The check for <= was already performed in the previous if/else if statements when it failed the condition for >=
Before:
After:
thanks Alex for the clear example of how to simplify. that's a cool way to do and i will never have thought about that in a million years.
earlier i tried simplifying it by writing it like so below but i'm still fuzzy why it doenst seem to work.
0.092 >= ATRCurrent >= 0.070btw, i'll try to study and learn how to use debugger. still a newbie here!
wow, thanks wiliam, i never thought that's how to read it!
that's insightful for a newbie like me. appreciate. But sometimes your comments are too high "up there" that i have a hard time understanding it at my level.
which means the correct way to write it must be :if( 3 > (2 > 1 )) if( 3> true) if( 3 > 1) if(true)
right?
- I won't generally give it; just point you in the correct direction so you will learn.
- Correct, but 3 > (5 > 4) is also true. Don't compare numbers to booleans.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Gurus,
appreciate any assistance!
As you can see from screenshots below, the ATRCurrent value is at 0.034, which should translate to pATRStrength becoming "START VIX-TREND" instead of "VIX-TRENDING"
what is wrong with my code or...does [if] vs. [else if] make any difference of how it evaluates?
(btw, the statement above is part of an #include function file which i call from the Main EA to reflect a string comment based on value of the ATRCurrent double. )