EnrichWave

Active Trader
May 15, 2018
45
3
34
India
Could any one write a script to change the SL TP of opened, pending orders which price value taken from SL, TP lines?

Kind Regards
 

Enivid

Administrator
Staff member
Nov 30, 2008
12,249
471
114
Odessa
www.earnforex.com
Could any one write a script to change the SL TP of opened, pending orders which price value taken from SL, TP lines?
Do you mean a script that would rewrite SL/TP for all existing trades in a given account? If so, you can try modifying the attached script to read the SL/TP line values and use them to set the trades' SL/TP.
 

Attachments

  • Like
Reactions: EnrichWave

dy_eyeconical

Trader
Dec 2, 2019
1
0
6
Seattle, WA
Hello there. To anyone that may be reading this. How difficult would it be to port this and to make this indicator work in tradingview charts? Does anyone know how i could code this up?
 

Enivid

Administrator
Staff member
Nov 30, 2008
12,249
471
114
Odessa
www.earnforex.com
Hello there. To anyone that may be reading this. How difficult would it be to port this and to make this indicator work in tradingview charts? Does anyone know how i could code this up?
From what I've seen when I last looked at TradingView's PineScript, it would impossible. The main reasons are the lack of account information functions and on-chart panel drawing tools.
 

EnrichWave

Active Trader
May 15, 2018
45
3
34
India
Do you mean a script that would rewrite SL/TP for all existing trades in a given account? If so, you can try modifying the attached script to read the SL/TP line values and use them to set the trades' SL/TP.
Exactly dude., but for MT5..
 

EnrichWave

Active Trader
May 15, 2018
45
3
34
India
There are two versions for MT5. The one in the zip archive is a rough conversion of MQL4 code, the one in a single .mq5 file is a rewrite for MQL5.
If I give some value in TP,SL it's working perfect. But sometimes when I try to changed TP,SL to 0 It's not working.. I could not find where it's checking TP or SL >0..

Kind Regards
 

Enivid

Administrator
Staff member
Nov 30, 2008
12,249
471
114
Odessa
www.earnforex.com
If I give some value in TP,SL it's working perfect. But sometimes when I try to changed TP,SL to 0 It's not working.. I could not find where it's checking TP or SL >0..

Kind Regards
Which of the two scripts did you try? Is there any output in the Experts/Journal tabs when it isn't working?
 
  • Like
Reactions: EnrichWave

EnrichWave

Active Trader
May 15, 2018
45
3
34
India
I checked on both files. mql4 conversion and rewritten to Mq5 file.
When I load the script with value 0 that showed like
Scripts script Modify_All_TP_SL(1) (XAUUSD,H4) loaded successfully
Scripts script Modify_All_TP_SL(1) (XAUUSD,H4) removed

but when I used the scripts with some value It showed like
Scripts script Modify_All_TP_SL(1) (XAUUSD,H1) loaded successfully
Trades 'xxxxxxxxxx': modify order #933373 sell limit 0.01 XAUUSD at 1478.95 sl: 0.00 tp: 0.00 -> 1478.95, sl: 1485.00 tp: 0.00
Trades 'xxxxxxxxxx': accepted modify order #933373 sell limit 0.01 XAUUSD at 1478.95 sl: 0.00 tp: 0.00 -> 1478.95, sl: 1485.00 tp: 0.00
Trades 'xxxxxxxxxx': modify #933373 sell limit 0.01 XAUUSD -> price: 1478.95, sl: 1485.00, tp: 0.00) done in 240.009 ms
Trades 'xxxxxxxxxx': modify #933606 sell 0.01 XAUUSD sl: 0.00, tp: 0.00 -> sl: 1485.00, tp: 0.00
Trades 'xxxxxxxxxx': accepted modify #933606 sell 0.01 XAUUSD sl: 0.00, tp: 0.00 -> sl: 1485.00, tp: 0.00
Trades 'xxxxxxxxxx': modify #933606 sell 0.01 XAUUSD -> sl: 1485.00, tp: 0.00 done in 223.527 ms
Trades 'xxxxxxxxxx': modify #933371 sell 0.01 XAUUSD sl: 0.00, tp: 0.00 -> sl: 1485.00, tp: 0.00
Trades 'xxxxxxxxxx': accepted modify #933371 sell 0.01 XAUUSD sl: 0.00, tp: 0.00 -> sl: 1485.00, tp: 0.00
Trades 'xxxxxxxxxx': modify #933371 sell 0.01 XAUUSD -> sl: 1485.00, tp: 0.00 done in 215.955 ms
Scripts script Modify_All_TP_SL(1) (XAUUSD,H1) removed
 

EnrichWave

Active Trader
May 15, 2018
45
3
34
India
Dude., I removed that line too.. but it seems it checks that somewhere..
may be "OrderTakeProfit()" or "OrderOrderStopLoss()" may have that check. I tried to find where that functions.. I could not find it even in "KimIVtoMT5.mqh".

Kind Regards
 

hedd

Newbie
Jan 6, 2020
6
0
1
74
Being a "newbie" probably doesnt help , but your PSC most certainly will! Thank you for your product Enivid. Some guidance would help please:

I have downloaded both the Script and PSC Indi (Ver 2.27), but I just can't seem to get the Script to activate trades.

Your help to get the script processing would be greatly appreciated. Thank you.
 

Enivid

Administrator
Staff member
Nov 30, 2008
12,249
471
114
Odessa
www.earnforex.com
Being a "newbie" probably doesnt help , but your PSC most certainly will! Thank you for your product Enivid. Some guidance would help please:

I have downloaded both the Script and PSC Indi (Ver 2.27), but I just can't seem to get the Script to activate trades.

Your help to get the script processing would be greatly appreciated. Thank you.
Did you install the PSC-Trader script into the Scripts folder? Did it compile? Do you run it when the Position Size Calculator is on the chart? What messages does it output in the Experts tab of your Terminal subwindow?
 

hedd

Newbie
Jan 6, 2020
6
0
1
74
Thank you for your prompt reply Enivid. I had difficulty compiling the script but I did go thro compile process picking up the mq4 file from the script folder as the Screen Shot attached (which shows relevant comments in Experts Tab and PSC open on the Chart). I hope this is of assistance?
 

Attachments

Enivid

Administrator
Staff member
Nov 30, 2008
12,249
471
114
Odessa
www.earnforex.com
Thank you for your prompt reply Enivid. I had difficulty compiling the script but I did go thro compile process picking up the mq4 file from the script folder as the Screen Shot attached (which shows relevant comments in Experts Tab and PSC open on the Chart). I hope this is of assistance?
Please make a screenshot of the Experts tab after you try to launch PSC-Trader.

PS: However, I believe the problem is in the fact that your AutoTrading is disabled. Please enable it for the script to work.