If the stock is rising and making new highs, ideally the is reaching new highs as well. If the stock is making new highs, but the starts making lower highs, this warns the price uptrend may be weakening. This is negative divergence.
Positive divergence is the opposite situation. Imagine the price of a stock is making new lows while the makes higher lows with each swing in the stock price. Investors may conclude that the lower lows in the stock price are losing their downward momentum and a trend reversal may soon follow.
Divergence is one of the common uses of many technical indicators, primarily the oscillators.
Use it at your own risk
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.