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?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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?