Expert Advisor
// MQL4&5-code #include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006 #ifdef __MQL5__ #define Bid (SymbolInfoDouble(_Symbol, SYMBOL_BID)) #define Ask (SymbolInfoDouble(_Symbol, SYMBOL_ASK)) #endif // __MQL5__ // Idea - https://www.mql5.com/ru/code/7464 #property strict input int Shift = 3; input int Limit = 18; input double Lots = 0.1; int PriceToInteger( const double Price ) { return((int)(Price / _Point + 0.1)); } void OnTick() { static int PrevBid = PriceToInteger(Bid); static int PrevAsk = PriceToInteger(Ask); const int IntBid = PriceToInteger(Bid); const int IntAsk = PriceToInteger(Ask); const bool TradeTime = (TimeCurrent() % (24 * 60 * 60) < D'1970.01.01 23:50'); // exclude swaps if (TradeTime && (IntAsk - IntBid < Limit)) { if ((IntBid - PrevBid >= Shift)) OrderSend(_Symbol, OP_SELL, Lots, Bid, 0, 0, 0); if (PrevAsk - IntAsk >= Shift) OrderSend(_Symbol, OP_BUY, Lots, Ask, 0, 0, 0); } PrevBid = IntBid; PrevAsk = IntAsk; for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS) && ((!TradeTime) || (OrderProfit() > 0) || ((OrderType() == OP_BUY) && (PriceToInteger(OrderOpenPrice()) - IntBid >= Limit)) || ((OrderType() == OP_SELL) && (IntAsk - PriceToInteger(OrderOpenPrice()) >= Limit)))) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0); }
The results
MT4 report
Symbol | EURUSD (Euro vs US Dollar) | ||||
Period | 1 Minute (M1) 2017.04.10 00:00 - 2017.04.14 20:58 (2017.04.10 - 2017.04.16) | ||||
Model | All ticks (most accurate method based on all smallest available timeframes) | ||||
Parameters | Shift=3; Limit=18; Lots=0.1; | ||||
Bars in history | 7292 | Modelled ticks | 1865515 | Modeling quality | 99.00% |
Chart mismatch errors | 0 | ||||
Initial deposit | 100000.00 | Spread | Variable | ||
Net profit | -10863.90 | Total profit | 2528.70 | Total loss | -13392.60 |
Profitability | 0.19 | Expected payoff | -0.49 | ||
Absolute drawdown | 10864.70 | Maximum drawdown | 10864.70 (10.86%) | Relative drawdown | 10.86% (10864.70) |
Total trades | 21954 | Short positions (% win) | 12016 (68.60%) | Long positions (% win) | 9938 (67.03%) |
Profitable trades (% of all) | 14904 (67.89%) | Loss trades (% of all) | 7050 (32.11%) | ||
Largest | profitable trade | 3.00 | losing transaction | -4.40 | |
Average | profitable deal | 0.17 | losing trade | -1.90 | |
Maximum number | continuous wins (profit) | 155 (46.60) | Continuous losses (loss) | 115 (-210.10) | |
Max. | continuous profits (number of wins) | 46.60 (155) | continuous loss (number of losses) | -210.10 (115) | |
Average | continuous winnings | 5 | continuous loss | 2 |
MT5 Report
Strategy Tester report | ||||||||||||
Alpari-MT5 (Build 1596) | ||||||||||||
Settings | ||||||||||||
Expert Advisor: | Lucky | |||||||||||
Symbol: | EURUSD | |||||||||||
Period: | M1 (2017.04.10 - 2017.04.16) | |||||||||||
Parameters: | Shift=3 | |||||||||||
Limit=18 | ||||||||||||
Lots=0.1 | ||||||||||||
Broker: | Alpari International Limited | |||||||||||
Currency: | USD | |||||||||||
Initial deposit: | 100 000.00 | |||||||||||
Leverage: | 1:100 | |||||||||||
Backtest | ||||||||||||
Story quality: | n/a | |||||||||||
Bars: | 7192 | Tiki: | 1865415 | Characters: | 1 | |||||||
Net profit: | -10 863.90 | Absolute drawdown on balance sheet: | 10 863.90 | Absolute drawdown on funds: | 10 864.70 | |||||||
Total profit: | 2 528.70 | Maximum drawdown on balance: | 10 863.90 (10.86%) | Maximum drawdown of funds: | 10 864.70 (10.86%) | |||||||
Total loss: | -13 392.60 | Relative drawdown on balance sheet: | 10.86% (10 863.90) | Relative drawdown on funds: | 10.86% (10 864.70) | |||||||
Profitability: | 0.19 | Expected payoff: | -0.49 | Margin level: | 863.58% | |||||||
Recovery Factor: | -1.00 | Sharpe Ratio: | -0.50 | Z-score: | -52.22 (99.74%) | |||||||
AHPR: | 1.0000 (-0.00%) | LR Correlation: | -1.00 | OnTester Result: | 0 | |||||||
GHPR: | 1.0000 (-0.00%) | LR Standard Error: | 149.82 | |||||||||
Total trades: | 21954 | Short trades (% of winners): | 12016 (68.60%) | Long trades (% wins): | 9938 (67.03%) | |||||||
Total trades: | 43908 | Profitable trades (% of all trades): | 14904 (67.89%) | Loss trades (% of all trades) | 7050 (32.11%) | |||||||
Largest profitable trade | 3.00 | Largest losing trade | -4.40 | |||||||||
Average profitable trade: | 0.17 | Average losing trade: | -1.90 | |||||||||
Maximum number of consecutive wins (profit): | 155 (46.60) | Maximum number of continuous losses (loss): | 115 (-210.10) | |||||||||
Max. continuous profits (number of wins): | 46.60 (155) | Max. continuous loss (number of losses): | -210.10 (115) | |||||||||
Average continuous winnings: | 5 | Average Continuous Losses: | 2 |
The results are a match!
Performance
2017.05.08 01:45:42.765 EURUSD,M1: 1865415 tick events (7292 bars, 1865515 bar states) processed in 0:00:03.682 (total time 0:00:04.400)
MT5-log
2017.05.08 02:04:53.278 Core 1 EURUSD,M1: 1865415 ticks, 7192 bars generated. Test passed in 0:00:12.309 (including ticks preprocessing 0:00:00.203).
MT4-tester has managed 3 times faster than MT5-tester. If there is any doubt that the MT5-logging is caused by using a third party library, those who wish may rewrite the simple MT4-logic of this Expert Advisor in MQL5 in their own way and check the hypothesis.
HZ the MT5 tester was working much slower, until I cleaned all Bases folders by hand. The results are given with this in mind.
On Alpari-MT5-Demo server in the new build (to be released in a week) with quick access to deal history I have succeeded:
EURUSD,M1: 1865417 ticks, 7192 bars generated. Test passed in 0:00:05.578.
MT5 has a system overhead for transferring data and the task itself to an external agent process, which on small (seconds) tasks introduces a big error in comparison.
And the complexity and quality of the tester in MT5 is much higher: synchronous modeling of many instruments with millisecond accuracy, real slips/delays during scrolling of world changes and a lot of more minor functions. It's not like there's a for loop.
Slower by orders of magnitude - aren't you confused with initialization/synchronization and uploading of all data? Everything is written in logs. The files on the disk should not be touched in any case.
I recommend to put %userdata%\MetaQuotes directory (like C:\Users\%username%\AppData\Roaming\MetaQuotes) into antivirus pass. This is where the data lies and adding the antivirus to the pass dramatically improves the speed of access to the terminal and tester data.
Otherwise, they get so excited when they see metatester[64].exe running, opening network port and a lot of large data files, written by terminal and tester. Some traders' tester even manages to fall off, because antivirus does not have time to check the metatester[64].exe file even in a few seconds and the terminal is unable to access it.
the complexity and quality of the tester in MT5 is an order of magnitude higher: synchronous modelling of multiple instruments with millisecond accuracy, honest slips/delays while scrolling through world changes and a bunch of smaller features.
The MT4+TDS bundle has that too. Plus some more features that MT5 lacks... But of course there's no multicurrency.
Slower by orders of magnitude.
At first I thought that TDS deliberately slows down MT5, so I cleaned its memory. I also cleaned Bases-folders (I was running out of disk space). After that MT5 was two orders of magnitude faster for a single run (reboots didn't help before). The hypothesis about TDS-blocks could not be confirmed, however I tried. I have not had any anti-viruses on my computer.
Alpari-MT5 server is real.
ZZY ran MT4-optimizer on full execution - 14 minutes. MT5 (only one agent left) - looks like it will be many hours. Will post the total in the morning/afternoon.
Where did the slips come from?
You have something completely different in mind. Play with the Delay field in MT5 tester and you will see that it is something else entirely. Even the usual Sleep(2500) in MQL5 code, when executed in the tester, will give a delay in the code when the whole world keeps simulating. The execution delay field effectively shows how trades will execute if you put your 100ms ping to the server there.
There can't be an order of magnitude lag. And why would there be any add-ons for MT5 when it works fine on its own.
About overshooting - there are no settings and no limits.About the lack of antivirus - for a long time now, all versions since 7 have had an in-house and inconspicuous Windows Defender, which does a good job of scanning all files.
Sometimes it generates noticeable lags in file operations even on SSD disks.
About the lack of antivirus - for a long time now, all versions from 7 have had an in-house and inconspicuous Windows Defender, which scans all files.
Forum on trading, automated trading systems and trading strategy testing
fxsaber, 2017.05.07 21:55
Alpari-MT5 trading server
Why are there duplicate ticks (bid and ask are equal) in FOREX tick history?
The tester is racing EAs on duplicates and there are half of them. Is it necessary to obtain the appropriate performance drop by half?
You still don't understand the slips I'm talking about. It doesn't work in MT4 as a matter of principle.
Not in ticks, but in the process of mcl5 programme, when it stops and the ticks keep going and the world is spinning. Write Sleep(3000) and the program will wait for 3 seconds and during this time the ticks will be ticking, the market will be simulating.
If you set the Execution Delay field to 200ms in the tester, a net latency of 200 when executing trades will be simulated, which will give either market slippage or requotes.
This is a whole other powerful level of market process modelling, and within a multi-currency system. And more importantly, in a remote alienated process. For example, a 10,000km agent suddenly receives a dynamic request for access to missing symbols from the code when performing a task and is able to request this data from the master, embed it in the market world and continue to spin it.
You still don't understand the slips I'm talking about. It doesn't work in MT4 as a matter of principle.
Not in ticks, but in the process of mcl5 programme, when it stops and the ticks keep going and the world is spinning. Write Sleep(3000) and the program will wait for 3 seconds and in that time the ticks will be ticking, the market will be simulating.
This does not work now in MT4.
If you set the Execution Delay field to 200ms in the tester, it will simulate a net latency of 200 when executing trades, which will give either market slippage or requotes.
This works now in MT4.
This is a whole other powerful level of market process modelling, and within a multi-currency system. And more importantly, in a remote alienated process. For example, a 10,000km agent suddenly receives a dynamic request for access to missing symbols from the code when performing a task and is able to request this data from the master, embed it in the market world and continue to spin it.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Forum on trading, automated trading systems and trading strategy testing
Discussion on "Ready-made EAs from MQL5 Wizard work in MetaTrader 4"
fxsaber, 2017.03.09 13:02
I suggest to take Tick Data Suite trial (Compatible: MT4 build 940 - 1052) for comparison.
In MT5 tester select "by real ticks" mode. Save them and feed them to the MT4 tester via TDS.
Then the quotes in both testers will coincide 100%, which will allow comparing them not only in trades, but also in speed.
It would then be possible to compare the conversion/creation of EAs in both directions.
MT4 build 1072, MT5 build 1596 trading server Alpari-MT5.
MT4 tester settings on the screenshot
Currency in both testers is USD. This allows in the same MT5 tester for EURUSD not to pull another tick of conversion symbol.
Now we run the following cross-platform Expert Advisor in both testers
MT4-tester log
MT5-tester log
We confirm that the files received from each tester are identical - the ticks of the testers coincide.
At this point the preparation of both testers for the new service is ready.