Download MetaTrader 5

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

To add comments, please log in or register
Find out the most discussed Forum topics. Have a look at the Wall section!
Fa Cao
1141
Fa Cao 2014.01.21 03:09 

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.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.01.21 09:06  
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 ;

Fa Cao
1141
Fa Cao 2014.01.21 12:32  
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

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.01.21 12:35  
vx0532:

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

the ";" does something too

OK the OrderSelect() selects . . . the if does nothing.
whroeder1
14514
whroeder1 2014.01.21 13:12  
  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 )
Fa Cao
1141
Fa Cao 2014.01.21 15:05  
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.

To add comments, please log in or register