Patel Hitendrakumar Mahendrabhai:
hi,
if open order 10
i want calculate if (10th order - 1st order) = 1$ profit so close both trade, 2 to 9 order wait for profit
Loop through all open positions and check the open date/time.
Here is an example of such a loop: https://www.mql5.com/en/code/36010
Copy what you need and adjust it to your requirements.
![Close All Orders and Positions Close All Orders and Positions](https://c.mql5.com/36/56/close-all-orders-and-positions.jpg)
Close All Orders and Positions
- www.mql5.com
This is a simple script that Closes all Orders and Positions available
If (PositionsTotal()>0) { PositionGetTicket(0); //Oldest Opened Position PositionGetDouble(POSITION_PROFIT); // Get the position Profit PositionGetTicket(PositionsTotal()-1); //latest Opened Position PositionGetDouble(POSITION_PROFIT); // Get the position Profit }
Read documents to close positions
Patel Hitendrakumar Mahendrabhai: i want calculate if (10th order - 1st order)
MT5 has positions, not opened orders.
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
hi,
if open order 10
i want calculate if (10th order - 1st order) = 1$ profit so close both trade, 2 to 9 order wait for profit