I will try this. Thank you
Slawa here is what I tried. I want closed from Expert only, not all experts, so I make balance = 0.
It works for buy orders but does not seem to work for sells. I am getting mixed results
It works for buy orders but does not seem to work for sells. I am getting mixed results
closedProfit = 0; // counts closed p&l double point_value; double balance= 0; int type = OrderType(); int total = HistoryTotal(); for(int i=0;i<total;i++) // scan all closed / cancelled transactions { OrderSelect(i, SELECT_BY_POS, MODE_HISTORY ); if ( OrderSymbol()==Symbol() && ( (OrderMagicNumber() == Magic1) { closedProfit = closedProfit + OrderProfit(); point_value=MarketInfo(OrderSymbol(),MODE_POINT); if(point_value==0) continue; double open_price=OrderOpenPrice(); double close_price=OrderClosePrice(); double profit=(close_price-open_price)/point_value; if(type==OP_SELL) profit=-profit; balance+=profit; } }
If can help, thanks
int type = OrderType(); should be inside loop after OrderSelect

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I also know how to see pips on my chart comments using Ask,Bid, and OrderOpenPrice.
How Can I get the total pips earned and lost from orders I have closed?
Here is code I use to get my closed Profit/Loss:
Thank you