Script LotsOptimizedLoss
The description of actions:
For currency pair of chart to which it is attached, calculates the size of lots bringing in a case stoploss the loss equal to the specified interest of the current balance. 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: StopLoss (pips)" = level stoploss in pips from the open price of a position; value should be more than 0.
Global variable "Scripts: MM RiskPercent" = interest of the current balance which will be lost in a case stoploss; 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.
![To download the full version for MT5](images/edl51.gif)
See also these scripts:
![LotsOptimizedMargin](images/lm1.gif)
- calculate the optimum size of lots, being based on the used margin.
![OpenBUY](images/ob1.gif)
- open a long position.
![OpenSELL](images/os1.gif)
- 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 ?
|