Reading Assignment: Pinescript

  1. The language operator [] :
  • provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down - expr1[expr2].
  • Returns: A series of values.
  • i.e.:open[1] or open[2], close[1], high[1], low[1]
    That is how we refference previous candles if we want to make a statement or a check of multiple candles. I want to check the current candle, the previous candle and the one before that.
  1. 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. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.
  • Returns: Value of input variable.
  • Input is a named string constant for # input type of function
    (# = bool, color, float, integer, resolution, session, source, string, symbol, time)
    => input.bool / input.color…
  1. Strategy function:
    a1) generates/activates strategies: i.e. strategy.order, strategy.entry and strategy.exit
    a2) strategy.cancel - is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.exit, strategy.entry and strategy.close.
    a3) i.e. strategy.direction.all / (#=long, short) - allows strategy to open both long and short positions / or #,

b1) it calculates the result of the strategy we used dependant on the type of strategy used we isolate with commands,
b2) calculates dependant on the commands i.e. strategy.closedtrades - number of trades, which were closed for the whole trading interval.
(# position_size, opentrades, wintrades, losstrades, eventtrades),
b3) i.e. strategy.position_avg_price - calculates the average entry price of current market position.

  1. The volume variable contains the current bar volume.
    Previous values may be accessed with square brackets operator [], e.g. volume[1], volume[2].
1 Like
  1. The [] operator in Pinescript is a series subscript operator which provides access to previous values in a series. The [] operator returns a series of values.

  2. The input function adds an input to your script indicator and returns the value of the input variable.

  3. The strategy function allows the programmer to select and modify various parameters to formulate the desired trading strategy in to a trading system.

  4. The volume variable contains the current volume bar’s data.

1 Like
  1. What does the language operator [] do?
    Provides access to previous values.

  2. What does the input function do?
    It allows you to input data on your chart.

  3. What does the Strategy function do?
    Sets a number of strategy properties

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

1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    [] can be used to “save” variable value between bars
  2. What does the input function do? (Hint: Try it in Tradingview)
    Adds an input to your script indicator (bool, colour, integer…), returns value of input variable.
  3. What does the Strategy function do?
    The function sets a number of strategy properties, every strategy script must have one strategy call.
  4. What information does the Volume variable contain?
    It contains the current bar volume of trades.
1 Like
  1. The square brackets provide access to the values of series and the inputted number is the amount of bars you want to go back.
    E.g. high[2] = the high of the candle going back two bars in the series.

  2. It allows you to add an input. It also creates a widget which makes it easy to change variables without updating your code.

  3. It is functions that sets up and defines your strategy properties.
    E.g. strategy.entry(“buy”, true, when = open > close[1])
    The code above will enter a long position when the current open price is greater than the previous close. please correct if I’m using the open and close vars wrong.

  4. The volume of the current bar.

1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical.

  2. What does the input function do? (Hint: Try it in Tradingview)
    it adds input to script indicator

  3. What does the Strategy function do?
    performs proposed strategy

  4. What information does the Volume variable contain?
    current bar volume

1 Like
  1. What does the language operator [] do?

As mentioned in the video “variables” expr1[expr2] references to previous candles.

expr2 is indexed positive into the past.

For example:

  • current open … open

  • previous candle open …open[1]

expr2 is an integer and decimal points are just cut.

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

input allows you to create a settings menu where you can allow all kind of value inputs instead of changing hard coded settings in the script.

  1. What does the Strategy function do?

In contrast to the “study” function the “strategy” function can be backtested and is also able to generate buy and sell orders.

  1. What kind of information does the Volume variable contain?

It contains the volume which was traded of the bar.

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

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

  1. 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. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.
3. What does the Strategy function do?

Implement different strategy properties.

  1. What information does the Volume variable contain?
    Volume of current and previous bar
1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    Series subscript. 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. 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. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.

  3. What does the Strategy function do?
    The function sets a number of strategy properties.

  4. What information does the Volume variable contain?
    Current bar volume.

1 Like

1 [ ]

