Serious issue with charts in MT5! - page 2

 
Ryan L Johnson #:

I've never heard of closeby... likey because I'm in Netting Land.

What is the effect of closeby in a Hedge account? Is it a complete wash with no spread?

CloseBy is an accounting operation not a trade operation. It has the same net effect of closing a position on a netting account. That is, you pay commission and spread on deals in and out. In the case of a hedge account and 2 opposing positions on the same symbol, they cancel each other out hence you can just stripe them away against each other. But you will save one times the spread and commission over just closing them individually.

The mere existance of the CloseBy operation proves that hedging on the same symbol does not have any magical properties some believe it has.

Some brokers do not allow CloseBy operations, this tells you that with 10 out of 10 odds you need to switch broker.

 
Enrique Dangeroux #:
The mere existance of the CloseBy operation proves that hedging on the same symbol does not have any magical properties some believe it has.
Thank you for expounding on the topic of CloseBy. Obviously, I'm not missing out on any magical function. I would never use it.
 
Ryan L Johnson #:
Thank you for expounding on the topic of CloseBy. Obviously, I'm not missing out on any magical function. I would never use it.
You use it. On a netting account there is no choice and is applied by default. 
 
Enrique Dangeroux #:
You use it. On a netting account there is no choice and is applied by default. 

I'm afraid that I'm further confused. In a Netting account, I can't have opposing positions open simultaneously.

The documentation states:

Closing opposite positions: full and partial (hedging)

On hedging accounts, it is allowed to open several positions at the same time, and in most cases, these positions can be in the opposite direction. In some jurisdictions, hedging accounts are restricted: you can only have positions in one direction at a time. In this case, you will receive the TRADE_RETCODE_HEDGE_PROHIBITED error code when trying to execute an opposite trading operation. Also, this restriction often correlates with the setting of the ACCOUNT_FIFO_CLOSE account property to true. (https://www.mql5.com/en/book/automation/experts/experts_closeby).

And the Help page (mobile, anyway) states:

This type of operations can only be used with the hedging mode of position accounting system (https://www.metatrader5.com/en/mobile-trading/android/help/trade/closeby).

What would I even plug into the function parameters?:

bool  PositionCloseBy(
   const ulong   ticket,        // position ticket
   const ulong   ticket_by      // opposite position ticket
   )

(https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradepositioncloseby).

 
Abdullah Uygar Tuna #:
Hi, I think I can see what's happening here, and the good news is that nothing is wrong with your fills. It looks like the Close By mechanism rather than slippage.

Your log shows it: "bulk closing of all positions started", then "close position #43586020 sell 0.5 XAUUSD by position #43586067 buy 0.5". When MT5 bulk-closes a hedged account, it first settles opposite positions against each other (Close By) and only closes the rest at market.

With Close By, the two positions aren't closed at the current market price. They're settled against each other at the opening price of the opposite position:

- sell #43586020 opened at 4125.83
- buy #43586067 opened at 4132.84
- the Close By deal is "buy 0.5 at 4132.84", so the sell is shown closed at the buy's entry price

That's why the chart shows the sell closing about 7 dollars away from the market, which no spread could explain. The result itself is correct, though. That amount (7.01 x 0.5 lot x 100 oz = 350.50) was already locked in at 11:41:11, when the opposite buy was opened while the sell was still running. Close By simply books it. It also explains why your account statistics add up while the chart arrows look off.

Only the third position (#43586078) was closed at market, at 4126.73, and that one reflects the real price at that moment.

Two practical notes:
1. Close By actually works in your favour: the two opposite positions are settled without paying the spread on either leg, whereas closing them separately would cost two spreads.
2. If you'd prefer the chart to show market prices, close the positions one by one instead of using bulk close. The combined result will be the same, or slightly worse because of the extra spreads.

You can confirm it in the History tab: the Close By deal has the direction "out by", and its price matches the opposite position's open price.

Hope this helps!

Hello and thank you very very much for your kind response and for explaining exactly what was happening on my account!

Yes indeed, the result in my balance was fine, but it looks very odd on the chart.

I will message you privately on how this affects the free version of your EA...

Thanks again, it now makes good sense!