Check if Previous Order is Closed - page 2

 

1. **Track Existing Orders:**
   - Use blocks that can track the status of existing orders.  this typically involves using blocks that check if a buy or sell order is currently open.

2. **Place New Order:**
   - Use blocks to define conditions for opening a new order, such as indicators or specific price actions.

3. **Close Existing Order:**
   - When a new order is triggered (buy or sell), immediately close the opposite order if it exists.

### Step-by-Step Example:

Here’s how you can set it up in

- **Track Existing Buy and Sell Orders:**
  - Use blocks that check if a buy order is currently open (`Is Buy Order Open` block).
  - Similarly, use a block that checks if a sell order is open (`Is Sell Order Open` block).

- **Place New Order:**
  - Create conditions for placing a new buy order using indicators or price conditions.
  - Connect these conditions to a block that opens a buy order (`Buy` block).
  - Alternatively, create conditions for placing a new sell order and connect them to a block that opens a sell order (`Sell` block).

- **Close Existing Order on New Order Placement:**
  - Use conditional blocks that check if a buy order is open when a new sell order is triggered (or vice versa).
  - Connect these conditional blocks to blocks that close the opposite order (`Close Buy` or `Close Sell` blocks).

### Example Workflow:

- **Buy Order Logic:**
  - If conditions for a new buy order are met:
    - Check if there is an existing sell order open (`Is Sell Order Open`).
    - If a sell order is open, connect this condition to a `Close Sell` block to close the sell order.
    - Then connect the conditions for opening a buy order to the `Buy` block to open a new buy order.

- **Sell Order Logic:**
  - If conditions for a new sell order are met:
    - Check if there is an existing buy order open (`Is Buy Order Open`).
    - If a buy order is open, connect this condition to a `Close Buy` block to close the buy order.
    - Then connect the conditions for opening a sell order to the `Sell` block to open a new sell order.

By setting up these blocks and connections in

, you create an EA that automatically manages closing existing orders when new orders are placed based on your specified conditions. Adjust parameters and thoroughly test your strategy before deploying it in a live trading environment.