BE for both directions

 

Hello, I am working on an EA and have a problem with my BE function.

For Example:

  • BUY 1.00
  • BUY 1.10
  • BUY 1.20

Calculation of the BE is easy, it would be 1.10, so close all Trades if < = 1.10

But what do I do if I have this situation?

  • BUY 1.00
  • BUY 0.80
  • BUY 0.85

First the BE would be above the price of the second trade, with the third trade the BE would jump under the Price and would close immediatelly.

How can I make my BE function close trades, above and beneath the price, depending on the openprices of the trades, without getting in the way of each other?

Is there an easy solution, or am I missing something obvious here?

Thanks for any help.

 
Just wondering if anyone could explain what is BE function? Since I am new to the forum and Mql4. Thanks in advance.
 
wenfeiyunyun:
Just wondering if anyone could explain what is BE function? Since I am new to the forum and Mql4. Thanks in advance.

BE = Break Even
 

Use iExposure indicator and you can check BE for both directions trades of the currency

 
sepp112: But what do I do if I have this situation?
BE = lots weighted average = Sum(lots*oop)/Sum(lots)
 
WHRoeder:
BE = lots weighted average = Sum(lots*oop)/Sum(lots)
Thanks, but I can calculate the the BE. The question is how all trades are closed after BE is reached. If the second Long is above the first trade then close when ASK = BE. So how do I but that in one function that dos not interfere with each other?
 
sepp112:
Thanks, but I can calculate the the BE. The question is how all trades are closed after BE is reached. If the second Long is above the first trade then close when ASK = BE. So how do I but that in one function that dos not interfere with each other?

You simply close all trades when the current price == the calculated price to break even.
 
GumRai: You simply close all trades when the current price == the calculated price to break even.
Or move the SL of the trades to BE and they'll close when market comes back down.
 
hello, I prefer to not set a real stoploss, and the problem with current price == breakeven is, that when I do not get this exact price the BE will not trigger. It is very likly that the price will jump over/under the BE