Ever since I stopped using Robominer, there have been many open trades that I need to manage. I looked at existing EA's to help manage the open positions but none of them would convert a negative
rollover 
/swap to pips and adjust the take profit
point 
taking the negative
rollover 
/swap into consideration.
I wrote the attached EA which I call AvoidSwap for the following purposes:
1. To re-adjust the take profit.
2. To re-calculate and adjust the take profit price taking any negative
swap 
into consideration.
3. To perform an emergency close of open trades.
AvoidSwap works by magic number. The trade or trades that you want to manage must have a magic number. The parameters
magicstart and
magicend should be used to identify the open trades that you want to change. If the magic number is the same for all trades that you want to mange, set
magicstart and
magicend to the same number.
AvoidSwap is designed for safety. There are three on/off switches. By default, all three switches are off.
runit controls whether AvoidSwap scans open trades
changenow controls whether AvoidSwap actually makes changes or just reports
emergencyclose controls whether all matching trades (by magic) are closed
changenow and
emergencyclose only work if
runit is on.
emergencyclose only works if
runit and
changenow are on.
AvoidSwap will run only once on the next chart
tick 
. After it finishes running, it will set all three switches off to prevent the EA from running on every
tick 
.
I suggest that you run AvoidSwap once with only
runit on. This will produce a report in the experts log of what would have been changed. Once you are ok with the preliminary report, run the EA again with both
runit and
changenow on.
AvoidSwap is an open source EA which is licensed with the
GNU GPL version 2. Under the terms of this license, you are entitled to:
1. the software free
2. the source code free
You also may redistribute the software providing the copyright is in tact and the source code is included.
You may also modify the EA source code to create a separate version. Under the terms of the GPL, all offspring of the original EA are also required to be licensed by the GPL.
Please read the entire text of the GPL license which is included along with the software.
Please report all bugs to me.
Enjoy,
Rick