OPEN-SOURCE SCRIPT
Double Top/Bottom Screener with Distance.

Thank you for providing the error messages! There are two issues to address based on your input:
Error: "Value with NA type cannot be assigned to a variable that was defined without type keyword"
This occurs because in Pine Script, when a variable like distanceToNearest is used without an explicit type declaration (e.g., var float distanceToNearest), assigning na directly to it can cause a type mismatch error if the variable’s type isn’t pre-defined. The fix is to either declare distanceToNearest with a type (e.g., var float) or ensure the assignment aligns with Pine Script’s typing rules.
Warning: "Version 5 of Pine Script® is outdated. We recommend using the current version, which is 6. (PINE_VERSION_OUTDATED)"
TradingView has updated to Pine Script version 6, which includes new features and improvements. While version 5 still works, upgrading to version 6 is recommended for better compatibility and future support. The transition is mostly seamless, but we’ll need to adjust the script accordingly.
Error: "Value with NA type cannot be assigned to a variable that was defined without type keyword"
This occurs because in Pine Script, when a variable like distanceToNearest is used without an explicit type declaration (e.g., var float distanceToNearest), assigning na directly to it can cause a type mismatch error if the variable’s type isn’t pre-defined. The fix is to either declare distanceToNearest with a type (e.g., var float) or ensure the assignment aligns with Pine Script’s typing rules.
Warning: "Version 5 of Pine Script® is outdated. We recommend using the current version, which is 6. (PINE_VERSION_OUTDATED)"
TradingView has updated to Pine Script version 6, which includes new features and improvements. While version 5 still works, upgrading to version 6 is recommended for better compatibility and future support. The transition is mostly seamless, but we’ll need to adjust the script accordingly.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.