anyone?
anyone?
In my EA, I buy at the ASk, sell at the bid.
On all SELL orders, I set a target profit and a stop loss both with 3 pips added due to the spread. However, when I run this in the strategy tester, BUY trades show profits of 400, losses of 400, yet
SELL trades show profits of 430, losses of 430.
You don't need to add the spread in this way. If you have e.g. a buy stop order with pending entry at 1.4200 and a stop loss at 1.4100, then it will get filled when the ask is at 1.4200 and closed when the bid is at 1.4100. Ditto on the t/p. And vice versa for sells rather than buys. In other words, the spread is "automatically factored in" to the s/l and t/p prices.
However, you do need to do what you're currently doing in terms of adding the spread to your long entry price. Just in case this isn't already clear to you, High[] gives you the highest bid price over your chosen period. If you used that as the buy-stop entry price, then you'd enter when the ask hit the historical bid level. Therefore, it makes sense to do what you're doing in terms of subtracting x (0.0006) from the short entry, and adding x plus the spread (0.0009) to the long entry. Though I'm not quite sure where 0.0006 comes from.
![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
In my EA, I buy at the ASk, sell at the bid.
On all SELL orders, I set a target profit and a stop loss both with 3 pips added due to the spread. However, when I run this in the strategy tester, BUY trades show profits of 400, losses of 400, yet
SELL trades show profits of 430, losses of 430.
With the spread added, they should be the same shouldn't they?