While programming has become increasingly simple in recent years, there are still hurdles that new developers have to jump over, including but not limited to random error messages that can be rather vague. This is especially true if you’re using external APIs and using an unfamiliar programming language.
In this article, we’re talking about the “Compilation error: Script could not be translated from: Null”, its causes and what you can do to fix the problem.
What causes this error?
As the error itself suggests, the issue arises from a compilation error in the script. This often happens in Pinescript code using external AI APIs. The most common reason for this is that at least part of the script, or in some cases the entire script isn’t written in Pinescript.
You’ll see this specific error message in version one pine scripts and it generally indicates that the code itself is incorrect. Pine version two and higher are better at explaining such errors.
How to fix this?
The obvious fix is to refer to the Pinescript manual or the Pinescript primer to cross-check your script and make sure it’s written in Pinescript as described by the manual. Once your script is written according to Pine standards and is correct from a syntax perspective, the error will be resolved.
Alternatively, you can change your Pine version to version two or above to better understand what exactly is causing the problem. You can do this by adding the following compiler directive in the first line of your script.
‘N’ in the command mentioned above tells the compiler which Pine version (one to four) to use. For versions two and above, the compiler will give you the exact line of the error and what exactly you need to change.