
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Please explain in more detail and differently please, because I am not following what you want.
Please explain in more detail and differently please, because I am not following what you want.
When I open a sell trade I set the stoploss at +5 USD, but the price rises sharply and breaks the stoploss at +15 USD in one move, and the tester calculates that blow at +5 USD in the final balance and does not at +15 USD which is the close of the candle, do you understand me? How to calculate the stoploss at the close of that candle?
The tester gives me wrong results for this reason, example: the final balance should be $10020 and not $10125.
Ok, now I understand the issue, but unfortunately all we have discussed so far has nothing to do with it nor will it solve the problem.
The issue is that the Strategy Tester will take the S/L and T/P at the exact price you set it instead of the real price slippage. The same also happens for the opening price of pending orders.
This is a real problem which MetaQuotes has never corrected and it has been like that even in MT4 (and it also makes back tests of Market products look very nice in the Strategy Tester, but bad in live trading).
The only solution I have come up with, is to implement virtual stops that are handled within the code (instead of the broker/tester side), that simulates the stops being hit and closes the positions when the target stops are reached.
In my own EAs I do the following:
When the EA is trading live, all I do is set the virtual stop offset to 0, instead of 10000 for the Strategy Tester.
The reason I use this offset is so that I still have the stops information stored with the order and position and I don't need to keep an internal cache of the data of the real stops. It is all stored within the normal trading records but just offset in value.
The value I choose, for example 10000, is so that the stops don't get accidentality triggered (in the tester system) by a very big spike in spread or slippage and also because it is a "nice" number and easy to calculate visually when reading the test reports.
I hope you will be able to understand all this process. However, for a beginner it may be difficult to implement, as it requires a higher level of coding skills.
Ok, now I understand the issue, but unfortunately all we have discussed so far has nothing to do with it nor will it solve the problem.
The issue is that the Strategy Tester will take the S/L and T/P at the exact price you set it instead of the real price slippage. The same also happens for the opening price of pending orders.
This is a real problem which MetaQuotes has never corrected and it has been like that even in MT4 (and it also makes back tests of Market products look very nice in the Strategy Tester, but bad in live trading).
The only solution I have come up with, is to implement virtual stops that are handled within the code (instead of the broker/tester side), that simulates the stops being hit and closes the positions when the target stops are reached.
In my own EAs I do the following:
When the EA is trading live, all I do is set the virtual stop offset to 0, instead of 10000 for the Strategy Tester.
The reason I use this offset is so that I still have the stops information stored with the order and position and I don't need to keep an internal cache of the data of the real stops. It is all stored within the normal trading records but just offset in value.
The value I choose, for example 10000, is so that the stops don't get accidentality triggered (in the tester system) by a very big spike in spread or slippage and also because it is a "nice" number and easy to calculate visually when reading the test reports.
I hope you will be able to understand all this process. However, for a beginner it may be difficult to implement, as it requires a higher level of coding skills.
I understand, can you give me a small code example of what you are telling me? I am new to mql5 and trying to learn as much as possible
Unfortunately not, because this is something that is interwoven into my own EAs code and functionality. It's not something that can be shown separately as isolated code. As i stated, this is something targeted for skilled coders, not for newbie coders.