### Trading Robot Specifications with Hedging System
#### Variables
1. **Order Size:**
- Defines the size of the pending order created in relation to the original position.
- The size can be chosen relative to the original position (percentage) or manually (fixed size).
- Example:
- Original position: 1 lot.
- Order size: 50% of the original position.
- Order size value: 0.5 lots.
2. **NR (Number of Repositionings):**
- Maximum number of times the system will replenish the hedge.
- Additionally, there should be an option to either leave the original position open when NR is exhausted or close it when NR is exhausted.
3. **DPO (Distance from Original Position):**
- Distance expressed as a ratio or percentage between an entry and the target (1:1, 1:2, etc.).
- Example with ratio:
- Long trade with a 1:1 ratio and a DPO of 0.25.
- The DPO is reached when the price travels or reaches the 0.25 ratio on its way to the 1:1 target.
- Example with percentage:
- Long trade with a 1:1 ratio and a DPO of 25%.
- The DPO is reached when the price travels 25% of the way to the 1:1 target.
4. **DNPO (Negative Distance from Original Position):**
- Distance against the original position, expressed as a ratio or percentage.
- Example with ratio:
- Long trade with a 1:1 ratio and a DNPO of -0.25, where 0 is the original position entry.
- The DNPO is reached when the price drops and reaches 0.25 of the stop loss.
- Example with percentage:
- Long trade with a 1:1 ratio and a DNPO of 25%.
- When we have a 25% loss (based on the total loss we would have in our original position if the price hits the stop), that will be the DNPO.
- Note: The system must be able to manage multiple manually opened positions independently.
- Note 2: The system must be compatible with other EAs.
- Note 3: When opening a manual or other EA trade, the system should have a user-selectable waiting time before it starts calculating DPO and DNPO values. This allows the user enough time to set the Stop Loss and Take Profit in the trade before the system starts managing it.
#### Functionality
- When a position is opened and its stop loss and take profit are set, the robot automatically places a pending order at the DNPO level.
- If the price drops and triggers this order, its stop loss is set to the DPO value.
- If the DNPO order hits its stop loss, another pending order is created at the same DNPO level.
- This cycle will repeat until the maximum number of repositionings (NR) selected by the user is reached.
#### Case Example 1
- **Original Position:**
- 1 lot, 1:1 ratio, entry price $100, 100 pips stop loss.
- DPO: 50% (price $150).
- DNPO: -50% (price $50).
- NR: 3.
- Order size: 100%.
- **Sequence of Operations:**
1. The price rises to $150 and then drops to $50.
2. A DNPO order of 1 lot with a stop loss at $150 is activated.
3. The price rises to $150, triggering the stop loss of the DNPO order.
4. The price drops again to $50, activating another DNPO order.
5. The price rises to $150, triggering the stop loss of the second DNPO order.
6. The price rises to $200, reaching the take profit of the original order.
#### Case Example 2
**Original Trade Parameters:**
- Position: Buy
- Size: 1 lot
- Ratio: 1:1
- Entry price: $100
- Stop loss: 100 pips
- DPO: 0.25 (25%)
- DNPO: -0.25 (25%)
- NR: 3
- Order size: 100%
**Sequence of Events:**
1. **Initial Price:** $100
2. **Price Movement:**
- Rises to $150.
- Drops to $75.
3. **Activation of DNPO Order:**
- A DNPO order of 1 lot at $75 is activated.
- DNPO order stop loss at $125 (DPO).
4. **Price rises to $125:**
- Triggers the stop loss of the DNPO order.
5. **Cycle Repeats:**
- Price drops again to $75, activating another DNPO order.
- Price rises to $125, triggering the stop loss of the DNPO order again.
6. **Price Movement Continues:**
- Price finally rises to $200, reaching the take profit of the original order.
#### Case Example 3
**Original Trade Parameters:**
- Position: Buy
- Size: 1 lot
- Ratio: 1:2
- Entry price: $100
- Stop loss: 100 pips
- DPO: 1.25 (125%)
- DNPO: -0.25 (25%)
- NR: 3
- Order size: 100%
**Sequence of Events:**
1. **Initial Price:** $100
2. **Price Movement:**
- Rises to $225.
- Drops to $75.
3. **Activation of DNPO Order:**
- A DNPO order of 1 lot at $75 is activated.
- DNPO order stop loss at $225 (DPO).
4. **Price rises to $225:**
- Triggers the stop loss of the DNPO order.
5. **Cycle Repeats:**
- Price drops again to $75, activating another DNPO order.
- Price rises to $225, triggering the stop loss of the DNPO order again.
6. **Price Movement Continues:**
- Price finally rises to $300, reaching the take profit of the original order.
These examples are for long trades, but the system should also work for short trades, as follows:
### Case Examples Adapted for Short Trades
#### Example 1
**Original Trade Parameters:**
- Position: Sell
- Size: 1 lot
- Ratio: 1:1
- Entry price: $100
- Stop loss: 100 pips
- DPO: 50% (price $50)
- DNPO: -50% (price $150)
- NR: 3
- Order size: 100%
**Sequence of Operations:**
1. **Initial Price:** $100
2. **Price Movement:**
- Drops to $50 and then rises to $150.
3. **Activation of DNPO Order:**
- A DNPO order of 1 lot at $150 is activated.
- DNPO order stop loss at $50 (DPO).
4. **Price drops to $50:**
- Triggers the stop loss of the DNPO order.
5. **Cycle Repeats:**
- Price rises again to $150, activating another DNPO order.
- Price drops to $50, triggering the stop loss of the DNPO order again.
6. **Price Movement Continues:**
- Price finally drops to $0, reaching the take profit of the original order.
#### Example 2
**Original Trade Parameters:**
- Position: Sell
- Size: 1 lot
- Ratio: 1:1
- Entry price: $100
- Stop loss: 100 pips
- DPO: 0.25 (25%)
- DNPO: -0.25 (25%)
- NR: 3
- Order size: 100%
**Sequence of Events:**
1. **Initial Price:** $100
2. **Price Movement:**
- Drops to $50.
- Rises to $125.
3. **Activation of DNPO Order:**
- A DNPO order of 1 lot at $125 is activated.
- DNPO order stop loss at $75 (DPO).
4. **Price drops to $75:**
- Triggers the stop loss of the DNPO order.
5. **Cycle Repeats:**
- Price rises again to $125, activating another DNPO order.
- Price drops to $75, triggering the stop loss of the DNPO order again.
6. **Price Movement Continues:**
- Price finally drops to $0, reaching the take profit of the original order.
#### Example 3
**Original Trade Parameters:**
- Position: Sell
- Size: 1 lot
- Ratio: 1:2
- Entry price: $500
- Stop loss: 100 pips
- DPO: 1.25 (125%)
- DNPO: -0.25 (25%)
- NR: 3
- Order size: 100%
**Sequence of Events:**
1. **Initial Price:** $500
2. **Price Movement:**
- Drops to $375
- Rises to $525
3. **Activation of DNPO Order:**
- A DNPO order of 1 lot at $525 is activated.
- DNPO order stop loss at $375 (DPO).
4. **Price drops to $375:**
- Triggers the stop loss of the DNPO order.
5. **Cycle Repeats:**
- Price rises again to $525, activating another DNPO order.
- Price drops to $375, triggering the stop loss of the DNPO order again.
6. **Price Movement Continues:**
- Price finally drops to $300, reaching the take profit of the original order.
If you have any additional questions or need further clarification, feel free to ask. Additionally, please note that the source code for the trading robot should also be provided. When the original manual order reaches its take profit, the EA should stop managing that position.
If you find the system too complex, you can copy the instructions exactly as they are here in ChatGPT, and ask any questions you have. Feel free to confirm with me if the responses you receive are correct.