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
Dears,
I´m trying to code a simple program to perform a stop loss and take profit operation through MT´s Strategy Tester without success. I´m using the MT 5.0, build 2085, and tried all kind of codes from Internet, including the ones written based on the standard library CTrade, but it doesn´t work.
The behaviour I´m facing is that the MT is triggering the Buy Stop Loss before the current price to reach the SL threshold.
The code below was taken from the book "Expert Advidor 5 - Programming for Meta Trader", by Andrew r. Young, page 83:
I´ve ommited the rest of the script just for a matter of simplicity.
As can be seen in the picture attached,the stop loss was set to $13.16 when the buy order was sent, but the sell was performed at $14.47 based on a trigger whose the price was higher than the SL. Notice that the Low price in the respective period was $14.45, quite higher than the SL set ($13.16).
How can I code it in a way the stop loss is performed only when the current price reaches the SL defined?