Certainly! I'd be happy to help you create your trading robot using FXDreema for MetaTrader 5 (MT5). I'll provide detailed, step-by-step instructions so that even if you're new to FXDreema, you can follow along easily.
Overview of the Trading Robot Requirements
Before we begin, let's summarize the robot's functionality:
- Trade Entry:
- Buy Trade: Execute when the price moves up by three pips from a reference point.
- Sell Trade: Execute when the price moves down by three pips from a reference point.
- Trade Management:
- Only one trade should be open at any time.
- Lot size for all trades is 0.1 lots.
- No stop loss for initial trades.
- Reversal Trades:
- If a buy trade is open and the price reverses down by six pips, close the buy trade and open a sell trade with a take profit of three pips.
- If a sell trade is open and the price reverses up by six pips, close the sell trade and open a buy trade with a take profit of three pips.
Getting Started with FXDreema
Step 1: Access FXDreema
- Open your web browser and go to FXDreema.
- Create an account if you haven't already. This will allow you to save and export your projects.
- Log in to your FXDreema account.
Step 2: Create a New Project
- Once logged in, click on "My Projects" in the top menu.
- Click on the "Create a new project" button.
- In the popup window:
- Project name: Enter a name (e.g.,
Three_Pip_Movement_EA).
- Based on: Select "Metatrader 5".
- Click "Create".
Building the EA Logic
We'll be working mostly in the "On Tick" tab, which processes actions every time a new price tick is received.
Understanding the Interface
- Blocks List (Left Side): Contains all the blocks you can use.
- Workspace (Center): Where you place and connect your blocks.
- Properties Panel (Right Side): Shows settings for the selected block.
Step 3: Setting Up Variables
Variables make it easy to adjust parameters without changing the code.
-
Click on the "Variables" button at the top.
-
Create the following variables:
| Name | Type | Default Value | Description |
|---|
| LotSize | double | 0.1 | Lot size for each trade |
| TradeOpened | bool | false | To track if a trade is open |
| EntryPrice | double | 0.0 | Price at which the trade was opened |
| InitialPrice | double | 0.0 | Reference price when EA starts |
| TakeProfitPips | int | 3 | Take profit in pips for reversal trades |
| EntryPips | int | 3 | Price movement in pips to trigger entry |
| ReversePips | int | 6 | Price reversal in pips to trigger reversal trade |
-
Click "OK" to save the variables.
Step 4: Storing the Initial Price
We need a reference point to measure the price movement from.
- Go to the "on Init" tab (found at the top).
- Drag the "Modify Variables" block from the "Variables" category into the workspace.
- Click on the block to edit its properties:
- Variable: Select
InitialPrice.
- Operator:
=
- Value: Enter
Ask (the current market ask price).
- This sets
InitialPrice to the current ask price when the EA starts.
Step 5: Setting Up the "On Tick" Logic
Go to the "on Tick" tab to build the main logic.
Part A: Checking for Existing Trades
We want to open a new trade only if no trade is currently open.
- From the "Trade Operations" category, drag the "Check trading conditions" block into the workspace.
- Click on the block to edit its properties:
- Under "Condition", select "No positions/order".
- This ensures that the following actions only occur if there are no open trades.
Part B: Checking Price Movement
We need to check if the price has moved up or down by three pips from InitialPrice.
-
For Price Moving Up by Three Pips:
- From "Condition", drag a "Condition" block below the "No positions/order" block and connect them.
- In the condition block properties:
- Left Operand:
- Type:
Double value
- Value:
Ask (current ask price)
- Operator:
> (greater than)
- Right Operand:
- Type:
Double value
- Value:
InitialPrice + (EntryPips * _Point)
- Note:
_Point is a predefined variable representing the size of a pip.
-
For Price Moving Down by Three Pips:
- From "Condition", drag another "Condition" block below the "No positions/order" block but not connected to the previous condition (create a separate chain).
- In the condition block properties:
- Left Operand:
- Type:
Double value
- Value:
Bid (current bid price)
- Operator:
< (less than)
- Right Operand:
- Type:
Double value
- Value:
InitialPrice - (EntryPips * _Point)
Part C: Opening Trades Based on Price Movement
-
For Opening a Buy Trade:
-
Under the Condition block that checks for price moving up, drag a "Buy now" block from "Buy & Sell".
-
Set the Lot size to LotSize.
-
Leave Stop loss and Take profit fields empty (since we don't have initial SL or TP).
-
Remember to record the entry price and set TradeOpened to true:
- Under the "Buy now" block, add a "Modify Variables" block.
- Set
EntryPrice = Ask.
- Add another "Modify Variables" block to set
TradeOpened = true.
-
For Opening a Sell Trade:
-
Under the Condition block that checks for price moving down, drag a "Sell now" block.
-
Set the Lot size to LotSize.
-
Leave Stop loss and Take profit fields empty.
-
Record the entry price and set TradeOpened to true:
- Under the "Sell now" block, add a "Modify Variables" block.
- Set
EntryPrice = Bid.
- Add another "Modify Variables" block to set
TradeOpened = true.
Part D: Handling Reversals
We need to monitor open trades for price reversals.
-
Check if a Trade is Open:
- From "Condition", drag a new "Condition" block into the workspace (not connected to previous blocks).
- Condition:
- Left Operand:
TradeOpened (variable)
- Operator:
== (equal to)
- Right Operand:
true
- This block will check if a trade is currently open.
-
Determine Trade Type:
- Under the "TradeOpened == true" condition block, add another "Condition" block to determine if the open trade is a buy or sell.
- Check for Buy Trade:
- Left Operand:
Position Type of Trade #1 (from "Positions" category)
- Operator:
==
- Right Operand:
Buy
- Check for Sell Trade:
- Create a separate "Condition" block under "TradeOpened == true" to check for a sell trade.
- Left Operand:
Position Type of Trade #1
- Operator:
==
- Right Operand:
Sell
-
Handling Reversal for Buy Trade:
- Under the "Position Type == Buy" condition block, add another "Condition" block to check for price reversal.
- Condition:
- Left Operand:
Bid (current bid price)
- Operator:
< (less than)
- Right Operand:
EntryPrice - (ReversePips * _Point)
- Actions upon Reversal:
- Close the Buy Trade:
- Under the reversal condition, add a "Close positions" block from "Trade Operations".
- Set it to close "Buy positions".
Part E: Resetting After Take Profit
To handle the scenario where the reversal trade hits take profit:
-
Check for No Open Positions:
- From "Condition", drag another "Condition" block into the workspace (not connected to previous blocks).
- Condition:
- Left Operand:
Total Positions (from "Account & Positions" category)
- Operator:
==
- Right Operand:
0
- Action:
- Under this condition, add a "Modify Variables" block.
- Set
TradeOpened = false.
- Optionally, reset
EntryPrice or update InitialPrice if you want to start monitoring from the new price level.
Step 6: Connecting the Blocks
Your workspace should now have several chains of blocks. Ensure that:
- The initial trade entry checks (price movement up or down) are connected properly.
- The reversal handling chains are separated and correctly check for open trades and reversals.
- All blocks under each condition are connected in sequence.
- No blocks are left unconnected unless they are separate logical chains (which is acceptable in FXDreema).
Step 7: Saving and Exporting the EA
- Click on "File" in the top menu and select "Save" to save your project.
- To export your EA:
- Click on "Build" in the top menu.
- In the popup, ensure "MetaTrader 5" is selected.
- Click "Download" to get the compiled
.ex5 file.
Step 8: Installing the EA in MetaTrader 5
- Open your MT5 trading platform.
- Click on "File" > "Open Data Folder".
- Navigate to "MQL5" > "Experts".
- Copy your downloaded
.ex5 file into this folder.
- Restart MT5 or refresh the Expert Advisors list:
- In the "Navigator" window, right-click on "Expert Advisors" and select "Refresh".
Step 9: Testing the EA
Before using it on a live account, it's essential to test the EA.
Backtesting:
- In MT5, press Ctrl+R to open the Strategy Tester.
- Select your EA from the dropdown menu.
- Choose the symbol (currency pair) and timeframe you wish to test.
- Set the testing parameters (date range, deposit amount, etc.).
- Click "Start" to begin the backtest.
- Analyze the results and ensure the EA behaves as expected.
Optimization (Optional):
- You can optimize parameters like
EntryPips, ReversePips, and TakeProfitPips to find the most profitable settings.
- In the Strategy Tester, select "Optimization" and set the range for each parameter.
Step 10: Running the EA on a Demo Account
After successful backtesting:
- Open a demo account or use an existing one.
- Open the desired currency pair chart.
- Drag and drop your EA from the "Navigator" window onto the chart.
- In the EA settings window:
- Go to the "Inputs" tab to adjust any parameters if needed.
- Ensure "Allow algorithmic trading" is enabled.
- Click "OK" to apply the EA to the chart.
- Ensure the "AutoTrading" button at the top of MT5 is green.
Additional Tips
Conclusion
You've successfully created an Expert Advisor in FXDreema that meets your specified requirements. Remember to thoroughly test the EA under various market conditions to ensure it behaves as expected.
Need Further Assistance?
If you have any questions or need clarification on any of the steps, feel free to ask! I'm here to help.