Der Code ist korrekt und geht auch fast! nicht zu verkürzen, außer:
Code:
double BreakevenOfAllTrades()
{
double Total=0,
buy_TotalLots=0,
price= 0,
lots =0,
buy_pricetimeslots=0,
buy_TotalPriceTimesLots=0,
sell_TotalLots=0,
sell_pricetimeslots=0,
sell_TotalPriceTimesLots=0;
for(int cnt=0;cnt<OrdersTotal();cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol() == Symbol())
price = OrderOpenPrice();
lots = OrderLots();
if(OrderType()==OP_BUY)
{
buy_pricetimeslots = price * lots;
buy_TotalLots += lots;
buy_TotalPriceTimesLots += buy_pricetimeslots;
}
if(OrderType()==OP_SELL)
{
sell_pricetimeslots = price * lots;
sell_TotalLots += lots;
sell_TotalPriceTimesLots += sell_pricetimeslots;
}
}
if(buy_TotalLots != sell_TotalLots)
Total=(buy_TotalPriceTimesLots - sell_TotalPriceTimesLots) / (buy_TotalLots - sell_TotalLots);
return(Total);
}
traderdoc