I would like to know how I can 1) obtain the total profit on all my open trades, and then 2) say close all orders if this value is above a certain number. Any ideas?
Profit/loss on open trades is simply AccountEquity() minus AccountBalance(). For code to close all open orders, do a search on this forum - that question comes up about once a week. The standard way of doing it is to loop down from OrdersTotal()-1 to zero.
Profit/loss on open trades is simply AccountEquity() minus AccountBalance(). For code to close all open orders, do a search on this forum - that question comes up about once a week. The standard way of doing it is to loop down from OrdersTotal()-1 to zero.
... and in that loop simply select each order, then match it against a symbol if necessary, then close it.
Doesn't anyone ever BOTHER to search the forums these days?
CB

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I would like to know how I can 1) obtain the total profit on all my open trades, and then 2) say close all orders if this value is above a certain number. Any ideas?
Sp