Multiple Position Opening MT4
- ユーティリティ
- Francisco Manuel Vicente Berardo
- バージョン: 1.2
- アップデート済み: 5 10月 2024
The Multiple Position Opening is a multi-symbol multi-timeframe script used to open simultaneously various positions.
Risk Management
The volume used to open a position is chosen between a fixed and a variable lot size, available through the Volume and Free Margin % input parameters, respectively. If there isn't enough money in the account for the chosen volume, this is reduced to the highest possible value (corresponding to free margin). If this reduction leads to a correct volume (if the free margin is enough, at least, for the minimum volume allowed by the broker), a request for opening the position is sent to the trade server; otherwise, the request isn’t sent.
Input Parameters
- Magic Number: Script’s identifier.
- Type: Position type used.
- Volume: Lot size per deal (lots).
- Free Margin %: Percentage of account free margin used to calculate the lot size per deal (%).
- Stop Loss: Distance from the market price for placing a Stop Loss at a position opening (pips).
- Take Profit: Distance from the market price for placing a Take Profit at a position opening (pips).
- Deviation: Maximum allowed slippage from the requested price (pips).
- Comment: Text message displayed in the Trade or Account History tabs of the Terminal window and Objects list after opening a position (it only allows 31 characters).
- Total: Positions number to be open.
Some of the available parameters accept values that lead to particular options.
- Volume: A value lower than the minimum allowed volume by the broker is converted in this last. A value higher than the maximum available volume by the free margin is converted in this last.
- Free Margin %: A value whose volume doesn't reach the minimum allowed volume by the broker is converted in this last. A value whose volume exceeds the maximum available volume by the free margin is converted in this last.
- Stop Loss or Take Profit: A null value means the parameter’s inactive function. Any value between 0 and the Stop Level is converted in this last.
Displayed Information
The script possesses a vast number of messages to inform the user about errors and conditions changes that might occur during its execution. The messages are shown through the Alert function (by a pop-up window), its content includes:
- The warning that an input parameter has been incorrectly set.
- The info that the account doesn't have enough money for the chosen volume (see the Risk Management section above).
- The info that the number of permitted orders by the broker has been reached.
- The Trade Server Return Codes description.
- The symbol’s quotes (immediately) before the trade request’s formation, followed by the symbol’s quotes (immediately) after the trade server’s decision.
Note: Some elements of the list are displayed simultaneously (in the same text line): 4 and 5.
Observation
During high activity periods, the trade server’s decision on whether a trade request is executed or rejected may suffer significant delays. Some data used in the request sent to the server might become incorrect, leading to the order’s rejection. When the server is evaluating a request and the symbol's quotes are updated, three cases might occur:
- Pending order placing – the pending order’s target price becomes an incorrect distance.
- Position opening/modifying – the position's Stop Loss or Take Profit intended level becomes an incorrect distance.
- Position modifying – the position's Stop Loss or Take Profit previous level takes to its closing.
The symbol’s quotes mentioned in the fifth element of the list in the Displayed Information section are especially useful here (since firsts usually differ from lasts). A careful analysis of these quotes, knowing the implication that certain quote changes have on the request’s evaluation, permits understanding the reason when these cases occur. To avoid the request’s rejection by the trade server due to “invalid stops” (cases 1 and 2), the prices/levels used should exceed the symbol’s Stop Level by a few pips.
Conclusion
The Multiple Position Opening is a helpful and effective tool regarding the positions manual opening, especially when these represent a significant number, enabling a simple and intuitive setting of the positions to open.