Moin, ich hab das mal wie folgt gemacht:
double Profit,OCP,OT,average,Lots; --> global
void BreakEven()
{
for (int i = OrdersTotal() - 1; i >= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
//-----
if (OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_SELL)
{
Lots = Lots + OrderLots();
Profit = Profit + OrderProfit() + OrderCommission()+OrderSwap();
OCP = OrderClosePrice();
OT = OrderType();
}
}
if( Lots > 0 )
double pips = Profit/Lots/MarketInfo(Symbol(),MODE_TICKVALUE);
if (OT == OP_BUY)
{
average = OCP - (pips*Point);
}
if (OT == OP_SELL)
{
average = OCP + (pips*Point);
}
Comment ("Lots = "+ Lots,
"\n","Profit = ", Profit,
"\n","pips = ", pips,
"\n",DoubleToStr(OCP,5),
"\n","BreakEven is: ", DoubleToStr(average,5),
"\n");
//----
}
|