Check out OrdersTotal(), OrderSelect(), OrderType(), OrderSymbol(), OrderOpenTime(), OrderLots(), etc. at https://docs.mql4.com/trading.
All you need is a loop which goes through all open orders picked by OrderSelect() and filters out all unsuitable orders.
All you need is a loop which goes through all open orders picked by OrderSelect() and filters out all unsuitable orders.
double lots = 0.; int i = OrdersTotal(); datetime tm; while (i > 0) { i--; OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() /* or whatever symbol */) continue; if (OrderType() != givenType) continue; tm = OrderOpenTime(); if (tm < intervalStart) continue; if (tm > intervalEnd) continue; lots += OrderLots(); }
Good luck,
mqlexpert {at} gmail {dot} com
Hi Irtron
Many Thanks for your help, it was most helpfull
Regards
Scouseman
Many Thanks for your help, it was most helpfull
Regards
Scouseman
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 wonder if somecould point me in the right direction, what I am trying to do is code a hedge. I am trying to work out a way of calulating the total number of lots which are open on a given symbol in a given direction at a given time, in order for me to place an opposite trade of equal ammount of lots to create a perfect hedge.
Any help would be most appreciated.
Thanks
Scouseman