The function returns the lot size, which is calculated based on the stop loss size and the risk specified in the variable. That is, if the risk is set to 2%, and the SL is set to 40 points, the lot will be calculated in such a way, that if the price reaches the SL, then 2% of the deposit would be lost.
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/14296
The function closes all locked orders. This really saves money on the spread.Divergence
Implementation of a trading system based on divergence detection.