IF() reading True....when it should not

 
void rolShortStopA()
   {
   

   for(int b=OrdersTotal()-1; b>=0; b--)
      {
      bool ShortA;
      
      if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)
         && OrderMagicNumber()==Magic
         &&      OrderType()==OP_SELL
         &&         Ask<OrderOpenPrice()-(0.5*stopShort)
         )
                          { 
                      ShortA= OrderModify(OrderTicket(),0,Ask+(stopShort),OrderTakeProfit(),0,clrPurple);       
                     
                           if(!ShortA) Print("Error modifying ShortStopA", GetLastError()); else Print("ShortStopA OK");
                           
                           }         
       
       }
       
    }

Hi

I have the above function in my EA. My understanding is, if I've wrote it how I intended to, the part inside the blue parentheses should only run if ALL 4 of the conditions of the IF() are met. I know the last red highlighted argument is definitely false. However, after reviewing the Print, the section inside the { } still seems to be running anyway! This is because I'm getting a "Error modifying ShortStopA error 130" message.

I understand what an error 130 message is, and I think I know how to fix it. However, my understanding is the section inside the { } should not run because the red highlighted argument is definitely FALSE.


Am I misunderstanding something?

Many thanks

Steve

Many thanks 

Steve

 
lancastersteve: I know the last red highlighted argument is definitely false.

Exactly how do you know that?

How To Ask Questions The Smart Way. 2004
          Don't rush to claim that you have found a bug.
Questions Not To Ask
          My program doesn't work. I think system facility X is broken.

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?

 
William Roeder:

Exactly how do you know that?

How To Ask Questions The Smart Way. 2004
          Don't rush to claim that you have found a bug.
Questions Not To Ask
          My program doesn't work. I think system facility X is broken.

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?

Thanks William. I've already printed out the variables, which is why I'm confident the last red argument is false, and therefore my understanding (although basic) is that the section inside the { } should not run.

When I run as a Backtest, my code does what I expect it to do ; the section inside { } would not run.

It's in a Live situation where the section inside the { } runs, and this is causing my confusion.


This is despite the values of Ask, OrderOpenPrice, StopShort all being the same in both Backtest & in a Live situation when I Print the variables.

Reason: