Reading Assignment: Pinescript

  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    [] is used to declare the number of bars (candles) back (previous), using integers as parameters.

  2. What does the input function do? (Hint: Try it in Tradingview)
    Data input.

  3. What does the Strategy function do?
    The strategy function, along with its sub-functions, allows the user to set the specifics of the trading strategy in terms of buying/selling based on the user’s analysis.

  4. What information does the Volume variable contain?
    Current bar info: open/close, high/low.

  1. [] allows access to previous values of series. [x] where x is the number of periods in the past.

  2. The input function adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study.

  3. The function sets a number of strategy properties.

  4. The Volume variable contains the amount of volume traded during a given period.

  1. With the operator [] you have access to the previous value of an expression (e. g. candle stick). Inside the [] operator you define the number of bars you want to go back.

  2. With the input function you allow users to interact with your script indicator. Users can see and edit (e. g. change the number or boolean value) the input. The dialog which will be opene looks exactly the same as the built-in technical analysis indicators.

  3. The strategy function allows you to define the parameters of your trading setup, e. g. the entry, close, stop loss, take profit etc.

  4. volume return the current value of the volume bar

1.It can be used for save values between bars.

2.It adds an input.

3.If you are building a strategy then you will have to use the strategy function, which specifies the script name and some other script properties.

4.The volume variable store a current value of trade volume bars.

  1. The language operator [] let’s you query past instances of a variable. By adding a number inside the bracket you indicate how many previous bars or candles in the series you are referring to.
    Can be applied to open/close/low,high.
  2. Adds different settings to an object (like a plot or chart) where you can have an input that can change variables without modifying the code.
  3. Defines specific parameters for the trading strategy, like the conditions for entering/exiting the market. It can be used to backtest the strategy.
  4. Exposes current bar volume (how much was traded during that bar).

1- Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down.

2- Adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study.

3- The strategy function sets a number of strategies such as title, shorttitle, overlay, precision, scale, pyramiding, calc_on_order_fills, calc_on_every_tick, max_bars_back, backtest_fill_limits_assumption, default_qty_type, default_qty_value, initial_capital, currency, slippage, commission_type and commission_value.

4- The current bar volume, can also refer back to a previous bar with [].

1 Like
  • What does the language operator [] do? (Hint: It’s not for regular arrays)
    The [] symbol sends to previous values of series. It must be numerical.

  • What does the input function do? (Hint: Try it in Tradingview)
    The input function allow to add an input to the script code.

  • What does the Strategy function do?
    The Strategy function allows to send, cancel or modify buy/sell orders.
    Can be used in emulation mode (backtesting or forward testing).

  • What information does the Volume variable contain?
    The Volume variable tells the current bar volume.

1 Like
  1. In Pinescript the language operator [ ] is used as a subscript, which can call on values inside of the series it is the subscript of. Using numbers inside of the subscript brackets, you can reference previous candles on the chart. Putting a zero in the chart would reference the current days candle, while putting a one would reference yesterday, and a two would reference the day before yesterday and so on.

  2. The input function is used to add specified indicators to your program through the script editor.

  3. The strategy function allows for the setting of certain parameters and properties that the program will follow in the trading environment.

  4. The volume variable feeds your program data on the current bars volume level.

1 Like
  1. Operator [] is a series subscript. Provides access to previous values of series.
  2. Input function adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.
  3. Strategy function sets a number of strategy properties.
  4. Volume variable contains current bar volume.

#1 - What does the language operator [] do?
It provides access to to previous values

#2 - What does the input function do?
It adds an input to a script indicator

#3 - What does the Strategy function do?
It determines the basic parameters for the current strategy

#4 - What information does the Volume variable contain?
It contains the current bar volume

  1. Series subscript. Provides access to previous values of series. The number in [] is the number of bars back, and must be numerical. Floats will be rounded down.
  2. Adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study.
  3. The function sets a number of strategy properties.
  4. Current bar volume.
  1. It is a series subscript of which stores previous values for a given series.
  2. The input function adds an input with parameters for the trading strategy
  3. The volume variable contains the volume of the current bart and the previous bar.
    4.The volume variable contains the volume bar and using the [] gives previous bar
  1. [] is series subscript to set a previously set variable. The number within indicates how many bars back it goes.
  2. This function adds an input into the script editor.
  3. This function sets a number of strategy properties.
  4. The current traded volume (buy /sell) or on a given bar.
  1. [] allows you to access the previous values in the series.
  2. Input functions allows you to add an input to your script indicator.
  3. Strategy function allows you to define a strategy.
  4. Volume variable contains the volume of a bar.

What does the language operator [] do? (Hint: It’s not for regular arrays)

  • Provides access to previous values of series, with this operator you can query previous values.

What does the input function do? (Hint: Try it in Tradingview)

  • Adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study, in this way some edits will be faster and don’t need to get manually adjusted on the code

What does the Strategy function do?

  • This function sets some properties in our script

What information does the Volume variable contain?

  • Contains the volume of current candle, if we use this variable with operator [] we can access to previous data
1 Like

What does the language operator [] do? (Hint: It’s not for regular arrays) Answer: It is a series subscript that provides access to previous series of values
What does the input function do? (Hint: Try it in Tradingview) Answer: It adds an input to your script indicator.
What does the Strategy function do? Answer: The strategy function configures the strategy settings and sets a number of strategy properties.
What information does the Volume variable contain? Answer: Current Candle volume

  1. What does the language operator [] do? (Hint: It’s not for regular arrays)

Allows you to query previous variables, in this case prices.

  1. What does the input function do? (Hint: Try it in Tradingview)

Allows for data input into the script code. These behave like the TA indicators built into Tradingview.

  1. What does the Strategy function do?

Strategy is used for defining the logic for the trading strategy (ex. strategy.entry(“entry long”, true, 1, when = close < high[1])

  1. What information does the Volume variable contain?

The amount of volume in the current bar referenced.

1 Like

1: [] let you reference to previous value of sequence when number is passed in.
2: let the user input data
3: set up strategy object which can be later referet to
4: it stores the value of current volume

[ ] returns the value in a series relative to the current position. In the context of this course Open[1] would return the opening value of the previous candle.

The Input function allows the user to provide values to the script via the settings button when the script is running. It is a way of communicating with the script whilst it runs and enables the user to see changes instantly. The input function also allows the user to change parameters without going into the script.

The strategy function allows the user to setup general parameters such as the title, which data is to be used and in which window. The function is usually called at the start to give context and limitations within which the script will run.

The Volume variable contains the total amount traded on the current candle. The previous candle’s volume can also be accessed by using [ ] e.g. volume[1]

  1. [] stores values from previous candles.
  2. The input functions allows you to input data/functions/indicators.
  3. The strategy function allows you to set a number of properties to a strategy.
  4. The volume variable gives you the actual volume bar.