fbpx

Home > Blog > Pine Script Tutorial > Pine Script Tutorial – User input variable and hline()

Pine Script Tutorial – User input variable and hline()

Published by Ali Muhammad
Updated on

The inputs that a user can change later from the setting panel of indicators are referred to as user inputs in the pine script. These inputs are stored in variables called user input variables.

User input variable types are following

  • Input.integer
  • Input.bool
  • Input.string
  • Input.symbol
  • Input.resolution
  • Input.session
  • Input.source

User input variables

In the input function, many other parameters are also available like title, default value, input type, etc. Boolean variable only accepts one input value either true or false. In the input bool type, a box will appear in the setting panel. We can check (means true) or uncheck (means false) the box.  We can assign a default value either false or true.

Input integer type will accept only integer value and minval here refers to the minimum value and maxval represents the maximum value. The input float type is also the same just it will accept a float value (value with a decimal place).

Options parameter will pop up a drop-down list to select desired value from pre-defined values only.

The input symbol type is used to add a symbol to the code. For example, EURUSD, GBPUSD, etc. you can change the symbol later from the setting panel of the indicator by saving another currency symbol.  

Input resolution type is used to set the timeframe of the chart. The default value can also be set. A value of 15 means a 15-minute timeframe. In the setting panel, a drop-down list of timeframes will appear automatically so a timeframe can be changed easily from the setting panel. Input source type will give access to OHLC values (open, high, low, close).

type_integer = input(defval=5, title= "number", type=input.integer, minval=5, maxval= 100, confirm=true , step = 5)
type_bool = input(defval=true, title="true/false", type=input.bool, confirm=true)
type_float = input(defval=5.0, title= "number", type=input.float, minval=5, maxval= 100, confirm=true , step = 5)
type_string = input(defval="100", title="input value", type=input.string , options=["100","200","300"] , confirm=true)
tpe_symbol = input(defval="EURUSD", title="currency symbol", type=input.symbol, confirm=true)
type_timeframe = input(defval="1", title="timeframe", type=input.resolution , confirm=true)
pine script tutorial

How to draw a horizontal line in pine script?

To draw a horizontal line in the pine script programming language, hline() function is used. Add a constant value in the input of hline() function. There are also many other parameters in hline function like title, line style, line width, and color.

hline(1750, title="support level", linewidth=2, linestyle=hline.style_solid,  editable=true) 

The above code will draw a horizontal line at 1750 (support level in Gold).

I hope you will like this Article. For any Questions Comment below, also share by below links.

Note: All the viewpoints here are according to the rules of technical analysis. we are not responsible for any type of loss in forex trading.

Do you want to get success in Trading?

Here's the Roadmap:

1. Learn supply and demand from the cheat sheet here
2. Get access the Supply & Demand Indicator here
3. Understand the fair value gap here
4. Use the set and forget strategy here
5. Follow the risk management plan here

Leave a Comment