Clarification on open/close/buy/sell prices

 

Hi guys,
On testing the newest EA I see some strange things, e.g closing order inside StopLevel zone
with profit and without getting an error in the Jourlal. This should not happend IMHO.
Any reason why I can e.g close sell at 10 points below openprice, when stoplevel is in fact 20 points ?
In this case OrderSend(ECN) - Set stops - OrderClose - all happens in a couple of thicks I think.
From The Results:
# Time Type Order Size Price S/L T/P Profit Balance
907 2011.03.16 22:32 sell 303 0.46 1.39187 0.00000 0.00000 0.00 5999.32
908 2011.03.16 22:32 modify 303 0.46 1.39187 1.40497 1.38587 0.00 5999.32
909 2011.03.16 22:32 close 303 0.46 1.39197 1.40497 1.38587 -4.60 5994.72
910 2011.03.16 22:32 sell 304 0.46 1.39191 0.00000 0.00000 0.00 5994.72
911 2011.03.16 22:32 modify 304 0.46 1.39191 1.40501 1.38591 0.00 5994.72
912 2011.03.16 22:32 close 304 0.46 1.39201 1.40501 1.38591 -4.60 5990.12
913 2011.03.16 22:32 sell 305 0.46 1.39183 0.00000 0.00000 0.00 5990.12
914 2011.03.16 22:32 modify 305 0.46 1.39183 1.40493 1.38583 0.00 5990.12
915 2011.03.16 22:32 close 305 0.46 1.39193 1.40493 1.38583 -4.60 5985.52


My best guess is that I've made a bummer on some price definitions.

Correct me if I'm wrong on any of these:

1) OpenBuy at Ask, CloseBuy at Bid
2) OpenSell at Bid, CloseSell at Ask
3) if Buy, OrderOpenPrice() is Ask
4) If Sell, OrderOpenPrice() is Bid
5) Order history Prices in Terminal / Tester Result are all Bid
6) Chart candle prices are all Bid

O.T: It would be nice if we could select a mono space font when needed...


 
  1. open a buy at the Ask, Close the Buy at the Bid
  2. open a Sell at the Bid, close the Sell at the Ask
  3. OrderopenPrice is the price opened AT
  4. OrderopenPrice is the price opened AT
  5. history prices are the prices
  6. mql4 charts are bid charts.
Any reason why I can e.g close sell at 10 points below openprice, when stoplevel is in fact 20 points ?

You can not close an order when market is closer to SL/TP than MarketInfo(chart.symbol, MODE_STOPLEVEL)*Point. Usually 10-30 points on non ECN brokers.

07 2011.03.16 22:32 sell 303 0.46 1.39187 0.00000 0.00000 0.00 5999.32
908 2011.03.16 22:32 modify 303 0.46 1.39187 1.40497 1.38587 0.00 5999.32
909 2011.03.16 22:32 close 303 0.46 1.39197 1.40497 1.38587 -4.60 5994.72

You opened a sell. Set the SL 131 pips (including spread) above open price, TP 60 pips/600 points below. The Order closed the order 61 pips below for a loss. That makes no sense!
 

Yes there is something funny there...

For order 303: SL= -1310points, TP= +610points, the order was closed by OrderClose() @ -10points (an error in my soft did that). -10points x $10 x 0.46lots = -$4.60, so all that adds up correctly.

NOTE: I do all testing offline.

But the StopLevel was checked multiple times and came out as 20 points, so ordering the close of this order should have been rejected, or maybe the terminal tester tolerates

this kind of things.... in any case it should have thrown up an 130 or 145 error in the Journal. Remember from open to close took probably only 3 ticks.

Looks like its not entirely safe to rely on the Journal to weed out such errors... OR maybe the reason is that spread was 10points, that might have brought the close 1 point outside the StopLevel.

Reason: