Create and Test Forex Strategies
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| eas-guide:export-expert-advisor [2021/01/11 12:17] – ilan | eas-guide:export-expert-advisor [2026/02/15 08:28] (current) – [How to export an Expert Advisor] Miroslav Popov | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== How to export an Expert Advisor ===== | ===== How to export an Expert Advisor ===== | ||
| - | When you open a strategy in the **Editor** you can export it as an Expert Advisor. To do this, click on the **Export** button in the toolbar. | + | When you open a strategy in the **Editor**, you can export it as an Expert Advisor. To do it, click the **Expert Advisor** button in the toolbar, and a drop-down menu will give you options to export Expert Advisor for MetaTrader 4 and MetaTrader 5. |
| + | |||
| + | {{ : | ||
| - | {{ : | ||
| There are several Export options: | There are several Export options: | ||
| Line 11: | Line 12: | ||
| * **Expert Advisor for MT4** - exports an Expert Advisor for MetaTrader 4; | * **Expert Advisor for MT4** - exports an Expert Advisor for MetaTrader 4; | ||
| * **Expert Advisor for MT5** - exports an Expert Advisor for MetaTrader 5; | * **Expert Advisor for MT5** - exports an Expert Advisor for MetaTrader 5; | ||
| + | * **Expert Advisor Plus for MT5** - exports an Advanced Expert Advisor for MT5 ([[expert-advisors-plus]]); | ||
| - | The exported Expert Advisor is 100% native MQL code and doesn' | + | The exported Expert Advisor is 100% native MQL code and doesn' |
| - | + | ||
| - | {{ youtube> | + | |
| + | {{youtube> | ||
| Line 26: | Line 26: | ||
| - Go to **File > Open Data Folder** | - Go to **File > Open Data Folder** | ||
| - | - From the folder list open the **MQL4** folder | + | - From the folder list, open the **MQL4** folder |
| - Open the **Experts** folder | - Open the **Experts** folder | ||
| - Paste the Expert Advisor file | - Paste the Expert Advisor file | ||
| - | - Go back to MetaTrater | + | - Go back to MetaTrader |
| - Go to **Navigator** (if it's not open, open if from **View > Navigator**) | - Go to **Navigator** (if it's not open, open if from **View > Navigator**) | ||
| - In the **Navigator** box right-click. Click **Refresh** from the menu. Your expert should appear in the **Navigator** under **Expert Advisors**. | - In the **Navigator** box right-click. Click **Refresh** from the menu. Your expert should appear in the **Navigator** under **Expert Advisors**. | ||
| - Open the chart you want to place your Expert Advisor on | - Open the chart you want to place your Expert Advisor on | ||
| - | - To attach the Expert Advisor to the chart drag-and-drop it from the **Navigator** box to the chart, or simply | + | - To attach the Expert Advisor to the chart, drag-and-drop it from the **Navigator** box to the chart or double-click on the Expert Advisor |
| <WRAP center round tip 60%> | <WRAP center round tip 60%> | ||
| **Using different Magic Numbers** | **Using different Magic Numbers** | ||
| - | When you are trading several Experts on the same symbol they will need to differentiate between each others' | + | When trading several Experts on the same symbol, they must differentiate between each others' |
| </ | </ | ||
| Line 45: | Line 45: | ||
| - Go to **File > Open Data Folder** | - Go to **File > Open Data Folder** | ||
| - | - From the folder list open the **MQL5** folder | + | - From the folder list, open the **MQL5** folder |
| - Open the **Experts** folder | - Open the **Experts** folder | ||
| - Paste the Expert Advisor file | - Paste the Expert Advisor file | ||
| - | - Go back to MetaTrater | + | - Go back to MetaTrader |
| - Go to **Navigator** (if it's not open, open if from **View > Navigator**) | - Go to **Navigator** (if it's not open, open if from **View > Navigator**) | ||
| - In the **Navigator** box right-click. click **Refresh** from the menu. Your expert should appear in the **Navigator** under **Expert Advisors**. | - In the **Navigator** box right-click. click **Refresh** from the menu. Your expert should appear in the **Navigator** under **Expert Advisors**. | ||
| - | - In the **Navigator** right-click on the Expert Advisor name. From the menu choose **Modify** | + | - In the **Navigator**, right-click on the Expert Advisor name. From the menu, choose **Modify** |
| - | - A code editor will open. From the top menu of the window click **Compile** | + | - A code editor will open. From the top menu of the window, click **Compile** |
| - Close the code editor. | - Close the code editor. | ||
| - | - To attach the Expert Advisor to the chart drag-and-drop it from the **Navigator** box to the chart. | + | - To attach the Expert Advisor to the chart, drag and drop it from the **Navigator** box to the chart. |
| Line 62: | Line 62: | ||
| <WRAP center round important 60%> | <WRAP center round important 60%> | ||
| - | The solution | + | The solution would be an MT5 Hedging account, which can trade several experts per symbol. If using this feature, set a different Magic Number for each Expert Advisor. |
| </ | </ | ||
| Line 69: | Line 69: | ||
| ==== How to Run an Expert Advisor ==== | ==== How to Run an Expert Advisor ==== | ||
| - | When you drag and drop the Expert onto the chart a dialogue window will open. You you can review the Expert Advisor options in the **Inputs** tab. | + | A dialogue window will open when you drag and drop the Expert onto the chart. You can review the Expert Advisor options in the **Inputs** tab. |
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | === Options === | ||
| + | |||
| + | * **Magic Number** - a number MetaTrader uses to distinguish which position each expert belongs to. | ||
| + | |||
| + | * **Max spread protection (points)** - possibility to prevent trading on a high spread. The default value is zero, which means the protection is off. Set the desired value in points to engage the protection. For example, if you set 10, the Expert will open new positions only if the current spread is equal to or lower than 10. The Expert may try several times to execute the order. The Max spread protection does not affect the exit orders. | ||
| + | |||
| + | * **Min equity protection (currency)** - a protection which closes the current position and removes the Expert from the MetaTrader chart if the current Equity drops below the given number. The default value is zero, which indicates that the protection is off. Set the desired number in currency to engage the protection. | ||
| + | |||
| + | ==== Backtest an Expert Advisor in the MetaTrader tester ==== | ||
| - | {{ : | ||
| You can test the Experts in the MetaTrader **Strategy tester** (**View > Strategy Tester**). | You can test the Experts in the MetaTrader **Strategy tester** (**View > Strategy Tester**). | ||
| - | {{ : | + | {{: |
| <WRAP center round tip 60%> | <WRAP center round tip 60%> | ||
| - | You should get the same result in MetaTrader test as in EA Studio. If there is a a discrepancy check if you are using **the same data, spreads and commissions**. If there is still a discrepancy, | + | You should get the same result in the MetaTrader test as in EA Studio. If there is a discrepancy, check if you are using **the same data, spreads and commissions**. If there is still a discrepancy, |
| </ | </ | ||
| - | |||
| - | ~~DISQUS~~ | ||