This EA is closing open positions (long/short) if the price hits the other side of the moving average (below/above).
It basically works like a stop loss, without the need to trail it manually, while price and moving average fluctuate.
Input Options
It basically works like a stop loss, without the need to trail it manually, while price and moving average fluctuate.
Input Options
- TimeFrame (1=M1,5=M5,15=M15,30=M30,60=H1,240=H4,1440=D1,10080=W1,43200=MN,0=variable)
- MAType (0=SMA,1=EMA,2=SMMA,3=LWMA)
- MAPeriod (Number of prices that are calculated into the MA)
- MAPrice (0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted)
- Tolerance (How far the price is tolerated to break the MA, absolute value)
- BarCheck (true=checking previous bar close, false=checking latest price)
- Slippage (Maximum deviation from the market price when closing a trade)
- AlertMessage (true=shows alert message before closing a trade)
Feel free to share and/or modify this EA.
Note: I've coded it as simple, clean and clear as possible, so it can be the basis for more complex EA's.
Update to Version 1.1: Fixed some major issues and added the AlertMessage Option
Update to Version 1.2: Fixed some minor issues and added the TimeFrame Option
Update to Version 1.2b: Fixed an issue regarding multiple open positions
Attached File(s)