Script LotsOptimizedMargin
The description of action:
For currency pair of chart to which it is attached, calculates the size of lots borrowing the specified interest of the current free margin. The result is shown in MessageBox and after manual confirmation keeps in a global variable "Scripts: Lots" for further use in scripts OpenBUY and OpenSELL. Is possible to run script in test-mode for see that is a values will calculated at various size of balance. The results of test-mode is save to CSV-file.
Assignment:
The script allows to automate the mathematical calculations concerning the optimum size of an opened position.
Parameters:
Global variable "Scripts: MM RiskPercent" = interest of the current free margin used for opening a position; value should be more than 0 and less than 100, probably fractional value.
Global variable "Scripts: MM Method" = the code of base that used for calculation a size of lots. Possible values: 0 - FreeMargin, 1 - Balance, 2 - Equity.
Global variable "Scripts: MM ShowMessageBox" = enable/disable to show window MessageBox with result of calculations. Possible values: 0 - don't show window, 1 - to show window.
Global variable "Scripts: MM Test" = enable/disable the test-mode of calculations. Possible values: 0 - test-mode is disabled, 1 - test-mode is enabled.
Global variable "Scripts: MM Test FreeMargin First" = the first value of FreeMargin. This is parameter for test-mode.
Global variable "Scripts: MM Test FreeMargin Step" = the step for modify value of FreeMargin. This is parameter for test-mode.
Global variable "Scripts: MM Test FreeMargin Last" = the last value of FreeMargin. This is parameter for test-mode.
Global variable "Scripts: MM Test RiskPercent First" = the first value of RiskPercent. This is parameter for test-mode.
Global variable "Scripts: MM Test RiskPercent Step" = the step for modify value of RiskPercent. This is parameter for test-mode.
Global variable "Scripts: MM Test RiskPercent Last" = the last value of RiskPercent. This is parameter for test-mode.
At the first start of a script global variables will be created. For change of their values press F3 in a window of the terminal.
The status: Free-of-charge, it is possible to download the full version.
Platform: MetaTrader 4, MetaTrader 5.
See also these scripts:
- calculate the optimum size of lots, being based on the possible loss.
- open a long position.
- open a short position.
Frequently asked questions:
How I can run a script ?
How I can determine that the script works ?
What is the global variables ?
|