- double CalculateAveragePrice(int mNumber)
- {
- AveragePrice = 0;
- double Count = 0;
- for(i = 0; i < OrdersTotal(); i++)
- {
- if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
- {
- if(OrderSymbol() == Symbol() && OrderMagicNumber() == mNumber)
- {
- if(OrderType() == OP_BUY || OrderType() == OP_SELL)
- {
- AveragePrice += OrderOpenPrice() * OrderLots();
- Count += OrderLots();
- }
- }
- }
- }
- if(AveragePrice > 0 && Count > 0)
- {
- return(NormalizeDouble(AveragePrice / Count, Digits));
- }
- else
- {
- return(0);
- }
- }
复制代码
|