Set Fixed SL and TP

CARPARK

Trader
Mar 29, 2021
67
23
24
46
Tallinn
Hi there, I'm trying to apply the following script available in the software library to DAX30 CFD (have also tried with regular fx pair) but it fails with the error:

2021.09.15 10:18:40.714 SetFixedSLandTP_v1-0 GER30.cash,M1: Order failed to update with error - 1

I was wondering if anyone was familiar with this script could tell me what I am doing wrong?

Settings attached
 

Attachments

  • Screenshot 2021-09-15 102509.png
    Screenshot 2021-09-15 102509.png
    13 KB · Views: 17

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
Hi there, I'm trying to apply the following script available in the software library to DAX30 CFD (have also tried with regular fx pair) but it fails with the error:

2021.09.15 10:18:40.714 SetFixedSLandTP_v1-0 GER30.cash,M1: Order failed to update with error - 1

I was wondering if anyone was familiar with this script could tell me what I am doing wrong?

Settings attached
Error 1 means ERR_NO_RESULT (No error returned, but the result is unknown). I only get this error when I am trying to set the same SL and TP as the order already has set on it. Try modifying the SL and TP to some different values.
 

CARPARK

Trader
Mar 29, 2021
67
23
24
46
Tallinn
Yeah I've used it on a symbol I frequently use different EAs on.

I'll try some other stuff and see if I can get anywhere with it...
 
  • 👍
Reactions: Zoom

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
The Set Fixed SL and TP script has been updated to version 1.01 to introduce numerous changes:
  • Added an MT5 version of the script.
  • Added an option to apply stop-loss and take-profit based on the current price rather than open price.
  • Added an option to work with pending orders as well.
  • Added an option to set SL and TP not only for the current trading symbol.
  • Added an option to skip either SL or TP by setting the respective input parameter to zero.
  • Added a filter based on trade's direction.
  • Changed the script to work based on points rather than pips.
  • Removed the Slippage input parameter (wasn't used).
  • Refactored the MQL4 code.
 

MikeCreativ

Trader
Dec 26, 2023
3
0
6
53
Hello,

nice idea <Set Fixed SL and TP Script>, thank you for that.

I have a question/idea:
If you work in hedging, there can also be several trades open in one “Magic ID”. However, when the market turns, there are many positions open.

Sometimes it would be helpful to exit these trades at a certain price. Can you also add this “feature” as an “option”?

Best Ergards
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
Hello,

nice idea <Set Fixed SL and TP Script>, thank you for that.

I have a question/idea:
If you work in hedging, there can also be several trades open in one “Magic ID”. However, when the market turns, there are many positions open.

Sometimes it would be helpful to exit these trades at a certain price. Can you also add this “feature” as an “option”?

Best Ergards
Not sure what you mean. Could you please explain more?
 

MikeCreativ

Trader
Dec 26, 2023
3
0
6
53
Not sure what you mean. Could you please explain more?
Hello,

for an example see the screen below.
Due to the large number of open positions, it would not have been possible to close them all in line with the market.The regular "TP" was apparently missed by a few pips - see the marking "yellow" (1/ 2/ 3).
The idea would have been to pull the "TP" up a few pips - see the "orange" marking.
1703645130597.png
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
Hello,

for an example see the screen below.
Due to the large number of open positions, it would not have been possible to close them all in line with the market.The regular "TP" was apparently missed by a few pips - see the marking "yellow" (1/ 2/ 3).
The idea would have been to pull the "TP" up a few pips - see the "orange" marking.
View attachment 26579
Sorry, but I still don't understand what you are asking for. How is it different from setting TP at some specific level?
 

MikeCreativ

Trader
Dec 26, 2023
3
0
6
53
Sorry, but I still don't understand what you are asking for. How is it different from setting TP at some specific level?
The difference is that when specified in points, the target of the points specified in TP must be achieved for each open order.When entering the price, for example: all open orders of a specific Magic ID should be closed at this price.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
The difference is that when specified in points, the target of the points specified in TP must be achieved for each open order.When entering the price, for example: all open orders of a specific Magic ID should be closed at this price.
OK, now I understand what you want. I will consider adding such an option to this script in its future version.
 

janwro28

Newbie
Jan 17, 2024
4
0
1
51
The Set Fixed SL and TP script has been updated to version 1.01 to introduce numerous changes:
  • Added an MT5 version of the script.
  • Added an option to apply stop-loss and take-profit based on the current price rather than open price.
  • Added an option to work with pending orders as well.
  • Added an option to set SL and TP not only for the current trading symbol.
  • Added an option to skip either SL or TP by setting the respective input parameter to zero.
  • Added a filter based on trade's direction.
  • Changed the script to work based on points rather than pips.
  • Removed the Slippage input parameter (wasn't used).
  • Refactored the MQL4 code.
Hi. In my opinion, working on percentages would be much more useful than on points. What do you think about adding it to the script? Regards :)
 

janwro28

Newbie
Jan 17, 2024
4
0
1
51
Hi. Yes, I use it as a basic strategy. Eg. I fix 150% TP versus 100% SL. It means I always earn 1,5 more than I risk. Additionally, I do not need to think about points because of different markets - Gold, Silver are different in points than Currencies. All my trading community uses %, so not only me.
Regards,
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
Hi. Yes, I use it as a basic strategy. Eg. I fix 150% TP versus 100% SL. It means I always earn 1,5 more than I risk. Additionally, I do not need to think about points because of different markets - Gold, Silver are different in points than Currencies. All my trading community uses %, so not only me.
Regards,
So, it would set the TP based on the percentage of the SL, not on the percentage of price? That makes some sense, but I think that would be best as a separate script because it won't be able to set any TP for trades that don't already have a SL. The current script is intended more for setting a uniform SL and TP on a large number of filtered trades.
 

janwro28

Newbie
Jan 17, 2024
4
0
1
51
So, it would set the TP based on the percentage of the SL, not on the percentage of price? That makes some sense, but I think that would be best as a separate script because it won't be able to set any TP for trades that don't already have a SL. The current script is intended more for setting a uniform SL and TP on a large number of filtered trades.
Yes, you are right regarding TP based on % of SL. I hope you find time for that :)
Thank you very much for your attention. Regards
 

SteveM

Trader
Feb 1, 2024
1
0
6
63
Hi @Enivid and all - I appreciate the script SetFixedSLandTP (thank you) but I cannot seem to get it to work in my MT4 ...in the data folder, should the scripts be added to Expert Advisors folder OR Indicators folder OR Scripts folder? Just need to get it working ...any help please, thanks
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,535
1,355
144
Odesa
www.earnforex.com
Hi @Enivid and all - I appreciate the script SetFixedSLandTP (thank you) but I cannot seem to get it to work in my MT4 ...in the data folder, should the scripts be added to Expert Advisors folder OR Indicators folder OR Scripts folder? Just need to get it working ...any help please, thanks
The archive that you downloaded contains two folders. Both have to be copied directly to the MQL4 folder. The script will then appear under Scripts in your MT4's Navigator.