Reading Assignment: Pinescript

  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.
  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?
    This function sets a number of strategy properties. Examples can be: strategy(title, shorttitle, overlay and precision).
  4. What information does the Volume variable contain?
    the volume of the current bar.
1 Like

Hi everyone,

  1. It enables access to the previous values of a serie. For example for a daily time frame [1] will give you the value of the previous day, [2] 2 days ago, etc…if I understood correctly.
  2. It adds an input to a script indicator.
  3. It sets a number of strategy properties.
  4. The volume associated with the current bar. You can have past values using [] as well.
1 Like
  1. [ ] operator can be used to refer historical values. Historical values are variable values for the previous bars.

  2. The [input] function makes possible for script users to modify selected values from the script that can then use in its calculation or logic, without the need to modify the script’s code.

  3. A strategy is a Pine script that can send, modify and cancel buy/sell orders . Strategies allow you to perform backtesting and forwardtesting according to your algorithms.

  4. The volume Variable contains the current bar volume of trades.

1 Like
  1. What does the language operator [] do?
    It asks for the previous values or bars back.
  2. What does the input function do?
    Input adds input to the input tab of script setting.
  3. What does strategy function do?
    Adds parameters such as opening and closing a trade.
  4. What information does the volume variable contain?
    Current bar volume.
1 Like

1.It provides access to a value in the past of a given series. For instance ETH [3] is the value of 3 candels in the past.
2. It adds an input to our script
3.It sets up different strategy properties
4. It contains volume of the current bar

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

[] is used to reference numbers from previous candles

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

Adds an input to the script indicator.

  1. What does the Strategy function do?

Used to set the properties of a trading strategy

  1. What information does the Volume variable contain?

The volume bar, i.e. the volume being traded

1 Like

Familiarizing with PINESCRIPT

With the '[ ]' operator we can retrieve previous values from our expressions i.e. previous highs or lows of our bars. We have a lot of inputs variables. If we only focus on the basic one, we can change the variables that are displayed on our script. The strategy function allows us to define all the variables that we want to introduce for a trade to take place (Currency, Slippage, trading fees, initial capital and so on). The volume variable gives us the current bar volume of the trades executed all over the world.
1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
[] whatever is inside the language operator [] 
{ provides a value ||  series of values;}
  1. What does the input function do? (Hint: Try it in Tradingview)
    input option provides configuration options in the charts;
    oh man! i did my first try but have to add plot() into it to see on trading view what i was doing; i follow guidance from nefty.net
study(title="Aldrin_example indicator" , overlay=false)
//input options
data = input(title="Data", type=source, defval=close)
lookback = input(title="Lookback period", type=integer, defval=20)
lenMA = input(title="Lenght MA", type=integer, defval=12)

// Calculate rate of change and its MA
roc = roc(data, lookback) 
rocMA = sma(roc, lenMA)

// Plot values
plot(series=roc, title="RoC", color=teal, style=histogram, linewidth=4)
plot(series=rocMA, title="RoC MA", color=orange, linewidth=2)


3. What does the Strategy function do?
allows to set a buy/sell position of a trade
nefty.net for a sample stragegy

strategy(title="Stochastics strategy", overlay=true, scale=scale.left)

// Inputs
length  = input(title="Length", type=integer, defval=14)
dLength = input(title="D Length", type=integer, defval=3)
obLevel = input(title="Overbought", type=integer, defval=80)
osLevel = input(title="Oversold", type=integer, defval=20)

// Compute values
stochK = stoch(close, high, low, length)
stochD = sma(stochK, dLength)

