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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.