- Calculate the weighted average price of all positions
- Calculate the number of total lots currently active
- Calculate a target based on user entered pips from average price
- Close a user identified percent of total lots at the targeted price
- Move the stop to break even +2 pips after the intended scale out
The code as I've written it will accurately calculate the first three items on this list, but when it comes to closing at the desired point, it falls short. If the all the lots are in only one position, it will correctly execute as I wish closing out the correct percent of lots. However, if the lots are spread out over multiple positions, the EA will only close one of the positions, or worse none at all.
I am admittedly self taught and I'm sure you will find many errors in this code. I would appreciate any and all suggestions. I have written this code to help get me out of my seat during the day or sleep at night knowing that the EA will take profit when its time and then protect what's left of the position...
Can anyone help?