Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Reverse trading scripts for all trading symbols - Scripts for MetaTrader 4 | MT4/MT5 Download - MetaTrader 5 Resources

author EAcpu | 5 reads | 0 comments |

Reverse Trades For All Symbols Script - script for MetaTrader 4

Reverse Trades For All Symbols Script - script for MetaTrader 4

Reverse Trades For All Symbols Script - script for MetaTrader 4

Reverse Trades For All Symbols Script - script for MetaTrader 4

The strategy implemented in the script "Reverse_Trades_For_all_Trades_and_Symbols_V1.mq4" reverses all open trades for all symbols on the trading platform. When executed, the script iterates through all open trades, closing each trade and opening the opposite trade for the same symbol. This effectively reverses the direction of each trade, allowing traders to profit from changes in market direction. It is important to test the script thoroughly in a demo account before using it on a live trading account.

Here's a breakdown of the key components:

OnStart(): This function is called when the script starts. It calls the ReverseTrades() function.

ReverseTrades(): This function iterates over all open trades using a loop. For each trade, it selects the trade and retrieves basic information such as order type, opening price, lot size, and ticker. It then uses OrderClose() to close the existing order and OrderSend() to open the opposite order.

OrderClose(): This function closes an existing order using the specified order, lot size and closing price.

OrderSend(): This function opens a new order in the opposite direction using the specified symbol, order type, lot size and opening price.

The script provides feedback through the Print() function to inform the status of each operation, such as whether the order was successfully closed or opened.

This script is useful for traders who want to quickly reverse positions for all symbols in the MetaTrader platform.

Reverse Trades For All Symbols Script - script for MetaTrader 4

Reverse Trades For All Symbols Script - script for MetaTrader 4


Attachment download

📎 reverse_trades_for_all_trades_and_symbols_v1.mq4 (3.07 KB)

Source: MQL5 #49137

Verification code Refresh