79724692

Date: 2025-08-04 09:21:29
Score: 2.5
Natty:
Report link

Title: Pine Script v5 - "Cannot use 'plot' in local scope" error in a seemingly correct script

Hello,I am facing a persistent "Cannot use 'plot' in local scope" error in Pine Script v5, and I am unable to find the cause. The plotting and alertcondition functions are in the global scope, but the compiler seems to think they are in a local scope.

The error seems to be triggered by the combination of `request.security` calls and the `if` statements used for the state machine logic. The `bgcolor` function before the state machine works fine, but all `plot` functions after it fail. I have tried many different architectural patterns without success.

Could someone please review my code and explain why this error is occurring?

Here is the complete code:

// PASTE THE CODE FROM THE BLOCK BELOW HERE

Thank you fo

r your help!

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Shebaz