Having Problem with Close and Open an order

 

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

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

I am testing it only on EURUSD for now.
 
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?
 
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?

 
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.

Reason: