This is a fork of the original script by Balipour, with the addition of that can be used instead of in the Pearson correlation as an attempt to capture correlation trend changes more quickly, and conversion to pinescript v5. In the end, the does not help much, for a faster capture of correlation trend changes, another kind of correlation is necessary, such as sign test correlation (another one of my indicators implement this idea).
Please show the original indicator's author some love if you appreciate this work:
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.