Provided that your order magic number is stored in a variable myMagic, the code is as follows (havent tried compiling):
void printMyOrders() { int highestBuyPos=-1, lowestSellPos=-1; double highestBuyPrice=0.0, lowestSellPrice=1000000.0; for(int i=0; i < OrdersTotal(); i++){ if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { return ; } if(OrderSymbol()==Symbol()) { if(OrderMagicNumber()==myMagic) { if(OrderType() == OP_BUY) { if(highestBuyPrice < OrderOpenPrice()) { highestBuyPrice = OrderOpenPrice(); highestBuyPos = i; } } else if(OrderType() == OP_SELL) { if(lowestSellPrice > OrderOpenPrice()) { lowestSellPrice = OrderOpenPrice(); lowestSellPos = i; } } } } } if(!OrderSelect(highestBuyPos, SELECT_BY_POS, MODE_TRADES)) { Alert("Failed selecting highest buy order!"); } else { OrderPrint(); } if(!OrderSelect(lowestSellPos, SELECT_BY_POS, MODE_TRADES)) { Alert("Failed selecting lowest sell order!"); } else { OrderPrint(); } }
Thank you very much

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
for example-:
I have 3 buy orders and 4 sell orders open at the price below
3 Buy orders open price
2.5
2.3
2.6
4 Sell orders open price
1.6
1.2
1.1
1.5
Now I only want to display the highest of buy open price which is 2.6 and the lowest sell open price which is 1.1.
Anybody know how to do this?