a little confusing about the result difference caused by a little changed on codes

 

the codes are as below:

if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS))
{
 if(OrderSelect(0,SELECT_BY_POS));     
 if( 2*Stop_Loss > OrderOpenPrice()+ Bid )
..............
}

In the sentence "if(OrderSelect(0,SELECT_BY_POS));" above the codes, that the semicolon--";" is delete or not is obvious different for the result in the tester when back testing the pair for the past 3 years.

I think it should be almost the same for the result when we delete this semicolon or not here, but the result show it is another story.

So my question is that when or why the orderselct() would fail just in back testing rather than live trading.

Thank you.

 
vx0532:

the codes are as below:

In the sentence "if(OrderSelect(0,SELECT_BY_POS));" above the codes, that the semicolon--";" is delete or not is obvious different for the result in the tester when back testing the pair for the past 3 years.

I think it should be almost the same for the result when we delete this semicolon or not here, but the result show it is another story.

So my question is that when or why the orderselct() would fail just in back testing rather than live trading.

Thank you.

This line does nothing . . .

if(OrderSelect(0,SELECT_BY_POS));   

it is the same as . . .

if(OrderSelect(0,SELECT_BY_POS))
   {
   
   }   

. . . because of the ;

 
RaptorUK:

This line does nothing . . .

it is the same as . . .

. . . because of the ;


if(OrderSelect(0,SELECT_BY_POS));   

it does something, it change the selected order of course;

the ";" does something too

 
vx0532:

it does something, it change the selected order of course;

the ";" does something too

OK the OrderSelect() selects . . . the if does nothing.
 
  1. Why have an IF when it does nothing? What if there is no open orders? What are Function return values ? How do I use them ? - MQL4 forum
  2. Not filtering by magic number and pair make the EA incompatible with every other (including itself on other charts) and manual trading
  3. Price1 + Price2 is a meaning less number. Did you mean OOP - Bid?
    if( 2*Stop_Loss > OrderOpenPrice()+ Bid )
    Did you mean average price?
     if( Stop_Loss > (OrderOpenPrice()+ Bid)/2 )
 
WHRoeder:
  1. Why have an IF when it does nothing? What if there is no open orders? What are Function return values ? How do I use them ? - MQL4 forum
  2. Not filtering by magic number and pair make the EA incompatible with every other (including itself on other charts) and manual trading
  3. Price1 + Price2 is a meaning less number. Did you mean OOP - Bid?
    Did you mean average price?
Price1 + Price2 is a meaning less number. Did you mean OOP - Bid?
if( 2*Stop_Loss > OrderOpenPrice()+ Bid )

Yes, I mean OOP+Bid. this calculation means that now I have an order OP_Buy order and now I have set the stop loss line for it; now I want to send another OP_Buy order too if I still win when these two orders would closed at this stop line.