Having Problem with Close and Open an order

To add comments, please log in or register
Parham
12
Parham  

I am working on an EA, which I know would be very profitable, but I have a problem.

In Sell Position : it sells in a right place but for exit of that sell it close 13 pips above the right place.

the code for alosing is : [[[[ OrderClose(Ticket,Cls_Lot,Ask,2) ]]]]

please see the attachement for sell

In Buy Position : it buys 13 pips above the right place. but it closes in a right place.

the code for alosing is : [[[[ OrderBuy(Ticket,Cls_Lot,Bid,2) ]]]]

please see the attachement for buy

redindian
14
redindian  
Is it always 13 pips? What are you buying/selling?
Parham
12
Parham  
redindian:
Is it always 13 pips? What are you buying/selling?

I am testing it only on EURUSD for now.
William Roeder
22318
William Roeder  
More likely closing at 1.3 pips, the amount of the spread. 1 pip = 0.00010 (except JPY) Or you're testing when market is closed and the last spread happened to be 13 pips

Buy open at the Ask close at the Bid. Sell open at the Bid, close at the Ask. MQL4 charts are Bid charts. A Buy will never Open where you want, A Sell will never close where you want.

What attachment?
Parham
12
Parham  
WHRoeder:
More likely closing at 1.3 pips, the amount of the spread. 1 pip = 0.00010 (except JPY) Or you're testing when market is closed and the last spread happened to be 13 pips

Buy open at the Ask close at the Bid. Sell open at the Bid, close at the Ask. MQL4 charts are Bid charts. A Buy will never Open where you want, A Sell will never close where you want.

What attachment?


I know that Buy never open wher I want and sell will nevever close where I want, having different of spread is ok which is 3 pip, not 13 pip.

but I am testing it when market is close, are you sure that when market is close last spread happend to be 13 pip? how could I check that?

Simon Gniadkowski
17271
Simon Gniadkowski  
parhampe:


but I am testing it when market is close, are you sure that when market is close last spread happend to be 13 pip? how could I check that?

Spreads typically open up on a Friday evening just before the markets close . . . if you want to check your current spread add this to your code or create a simple script . . .

Print("Spread = ", Ask-Bid);  //  or . . 

Print("Spread = ", MarketInfo( Symbol(), MODE_SPREAD) );

. . . the last spread value on Friday evening is what the Strategy Tester will use throughout the weekend . . there are ways round this . . do a search.

To add comments, please log in or register