Download MetaTrader 5

logical confusion

To add comments, please log in or register
pascalboy
238
pascalboy  

Thare are two expert diagrams below.

The logics are the same but results are different.

and "C" output must be the same but they differ.

Is there anyone to explain it?

I have real examples about them .

The results always differ.

1. EXAMPLE

If (condition1)

{

Open Buy Order

}

If (condition2)

{

Close Buy Order

}

C=OrderClosePrice-OrderOpenPrice ;

Print(C);

return:

2.EXAMPLE

If(condition1)

{

A=Ask ;

}

If(condition2)

{

B=Bid;

}

C=B-A;

Print (C);

return;

Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
pascalboy:

Thare are two expert diagrams below.

The logics are the same but results are different.

and "C" output must be the same but they differ.

Is there anyone to explain it?

I have real examples about them .

The results always differ.


They are only the same if you do the 2 condition1s during the same tick, and the 2 condition2s during the same tick . . . or maybe I am misunderstanding your example/question ?

Also in example 1 placing the order will take some time so that the Bid price may have changed, in example 2 the Bid and Ask look like they will be from the same tick.

pascalboy
238
pascalboy  
I am misunderstanding your example/question ?

Also in example 1 placing the order will take some time so that the Bid price may have changed, in example 2 the Bid and Ask look like they will be from the same tick.

pascalboy
238
pascalboy  
You understood right. But this logic is wrong.
Ian Venner
2584
Ian Venner  

The only way that could work reliably is if you send your trade functions with no slippage and assign the bid and ask prices to A and B as they are when you send the open or close order so if the order is rejected by requote and you refresh rates you can re assign the Bid or Ask to A or B.

Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
pascalboy:
You understood right. But this logic is wrong.
Exactly what is wrong ? if your 2 examples do different things how can you possibly expect the same outcome ?
Keith Watford
Moderator
10564
Keith Watford  
If (condition1)

{
A=Ask             // 1.5000
Open Buy Order    //Order sent @ 1.5000, but with slippage is executed at 1.5001 
a=OrderOpenPrice  // 1.5001
}
pascalboy
238
pascalboy  

i do not think 1-10 points slippage effect so much.

i tried example-2 between 01.01.2011-06.02.2014.

the sum of C was 40.

and C has never been negative.

i tried example -1 at the same period the

last balance was 1,05 times the initial balance .

after

i added vertical lines to example-1 at open order and close order points .

the vertical lines jumped 4-5 hours from some of the buy or close points.

Maybe there can be a jump at the program loop.Does not matter but it is strange .Thanks for your opinion.

Ian Venner
2584
Ian Venner  

If you post code examples properly people would understand what you mean.

Slippage would make a difference, the Bid and Ask would be as they were when you sent the order. If there was 2 points slippage it would make the OrderOpenPrice() 2 points different from the ask.

If (condition1)
{ 
 //open Buy Order (no slippage)
 A=Ask ; 
}

If (condition2) 
{
 //close Buy Order (no slippage)
 B=Bid;
} 

C = OrderClosePrice()- OrderOpenPrice() ;
Print("C = ",C); 


D = B-A
Print("D = ",D)
To add comments, please log in or register