Home » Input Functions » input.text_area Function in Pine Script

input.text_area Function in Pine Script

Photo of author
Published on

The input.text_area function is a powerful feature in Pine Script that provides script users with configuration options via the Inputs tab in the script’s Settings. This function adds a field for multiline text input, granting you the ability to offer complex inputs to your script. This tutorial will delve into the usage, syntax, and application of input.text_area.

Understanding input.text_area Function

The input.text_area function, when integrated into your Pine Script, lets you create an input field where users can provide multiline text. The input value can be accessed and utilized within your script to modify its behavior based on user inputs.

i_text = input.text_area(defval = "Hello \nWorld!", title = "Message")

In this example, the script creates a multiline text input field with the title “Message” and a default value of “Hello \nWorld!”. The user’s input is stored in i_text and can be used later in the script.

Function Syntax

The syntax for the input.text_area function is as follows:

input.text_area(defval, title, tooltip, group, confirm) → input string


  • defval (const string): Specifies the default value of the input variable displayed in the “Settings/Inputs” tab.
  • title (const string): Sets the title of the input. If not specified, the script uses the variable name as the title.
  • tooltip (const string): This string is displayed when the user hovers over the tooltip icon.
  • group (const string): This creates a header above all inputs using the same group argument string.
  • confirm (const bool): If true, the user will be asked to confirm the input value before the indicator is added to the chart. The default value is false.

Unique Use Case: Adding User Notes to Charts

Let’s consider a unique use case where we want to allow the user to add notes to a chart using the input.text_area function.

indicator("Chart Notes", overlay = true)
notes = input.text_area(defval = "Enter notes here", title = "Chart Notes", confirm = true)

l = label.new(x = bar_index, y = close, text = notes, xloc = xloc.bar_index, yloc = yloc.price, style = label.style_label_down , size = size.large)
input.text_area Function

In this script:

  1. We start by specifying the script version and setting the overlay to true to ensure that our labels are plotted directly onto the price chart.
  2. We create a multiline text input field with the title “Chart Notes” and a default value of “Enter notes here”. We set confirm to true to require users to confirm their notes before they are added to the chart.
  3. We use label.new to create a new label on the chart at the current bar (bar_index) and close price. The label’s text is set to the user’s notes input.

Key Takeaways

  • input.text_area in Pine Script allows users to input multiline text, which can be used to alter the behavior of the script.
  • Understanding the function arguments lets you customize the input field to your needs, including setting default values, adding tooltips, grouping inputs, and requiring user confirmation.
  • Unique applications of input.text_area, like adding user notes to a chart, can make your scripts more versatile and user-friendly.


Mastering the input.text_area function provides you with the tools to make your Pine Scripts more flexible and interactive. Its application extends far beyond the simple example given here, opening up endless possibilities for user-script interaction. Happy scripting!

Leave a Comment