// Plot values
plot(series=stochK, color=#1E90FF, title="K")
plot(series=stochD, color=orange, title="D")

hline(price=obLevel, color=#C0C0C0)
hline(price=osLevel, color=#C0C0C0)

// Submit orders
if (crossunder(stochK, osLevel))
    strategy.entry(id="Enter Long", long=true)

if (crossover(stochK, obLevel))
    strategy.entry(id="Enter Short", long=false)


4. What information does the Volume variable contain?
it provides the amount of trades done in any given timeframe or series of timeframes

1 Like
  1. previous values
    2.returns input value
    3.sets script as strategy for exit and enter
    4.buy/sell volume of candle
1 Like
  1. It saves variable data between bars.
  2. Allows you to provide configuration options to users.
  3. Designates the script as a strategy and sets a number of strategy-related properties.
  4. Current bar volume.
1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    Provides access to previous values of series.

  2. What does the input function do? (Hint: Try it in Tradingview)
    Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users.

  3. What does the Strategy function do?
    It designates the script as a strategy and sets a number of strategy-related properties.

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

1 Like
  1. [] is called series subscript and returns previous values in a series.
  2. The input function adds an input to the inputs tab of the settings of a script. This provides configuration options to users of the script.
  3. The strategy function designates the script as a strategy and sets a number of strategy-related properties.
  4. The volume variable holds the volume of the current bar. Previous values can be accessed with the series subscript.
1 Like
  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    • Used to access the previous value bars back from the current value
  2. What does the input function do? (Hint: Try it in Tradingview)
    • It adds an input to the script editor which can be edited by the user.
  3. What does the Strategy function do?
    • It’s a function that tells the language that this is a strategy function to execute. The strategy function has related properties to be configured by the engineer
  4. What information does the Volume variable contain?
    • It contains the volume of the current bar
1 Like
  1. Provides Access to the previos candles. So if you write [1] --> means previous candle
  2. Adds an input (specified from us) in the editor
  3. Is a function for our strategy. We are declearing a strategy in it.
  4. The current bar volume
1 Like
  1. Allows you to access the charts previous values.

  2. Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users.

  3. This declaration statement designates the script as a strategy and sets a number of strategy related properties.

  4. Previous values may be accessed with square brackets, or current bar volume.

1 Like

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.

What does the input function do? (Hint: Try it in Tradingview)
Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users. This function automatically detects the type of the argument used for ‘defval’ and uses the corresponding input widget.

What does the Strategy function do?
This declaration statement designates the script as a strategy and sets a number of strategy-related properties.

What information does the Volume variable contain?
Current bar volume

1 Like

1. What does the language operator [] do? (Hint: It’s not for regular arrays)
Series subscript. The integer inside the bars is the position of the candle you are using as a determining factor for your strategy. e.g.: expr[1] means the candle before the current candle.

2. What does the input function do? (Hint: Try it in Tradingview)
Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users.
3. What does the Strategy function do?
It declares the script as a strategy and sets the relevant properties.
4. What information does the Volume variable contain?
It contains the current bar volume.

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

The brackets “[]” are used to reference and extract previous data in the series.

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

Input function allows data input to edit variable value and set parameters when applicable.

  1. What does the Strategy function do?

Provides parameters for trading strategies for backtesting.

  1. What information does the Volume variable contain?

Yields the volume of a particular bar during a set period.

  1. What does the language operator [] do? (Hint: It’s not for regular arrays)
    The [] operator is a fundamental part of Pine Script that allows you to access individual elements of arrays and series

  2. What does the input function do? (Hint: Try it in Tradingview)
    Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users.

  3. What does the Strategy function do?
    This declaration statement designates the script as a strategy and sets a number of strategy-related properties. Arguments include; 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, slippage, commission_type, commission_value, process_orders_on_close, close_entries_rule, margin_long, margin_short, explicit_plot_zorder, max_lines_count, max_labels_count, max_boxes_count, risk_free_rate, use_bar_magnifier

  4. What information does the Volume variable contain?
    The volume variable contains the current bar volume of activity for a given bar or candel on a chart. It represents the total number of lots that have been traded during a specific period.

  1. What does the language operator [] do?

This operator provides access to previous values of a series (e.g., a price or indicator value). The value inside the brackets represents the number of bars ago, and it must be a numerical value.

  1. What does the input function do?

This function adds a configurable input field to the Inputs tab, allowing users to modify parameters within the script, such as numbers, booleans, or colors, directly from the interface.

  1. What does the strategy function do?

This function designates the script as a strategy, enabling it to backtest and generate orders based on specified conditions.

  1. What information does the volume variable contain?

The volume variable contains the trading volume of the current bar, representing the total number of the instrument traded during that time period.