The script defines the place where it has been dragged by the mouse and looks for the nearest bar. The process is based on the concept of bar boundaries:

Tradotto dal russo da MetaQuotes Ltd.
Codice originale https://www.mql5.com/ru/code/16926
TrendMeLeaveMe
The semi-automated Expert Advisor using a trend line (TrendLIne).
Simplest Hedging EA ever
Only for hedge accounts. Opening two opposite positions on a new bar.
BBand Width Ratio
An implementation of Bollinger Bands width indicator for MetaTrader 5.
Fractal_Keltner
Fractal channel by Keltner.