expr1[expr2] Series subscript. Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical.

2 input

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. Enables this type dialog box:image

3 strategy

The function sets a number of strategy properties. Every strategy script must have one strategy call. Just the title argument is required, the others are optional.

strategy(title, shorttitle, overlay, format, 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, max_lines_count, max_labels_count, slippage, commission_type, commission_value, process_orders_on_close, close_entries_rule) → void

4 volume

Current bar volume. (= number of contracts exchanged during the time of the current bar.)
volume[n] returns the volume of the n:th prior bar.

1 Like
  1. Provides access to previous values of series. It is the number of bars back, and must be numerical.
  2. Provides an interface so you can edit the variable value via script settings.
  3. The function sets a number of strategy properties.
  4. Volume of current bar and previous bar.
1 Like
  1. The [] operator provides access to previous values in a series. The number within the brackets indicates the number of bars back you want to reference.

  2. The input function adds an input to your script indicator.

  3. The strategy function sets a number of properties related to the strategy.

  4. The Volume variable contains the current bar volume and previous values may be accessed using square brackets.

1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    This operator allows you to go back N number of candles in the period

  2. What does the input function do? (Hint: Try it in Tradingview)
    It adds a new input to the script editor

  3. What does the Strategy function do?
    it adds a strategy through parameters. There are many available parameters to use in the strategy.

  4. What information does the Volume variable contain?
    This is used to reference the volume for a given bar

1 Like

1.) What does the language operator [] do? (Hint: It’s not for regular arrays)
A.)It enables you to access historical(past) data/information. in this case (candles) put value within the [5] brackets and it return value of candle -5 assuming starting point being 0 .
2.) What does the input function do? (Hint: Try it in Tradingview)
A.)the UI enables user to test different variables in the script, it returns a new input value. ( very useful in my opinion.)
3.) What does the Strategy function do? it adds a new input/value.
A.)
4.) What information does the Volume variable contain?
A.)It holds the current/todays trading volume.

1 Like

1. What does the language operator [] do? (Hint: It’s not for regular arrays)
It provides access to previous values of series.
Example : open[1] refers to the previous(one back) candle, and give access to that specific candles open value.

2. What does the input function do? (Hint: Try it in Tradingview)
The input function is used to add or edit an input to your script, and it behave exactly the same as inputs of built-in TA indicators.

3. What does the Strategy function do?
The function sets a number of strategy properties.
Example: Strategy.entry = where to enter position
Strategy.close = where to close position

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

1 Like

1. What does the language operator [] do? (Hint: It’s not for regular arrays)
Series subscript. Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical.

2. 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. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.

3. What does the Strategy function do?
declares a strategy object which can be then used to entry/exit/etc.

4. What information does the Volume variable contain?
Amount of the instrument traded on a given time period (given “candle”)

1 Like
  1. The [] operator is used to access previous values from the series data structure

  2. Input allows you to give input to the script

  3. strategy() is used name the strategy

  4. Volume is the total amount of trades per candle

1 Like

[quote=“filip, post:1, topic:7685”]

  • What does the language operator [] do? (Hint: It’s not for regular arrays)
    Lets access to previous values of series
  • What does the input function do? (Hint: Try it in Tradingview)
    It adds an input to a script indicator.
  • What does the Strategy function do?
    The function sets a number of strategy properties to applies the logic of the strategy to a series of data.
  • What information does the Volume variable contain?
    It contains the current bar volume of trades.
1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)

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

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

It allows you to add or edit your input.

  1. What does the Strategy function do?

The function sets a number of strategy properties. It is highly recommended to use standard chart type together with strategy

  1. What information does the Volume variable contain?

Current bar volume. Volume is the total number of shares or contracts exchanged between buyers and sellers

1 Like

1.It provides access to previous values of series EXPR1,EXPR2 is the number bars back and need to be numerical
2.it adds a input that can change variables without modifying the code
3.use the strategy function tool, which specifies the script name and script properties
4. the volume variable store a current value of trade volume bars (how much was traded during that bar)

1 Like