Outer [if] statement is false but inner [if] gets triggered

 

Hi Gurus,

appreciate any pointers!

Why does inner [if] statement trigger when outer [if] is false?

i have a series of [if],[else if] statement with this one having an inner [if].  i know the outer [if] is false because the global variable "Proclivity" is not being changed when i print it out: 

//the outer [if] statement is false but the inner [if] gets triggered.
 
else if ( 
         (plocalProclivity ==1 )

         && (pDXYProclivity ==-1)
         && ( DXYATRStrength == "VIX REVERSAL" || DXYATRStrength == "START VIX-TREND"
            ||  DXYRVIStrength == "RVITrendLONG" || DXYDeMPosition =="DEMBOTTOM" || DXYFramaCurrentPrice < DXYbotBB1)
         && ( DXYRVIScore ==1 || DXYDeMScore ==1 || DXYFramaScore ==1 )  
       ) 
      
      { 
        Proclivity= "PROC REVERSE-SHORT"; //global variable doesnt gets changed accordingly but the INNER-[if] statement below gets triggered!?!
  
        if ( alertswitchPrevious !=-4 && alertswitchPrevious !=5
            && CurrentPrice <= topBB2 && CurrentPrice > midBB )
            
            // && alertswitch != 51 && alertswitch != 21
            { 
            alertswitch = -4; 
            alertcomment =  " Reverse-Extreme";
            Check =2;
            }
      }
 
JimSingadventure: Why does inner [if] statement trigger when outer [if] is false?
  1. It doesn't.
  2. You don't have an “outer if”; you have an outer else if. Always post all relevant code (using Code button) or attach the file.
  3. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)