close_position.md•505 B
# 🔒 close_position
**Signature:**
```python
def close_position(connection, id: Union[str, int])
```
## What does it do? 🛑
Closes a specific position by its ID. Ensures you can exit trades when you need to!
## Parameters
- **connection**: MetaTrader 5 connection object
- **id**: The unique position identifier
## Returns
- A dictionary with error flag, message, and closed position data (if successful)
## Fun Fact 🏁
Perfect for risk management—close those positions before they get wild!