1. Introduction
I am an independent French developer with a passion for finance.
Trader for years, I started developing trading algorithms a while ago.
Now I am a developer specialized in algorithm conception on MQL5.
I have created my own tools and indicators to stand out from everything else on the market today. I am always trying to create something new.
Welcome to my guide for the expert advisor Sun (and Golden Tree).
- Sun (EURUSD): https://www.mql5.com/en/market/product/75070
- Golden Tree (XAUUSD): https://www.mql5.com/en/market/product/76681
Sun is a major upgrade from my old Sun AI robot, almost everything is new. It has been built and validated on real tick data over 10 years on two brokers (a test broker and ICMarkets). So let's start from scratch.
Sun is an EA designed for specific pairs, so it is not recommended to use it elsewhere. The timeframe has no real impact on live trading, but in order to have better test quality, the recommended timeframe is M1. Each Sun pair uses the same engine but a different set of patterns, which makes each EA totally different from the others.
This EA requires a Hedge account (it does not work on a netting account), leverage 1:500 recommended.
This EA needs at least 1 GB of free RAM per pair to work properly (a lot of indicators are used).
I do not recommend Sun for beginners. Be sure to understand how MT5 and this EA work before going live.
Check the MetaTrader 5 user guide here: https://www.metatrader5.com/en/terminal/help
Sun uses homemade indicators that differentiate it from anything else on the market. Its trading style makes it unique.
It is a risky scalper, which uses grid and martingale in an aggressive way. The robot is composed of independent strategies that have lasted several years on the specific pair. As each cycle is independent, it is possible to have several at the same time. You can therefore define a maximum number of simultaneous cycles.
What is a cycle? A cycle is a strategy with a signal, an entry and an exit.
Each cycle is independent, it has multiple orders, its own signal, its own TP and its own SL.
For small traders, it is even possible to define a number of active cycles based on the current balance.
In order to manage risk more simply, you can activate an integrated SL for each pattern, or use an SL based on account equity.
But be careful, for a 0.01 initial lot, one cycle SL is equivalent to about 100$. If you start with 100$, you might lose everything.
Before continuing, I want to remind you that Sun's backtests look good because they use patterns that have worked in the past. It is important to understand that backtests are only used to validate the veracity of the strategy. Nobody will ever give you an EA with a 100% win rate on MQL5. Otherwise they would be billionaires in a few months and there would be no point in selling it. I am not selling a 100% win rate EA, I am selling my research time, my experience and my tools to achieve a good win rate ratio. Obviously the EA will hit SL, especially if market conditions change. If you want to look at the live performance, you should refer to the demo signals, not the backtest. When Sun hits a few cycle SL, I update the patterns that were unsuccessful in order to keep the EA in line with market changes. It means that a past cycle SL will NOT be in your backtest, but you will see it in my live signals. This is not a trick to hide past results, it is my way to keep the algo up to date. All my signals are public and you can subscribe for free with a demo account. Keep in mind that Sun is a high risk robot.
You need to take a step back and consider that the goal of a trading bot is not to return a crazy profit. Remember that the best fund in the world has an annualized return of 66%, and this performance costs millions per year. Do not expect to get more than that without some risk on the table.
I also remind you that we live in extremely volatile times. Interest rate changes, shortages, geopolitics. These factors have a strong impact on the market. Manage your risk carefully.
2. Inputs
Let's see the input list.
Sun Settings
- Initial lot: set the initial lot for a cycle.
- Maximum number of active cycle: set the strict maximum of simultaneous active cycles.
- Use cycle stoploss: if active, this uses the SL built into the cycle. Otherwise the EA keeps opening orders.
- Add infinite orders if cycle SL is off: only works if "Use cycle stoploss" is off. It allows the EA to override the pattern max orders and keep adding orders until the TP is reached. If false, the EA will not add any more order on the grid and waits until the cycle is closed manually or reaches the TP.
- Override cycle max order [0=off]: each pattern has its own max order, but you can change it. 0 keeps the default value. It is recommended to keep this value at 0.
- The EA can start a buy cycle: allow the EA to open a new buy cycle. If false, the EA will not open a new buy cycle but will still grid the active buy cycle. This parameter should stay true.
- The EA can start a sell cycle: allow the EA to open a new sell cycle. If false, the EA will not open a new sell cycle but will still grid the active sell cycle. This parameter should stay true.
Autolot Settings
- Balance per initial lot [0=off]: defines the initial lot of a cycle based on the balance. Set to 0 to disable this feature.
For example, if Initial lot = 0.01, Balance per initial lot = 1000, Maximum initial lot = 0.25.
| Initial Lot | Balance per initial lot | Current Balance | Current Initial Lot |
|---|---|---|---|
| 0.01 | 1000 | 750 | 0.01 |
| 0.01 | 1000 | 1000 | 0.01 |
| 0.01 | 1000 | 1550 | 0.01 |
| 0.01 | 1000 | 2000 | 0.02 |
| 0.01 | 1000 | 2550 | 0.02 |
| 0.01 | 1000 | 3000 | 0.03 |
| 0.01 | 1000 | 7550 | 0.07 |
| 0.01 | 1000 | 25050 | 0.25 |
| 0.01 | 1000 | 32000 | 0.25 |
- Balance per cycle [0=off]: set the maximum active cycles based on the balance. Set to 0 to disable this feature.
For example, if Balance per cycle = 200, Maximum number of active cycle = 10.
| Balance per cycle | Current Balance | Current Active Strategy |
|---|---|---|
| 200 | 195 | 1 |
| 200 | 200 | 1 |
| 200 | 355 | 1 |
| 200 | 400 | 2 |
| 200 | 455 | 2 |
| 200 | 800 | 4 |
| 200 | 1955 | 9 |
| 200 | 2025 | 10 |
| 200 | 4337 | 10 |
- Maximum initial lot: defines the maximum initial lot of a cycle.
Global Settings
- Maximum spread allowed [0=off]: set the maximum spread allowed to open a cycle. Set to 0 to disable this feature.
- Account type: set your account type so the EA can calculate the TPs better.
| ECN | Low spread and commission (raw) |
| Standard | Larger spread and no commission |
- Display informations on chart: show the interactive panel on the chart. Disabling it falls back to a simple text comment and slightly speeds up the tests. See section 3 for the panel.
- Sun chart color: change the color of the chart in a more sunny way.
- Magic Number: set the magic number. The magic number is very important. The EA only interacts with the orders that have this magic number. You have to use a different magic number than other active EA. I recommend to always use the same magic number for Sun.
- Order filling type: you can change the order filling type, more info here. It is recommended to use "auto".
Security Settings
- Equity TP: Stop the EA if the equity exceeds this limit [0=off]: set an equity TP. Set to 0 to disable this feature. For example, if you start with a 300 usd balance, you can set a target of 500 usd. If the equity goes above 500 usd, the EA closes all orders and stops trading until you change this limit or withdraw your balance.
- Equity SL: Stop the EA if the equity falls below this limit [0=off]: set an equity SL. Set to 0 to disable this feature. For example, if you start with a 300 usd balance, you can set a stoploss of 100 usd. If the equity goes below 100 usd, the EA closes all orders and stops trading until you change this limit or adjust your balance.
- Drawdown SL: Close orders if the drawdown goes above this limit [0=off]: set a drawdown limit in percentage. The value must be set between 0 and 100. Set to 0 to disable this feature. For example, if you set a drawdown SL to 50% and you have a balance of 1000$, when your equity goes below 500$ the drawdown is above the limit, all orders are closed and the EA keeps trading. Note: the drawdown is the difference in % between your balance and your equity. It is not based on your previous balance, it uses the strict balance at the time of the calculation.
- Send security push notifications: send a notification on your phone if a security is triggered. You need your device connected using this guide: https://www.metatrader5.com/en/mobile-trading/iphone/help/settings_messages#notification_setup
News Filter
- News filter on: pause trading around high impact economic news. Off by default. You can use it alone or together with the FTMO mode, and you can also toggle it live from the panel.
- News source: "Auto (FF + MQL5)" uses ForexFactory first and falls back to the MT5 calendar. "ForexFactory only" and "MQL5 only" force one source. ForexFactory needs you to whitelist https://nfs.faireconomy.media in Tools, Options, Expert Advisors, Allow WebRequest.
- Watched currencies: for example EUR,USD. Leave it empty to take the currencies from the symbol (EURUSD takes EUR and USD, XAUUSD takes USD).
- Action on news: "Hold positions" freezes new and added orders and removes the server TP and SL so nothing closes inside the window. "Flatten before" closes the symbol cycles before the window.
- Freeze before (min) and Freeze after (min): the safety window around each event, 5 and 5 by default. It is a bit wider than the strict news rule on purpose.
- Include Low impact, Include Medium impact, Include High impact: which importance levels you want to filter. By default only High is on.
- Time offset (min): a manual nudge if your broker clock differs from the calendar.
FTMO Mode
- FTMO mode: Off by default, or 1-step (daily 3%, max 10% trailing) or 2-step (daily 5%, max 10% static). It enforces the prop firm loss limits so the EA stops before a breach.
- Initial capital: 0 uses the starting balance. The limits are computed from this value.
- Daily reset: "Auto" aligns the daily loss reset to 00:00 Prague time, no matter your broker server time. "Manual" lets you set the reset hour yourself.
- Reset hour (manual): the server hour of the Prague midnight, only used if Daily reset is Manual.
GUI
- Show panel: show the interactive on-chart panel (on by default). Off uses a simple text comment.
- Panel X and Panel Y: the panel position offset.
Chart visuals
- Directional bars: color the candles by direction in the Sun palette.
- Trade lines: draw the average entry and take profit line of each active cycle.
- News zones: shade the news freeze windows on the chart.
3. Interactive panel
Sun now comes with an interactive panel on the chart. A status dot shows if the EA is allowed to trade, and a small button folds the panel to its title bar when you do not need it.
Controls, always visible:
- Pause / Resume: stop opening new cycles. The open cycles are still managed (grid and TP).
- Close all: close every Sun order, with a confirmation click to avoid a mistake.
- Buy: ON/OFF and Sell: ON/OFF: enable or disable a direction live.
- News filter: ON/OFF: turn the news filter on or off without opening the inputs.
Tabs:
- Account: server, time, leverage, balance, equity, floating P/L, margin and spread.
- Settings: the two trading switches, the cycle settings, the security limits, and the FTMO block when the mode is on.
- News: the active source, a countdown to the next event, and the day restricted events.
- Orders: the open orders per side with their P/L, and the active cycles versus the max.
- History: the realized P/L today, this week and total, the number of trades and the win rate.
One thing to know about the two trading switches. There is the MT5 AutoTrading button in the toolbar, and there is the "Allow Algo Trading" checkbox in the EA properties. You need both on for the EA to trade. A lot of people only enable one of the two and wonder why nothing happens, so the panel shows both clearly.
4. News filter
Grid and martingale are at their weakest during high impact news. Sun can pause around economic releases. It reads the events from ForexFactory, with the MT5 calendar as a fallback, filters them to your symbol currencies and the importance you chose, and freezes the order activity inside a safety window around each event.
You have two behaviours. "Hold" keeps your open positions but freezes new and added orders, and it removes the server TP and SL so nothing closes inside the window. "Flatten before" closes the cycles of the symbol before the window. You can switch the filter on or off live from the panel and you have a countdown to the next event.
To use ForexFactory, go to Tools, Options, Expert Advisors, tick "Allow WebRequest for listed URL" and add https://nfs.faireconomy.media. If you do not, Sun automatically uses the MT5 calendar instead.
5. FTMO and prop firm mode
Prop firms are now a big part of retail trading, so Sun has a dedicated FTMO mode that respects the firm loss limits and stops the EA before a breach:
- A daily loss guard, 5% for the 2-step and 3% for the 1-step, measured on the equity.
- A maximum loss guard of 10%, a static floor for the 2-step and a trailing one for the 1-step.
- A daily reset aligned to 00:00 Prague time. It is computed independently from your broker server time, so the time offset never trips you up.
- The news pause from section 4 to respect the restricted news rule.
When a limit is hit, Sun closes everything and halts, until the next daily reset for the daily limit, or for good for the maximum loss, and it can send you a push notification.
A small but important note: keep the EA running without interruption in FTMO mode. If you restart it in the middle of the day, the daily baseline is set again on the current balance. My recommended FTMO link is here: myx.trading/ftmo.
This mode helps you respect the rules, but it does not guarantee that you pass or keep a challenge. You stay responsible for your account.
6. Updates
Sun is updated over time, adding new features and also updating the less efficient patterns.
When a new update is live, you receive a message on MQL5. I recommend to keep Sun updated.
If you have any idea for a feature to include, please let me know. I do not promise to implement it, but I will listen to you as much as possible.
7. Risks
Risk definition: a situation involving exposure to danger.
Sun uses past data to aim for a high success rate, but the outcome is not guaranteed. Always remember that the market is unpredictable.
Past performance does not guarantee future performance.
Even though the USD is a stable currency, the world we live in now can bring many surprises, especially with inflation, interest rates, wars, shortages and the risk of recession, and any important news 24/7.
It is important to remember that this is a risky expert advisor because it uses grid and martingale strategies.
It will obviously hit a cycle stoploss one day, because nobody can predict the market.
If many cycles are opened against the trend, it leads to a significant drawdown.
It is important to understand and manage your risk well.
On Sun, there are several ways to manage your risk:
- Use the equity SL to keep a safety line in case of a losing scenario.
- Use the stoploss patterns to cut strategies when they go outside the bounds of the past.
- Use a number of strategies and an initial lot suitable for the balance.
- Use the drawdown security to close every order if the drawdown is too high and restart the cycles.
- Use the FTMO mode, or the equity and drawdown securities, to cap the account loss, and the news filter to avoid the most violent moves.
Based on 1:500 leverage, I recommend at the very least $200 per cycle for an initial lot of 0.01.
Remember the rules:
- N1: Only invest what you can afford to lose.
- N2: Secure your profits.
- N3: Always have a stoploss.
Note: for a 0.01 initial lot, one cycle SL is equivalent to about 100$.
If you start with 100$, you might lose everything.
If you have 10 cycles of 0.01 initial lot, you risk 10 x 1 x 100$ = 1000$.
If you have 5 cycles of 0.05 initial lot, you risk 5 x 5 x 100$ = 2500$.
8. Settings
There are many ways to manage your risk. I will summarize it all in a table.
Using 1 pair only:
| Very high risk | High risk | Medium risk | Low risk | |
|---|---|---|---|---|
| Minimum Starting balance (more risk) | 100 | 200 | 300 | 500 |
| Recommended Starting balance | 300 | 1000 | 3000 | 10000 |
| Initial lot | 0.01 | 0.01 | 0.01 | 0.01 |
| Balance per initial lot | 300 | 1000 | 3000 | 10000 |
| Balance per cycle | 100 | 200 | 300 | 500 |
| Maximum initial lot | 4 | 2 | 1 | 0.5 |
| Maximum number of active cycle | 3 | 5 | 10 | 20 |
You can adjust your risk yourself or download set files at the bottom of this blog post.
It is important to take into account the number of orders and the maximum volume allowed by your broker.
These values are based on ICMarkets properties, 200 lots maximum and 200 orders.
If you use multiple pairs on the same account, multiply the Balance per initial lot and the Balance per cycle by the number of pairs.
| Very High Risk Set | 1 pair | 2 pairs | 3 pairs | 4 pairs | 5 pairs | 6 pairs |
|---|---|---|---|---|---|---|
| Minimum Starting balance (more risk) | 100 | 200 | 300 | 400 | 500 | 600 |
| Recommended Starting balance | 300 | 600 | 900 | 1200 | 1500 | 1800 |
| Initial lot | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 |
| Balance per initial lot | 300 | 600 | 900 | 1200 | 1500 | 1800 |
| Balance per cycle | 100 | 200 | 300 | 400 | 500 | 600 |
| Maximum initial lot | 4 | 2 | 1.25 | 1 | 0.8 | 0.65 |
| Maximum number of active cycle | 3 | 3 | 3 | 3 | 3 | 3 |
| High Risk Set | 1 pair | 2 pairs | 3 pairs | 4 pairs | 5 pairs | 6 pairs |
|---|---|---|---|---|---|---|
| Minimum Starting balance (more risk) | 200 | 400 | 600 | 800 | 1000 | 1200 |
| Recommended Starting balance | 1000 | 2000 | 3000 | 4000 | 5000 | 6000 |
| Initial lot | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 |
| Balance per initial lot | 1000 | 2000 | 3000 | 4000 | 5000 | 6000 |
| Balance per cycle | 200 | 400 | 600 | 800 | 1000 | 1200 |
| Maximum initial lot | 2 | 1 | 0.75 | 0.5 | 0.4 | 0.3 |
| Maximum number of active cycle | 5 | 5 | 5 | 5 | 5 | 5 |
| Medium Risk Set | 1 pair | 2 pairs | 3 pairs | 4 pairs | 5 pairs | 6 pairs |
|---|---|---|---|---|---|---|
| Minimum Starting balance (more risk) | 300 | 600 | 900 | 1200 | 1500 | 1800 |
| Recommended Starting balance | 3000 | 6000 | 9000 | 12000 | 15000 | 18000 |
| Initial lot | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 |
| Balance per initial lot | 3000 | 6000 | 9000 | 12000 | 15000 | 18000 |
| Balance per cycle | 300 | 600 | 900 | 1200 | 1500 | 1800 |
| Maximum initial lot | 1 | 0.5 | 0.3 | 0.25 | 0.2 | 0.15 |
| Maximum number of active cycle | 10 | 10 | 10 | 10 | 8 | 6 |
| Low Risk Set | 1 pair | 2 pairs | 3 pairs | 4 pairs | 5 pairs | 6 pairs |
|---|---|---|---|---|---|---|
| Minimum Starting balance (more risk) | 500 | 1000 | 1500 | 2000 | 2500 | 3000 |
| Recommended Starting balance | 10000 | 20000 | 30000 | 40000 | 50000 | 60000 |
| Initial lot | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 |
| Balance per initial lot | 10000 | 20000 | 30000 | 40000 | 50000 | 60000 |
| Balance per cycle | 500 | 1000 | 1500 | 2000 | 2500 | 3000 |
| Maximum initial lot | 0.5 | 0.25 | 0.15 | 0.12 | 0.1 | 0.08 |
| Maximum number of active cycle | 20 | 20 | 13 | 10 | 8 | 6 |
Do not forget to adapt the max spread for each pair.
9. Broker
Recommended:
- Broker: myx.trading/broker
- Cashback: myx.trading/cashback
10. VPS
Recommended:
- VPS: myx.trading/vps
11. Bug and errors
If you think you have an error or an issue with Sun, please send me a report in a private message.
I need at least a screenshot of your chart and your orders (with the comment and magic number displayed).
I also need your journal and your expert log.
With all this information I might be able to help you fast.
If you do not have trades, check this step by step:
- Make sure your MT5 is running 24/7.
- Check that auto trading is enabled. Remember you need both the MT5 AutoTrading button and the EA "Allow Algo Trading" checkbox.
- Check if you have trades on the strategy tester with the same settings. If you do not, change the filling type and retry until you find the right one.
- Check the spread filter.
- Check the VPS journal log to see if there is an error.
- If you are using a rental, check that your new license is activated on your MT5.
- Wait at least 1 day to give it time to find a signal.
12. FAQ (Frequently Asked Questions)
Feel free to send me your question in a private message, or in the comment section below.
1. You wrote "at least 1 GB free RAM". How do I check it? Does it mean a 1 GB RAM VPS can only run 1 chart? Also, how do I check if the EA is not working properly?
Hi, you should have the information on your VPS. Otherwise check the task manager as shown in this guide https://www.freecodecamp.org/news/how-to-open-task-manager-in-windows-10/. Yes, 1 GB can run 1 chart. If the EA does not work, you will see a message in your journal log with a memory exception. I took 1 GB to be safe, in reality it is a little less.
2. Hello, if I use 4 Sun pairs, do I use the low risk set or a custom set, and do I have to change the magic number?
Hi, it is up to you and it depends if you use them on the same account or not. You can check the set for my 4 pairs signal in the description here: https://www.mql5.com/en/signals/1588933#!tab=description. You do not need to change the magic on a different pair, but it is a good practice to do it.
3. Hello Arthur, what is the difference between your Sun EA for the different pairs? Is there one EA for all pairs?
Hello, each Sun EA has the same engine but uses different strategies based on what worked best for each pair. There is no single EA with all pairs.
4. Is Sun a long term project? Will you keep optimizing it in the future?
Yes, Sun is a long term project, I will keep updating it.
5. Hello, is running multiple Sun EA on the same account more profitable than only one? For example EURUSD with USDCHF, or EURUSD with USDJPY.
Hi, it is the same. It just depends on the settings you apply to each one.
6. Hi Arthur, a couple of questions. A lower number of cycles equals less risk, correct, because there are fewer trades? But why does your high risk set have fewer cycles?
Hi. Not really. If you adapt the autolot and the balance per cycle, it is less risky, because with only 1 cycle, if it hits SL you are stuck and you lose all the potential. If you split it into 10 cycles, maybe 1 or 2 will SL but probably not all 10, and once the first cycle is open, the others can still trade and you are not stuck with one cycle. That means more trades and fewer SL.
7. I noticed you had backtests from 2017. Why, when I tried a backtest from 2016 with 100% quality, were the results so bad? Could you explain?
Hi, it is because it is not optimized on that period. Sun focuses on the last 5 years to find its patterns.
8. Any plans to reduce the price of Sun?
Hi, no special offer is planned at this time. If the purchase price is too high for your account, the rental price lets you invest less and reinvest the profits the following month.
9. Could you tell me what the "SL built into the cycle" is (the bool "Use cycle stoploss")? Is it the DD SL or the Equity SL that you can set, or an internal SL based on your algo? How much would I expect if it is set to true and the SL is triggered?
Hi, "Use cycle stoploss" closes the cycle if it crosses a specific value. It is an internal EA SL, different for each pattern based on what worked on past data. I would say very roughly the SL is around 100$ per cycle per SL, but it can be more or less. The DD SL, the Equity SL and the Equity TP are other securities based only on your equity and balance.
10. If there are already 10 active cycles at the moment, will it cause an issue if I change the setting to 5 cycles?
Hi, no, the 10 cycles stay open but no new cycle opens until you go back below 5.
11. I have a question about the SL in the cycle. When does a cycle SL close? I feel safer when I know that a cycle closes itself before crashing my account.
Hi, I will use an example. Let's say a cycle has 5 max orders and a distance of about 250 points between orders. If the cycle goes 250 points away from the fifth order by the end of the M1 candle, the cycle closes all its orders. If you are worried about your account, you can also set the equity SL to keep a minimum equity.
12. I tried an old version of your EA with much worse results than the new version, and that makes me suspicious. Why is this?
Hi, the patterns are updated regularly. When a pattern hits a SL, it is replaced in the next update. The idea is to find patterns that worked in the past to aim for a high success rate. But a pattern will fail one day, always. So old patterns are replaced with new ones and, hopefully, we keep a positive win rate in the future. If I could predict a 100% win rate EA on a live account, I would be a billionaire and I would not sell it on MQL5.
13. I do not have any order on the strategy tester or on a live account. Is it normal?
Hi, if you do not have orders on the strategy tester, try changing the "Order filling type" from auto to one of the other values.
13. Pricing
The price of Sun is justified by the cost of the pattern research (hardware and electricity) and the time spent on the research (several weeks per pair).
It also includes the cost of keeping the patterns up to date as they become less efficient over time.
The price does not guarantee future performance.
14. Conclusion
Sun's algorithm is the result of years of work. Each new pair added represents several weeks of computing time.
If you like this kind of AI product, do not hesitate to leave a review.
If you have a question, feel free to send me a private message on MQL5 or join my discord https://myx.trading/discord.
Have a good day,
Arthur
RISKS ASSOCIATED WITH FOREX TRADING
Trading foreign exchange ("Forex") on margin carries a high level of risk and is not suitable for all investors. Past performance is not an indication of future results. Here too, the high degree of leverage can work against you as well as for you. Before you decide to invest in foreign exchange, you should carefully assess your investment objectives, your experience, your financial means and your willingness to take risks. There is a possibility that you lose your initial investment in part or in full. So you should not invest money that you cannot afford to lose entirely.



