The purpose of this script is to reverse existing open positions quickly, reliably and accurately in an automated mechanism. There are circumstances when a trader feels that the market conditions have reversed and he needs to reverse his open positions. The trader is able to accomplish this with a single click using the Reverse script.
The script iterates through each open position (either a BUY or a SELL trade), and then closes it at the market price. After the original position has been closed, it opens a new trade with the same lot-size in the opposite direction. So, a BUY position is closed and an opposite SELL position with an identical lot-size is opened. Likewise, a SELL position is closed and an opposite BUY position with an identical lot-size is opened. If the paramter CurSymbolOnly is set to TRUE, then the script reverses positions only for the current chart symbol leaving open positions of other symbols untouched. However, if CurSymbolOnly is set to FALSE, then the script reverses open positions of all symbols.
If StopLoss and TakeProfitparameters are configured then the script sets the stop-loss and the profit-target of the reversed positions accordingly.
The Marketwatch parameter is used to configure the script for STP/ECN brokers, whereby the broker expects the stop-loss and the profit-target to be set only after the position is opened. When set to TRUE, the Reverse script first opens the reverse position and then updates the stop-loss and take-profit thereby fulfilling the criteria of STP/ECN brokers.
The Reverse script does not act upon pending orders, namely BUY-LIMT, BUY-STOP, SELL-LIMIT and SELL-STOP orders. It acts only on open positions, thus leaving the pending orders untouched.