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

Script to open long position - MetaTrader 5 script | Trading script download - MT4/MT5 resources

author EAcpu | 4 reads | 0 comments |

These scripts are designed to make purchases with fixed stop loss and take profit pip values ​​at the current price. There are four variations of the script, which can be divided into two groups:

The first set of scripts are OpenBuyPosition.mq5 and OpenBuyPosition_X.mq5. The second set of scripts ends with the name of the ECN file. They are OpenBuyPosition_ECN.mq5 and OpenBuyPosition_X_ECN.mq5.

All scripts are designed to make purchases with fixed stop loss and take profit pip values ​​at the current price.

The main advantage of the OpenBuyPosition and OpenBuyPosition_ECN scripts is the ability to fix the volume according to the size of the entire deposit using the MM (Money Management) script input parameter, which defines the ratio of the volume of equity involved in the transaction to the equity of the entire deposit:

OpenBuyPosition and OpenBuyPosition_ECN script input parameters:

 //+------------------------------------------------------------------------+
//|Script input parameters |
//+------------------------------------------------------------------------+
Enter double MM= 0.1 ; // Money Management
Input integer deviation = 10 ; // price deviation
Enter an integer Stop loss = 300 ; // Stop loss points at the current price
Enter an integer Take Profit = 800 ; // Profit in points from the current price
Enter the total time in units = 4 ; // Number of retries for unsuccessful transactions
Input unit sleep time = 1 ; // Pause time between retries (in seconds)

The main advantage of the OpenBuyPosition_X and OpenBuyPosition_X_ECN scripts is the ability to fix trade losses when the stop loss is triggered based on the entire deposit size using the LossMM script input parameter, which defines the equity volume ratio of the total deposit equity loss when the stop loss is triggered:

OpenBuyPosition_X and OpenBuyPosition_X_ECN script input parameters:


Attachment download

📎 openbuyposition.mq5 (15.44 KB)

📎openbuyposition_ecn.mq5 (18.03 KB)

📎 openbuyposition_x.mq5 (16.45 KB)

📎 openbuyposition_x_ecn.mq5 (19.04 KB)

Source: MQL5 #1574

Verification code Refresh