Partial close script

Ckart 1

Trader
Sep 17, 2018
9
1
24
San Francisco, CA
www.youtube.com
That is exactly what I was looking for!

It will save a lot of time not having to go through all the steps with meta trader doing it the difficult way.

Thank you very much.
 

milesZ

Trader
Dec 3, 2021
1
0
6
22
Have you seen this script? It can be easily modified to close 50% or 25% instead of the current 1/3 of a position.
Hey,

I have never modified scripts before. Wich line do I have to change in order to put a different percent to close?
 

Enivid

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

I have never modified scripts before. Wich line do I have to change in order to put a different percent to close?
The line number 44:
MQL4:
double halflots = NormalizeDouble(LOTS / 3.0, vp);
This makes it close 1/3 of a position. You can either keep it as a part and change to LOTS / 4.0 for 25% close or LOTS / 2.0 for 50% close, or you can change it to percentage like LOTS * 0.27 for 27% close.
 
  • 👍
Reactions: milesZ

jibaku

Trader
Dec 27, 2021
2
0
17
38
thanks, but just only 1 position can be closed by partial by this script. can u made it for all position ?
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
thanks, but just only 1 position can be closed by partial by this script. can u made it for all position ?
It partially closes all positions but only for the current trading symbol. You can make it work on all symbols by replacing this line of code:
MQL4:
if((l_type == OP_BUY || l_type == OP_SELL) && OrderSymbol() == Symbol())
with:
MQL4:
if(l_type == OP_BUY || l_type == OP_SELL)
 

TiagoDBC

Trader
Feb 24, 2024
2
0
6
35
Hi there, so this script closes for example 50% of the position that I have selected or all positions on Mt4 that are currently opened?

Thank you.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
Hi, thanks.
is there an script which closes partially the position I select on the terminal? If yes where can i find it? Tries to look everywhere but so far no sucess.
You can quite easily modify the attached script to only partially close those trades that match a given Magic number or even ticket number.