It is primarily used in money management of open positions and placing pending Buy Stop and Sell-Stop orders.
The Expert Advisor first checks for the existence of a Buy Stop pending order. If a pending Buy Stop order does not exist, then it places a Buy Stop pending order Pipslong pips above the current Ask price. The stop-loss and take-profit of the pending order are set to Stop Loss and Take profit pips respectively.
However, if a pending Buy Stop order already exists, then it checks the distance between the current Ask price and the entry price of this pending Buy Stop order.If this distance is more than Pips long pips, then its entry price is modified to the current Ask price plus Pips long pips.
Likewise, if a pending Sell-Stop order does not exist, then it places a Sell-Stop pending order Pips short pips below the current Bid price.The stop-loss and take-profit of the pending order are set to Stop Loss and Take profit pips respectively.
However, if a pending Sell-Stop order already exists, then it checks the distance between the current Bid price and the entry price of the pending Sell-Stop order. If this distance is greater than Pips short pips, then its entry price is modified to the current Bid price minus Pips short pips.