double buy=0, sell=0;
double lotbuy =0, lotsell=0;
double BEPbuy=0, BEPsell=0;
for (int a = 0; a < OrdersTotal(); a++)
{
if(OrderSelect(a, SELECT_BY_POS,MODE_TRADES) == true)
{
if (OrderSymbol() == Symbol() && OrderCloseTime() == 0) // Jika ada magic number ditambahkan && OrderMagicNumber()==MagicNumber
{
if(OrderType() == OP_BUY) {buy+=OrderOpenPrice()*OrderLots();lotbuy+=OrderLots();}
if(OrderType() == OP_SELL) {sell+=OrderOpenPrice()*OrderLots();lotsell+=OrderLots();}
}
}
}
BEPbuy = NormalizeDouble(buy/lotbuy,Digits);
BEPsell = NormalizeDouble(sell/lotsell,Digits);