FAQ

How to fix it? ‘the script must have one study() or strategy() function call’

How to fix it? ‘the script must have one study() or strategy() function call’

Sometimes when adding a script to the chart in TradingView you might see the following error: “Add to Chart operation failed, reason: The script must have one study() or strategy() function call”.

This is happening because PineScript expects to see 1 study or strategy call in your script. Most likely you missed it when copied your script or accidentally delete it. Based on this function call TradingView can distinguish an indicator from a strategy for backtesting.

It’s very easy to solve that error, just add the following line at the very top of your script buy below “//@version=4”.

If you have an indicator:

study("My Script")

If you have a strategy for backtesting insert the following line:

strategy("My Script")

Follow me on TradingView and YouTube.

This image has an empty alt attribute; its file name is wide.png
Pine Script Programming Courses
Pine Script Programming Courses
Learn to build your own TradingView Indicators and Strategies
Sidebar Signup Form
If you want to be the first in this business, subscribe to the latest news