I have an open source code of a Martingale EA with no bugs at all.
When martingale reaches .08 lots ( starts from .01, .02, .04, .08) , it opens another order in opposite position .
Example : USD/JPY .08 sell opened at 101.50 by martingale( exisiting EA ).
Then( our modified EA ) must place a Buy at .16 lots at 101.50 ( taking into account any spread difference ) . After 10 pips at 101.60 , all open .01, .02, .04, .08 sell positions are closed and .16 starts to trail from 101.60 , which is also set at breakeven.
If .16 buy goes to 101.40, then all previous sell positions are closed by the martingale EA at profit and we close this trade at loss in 101.40.
External parameter requires the following.
1. Open opposite position at Step? ( example step1 is .01,S2 is .02, S3 is .03.. etc.. )
2. Trail or Take profit- True /False
3. Trail Step.
4. Do not trade when spread is higher than >
Any other logical changes that may require at that time..
Once you PMB, if you require the old EA, I shall upload for you to see.