Script Structure Flashcards
(20 cards)
What is the purpose of Pine Script?
Used in TradingView for custom indicators and strategies
What must be defined at the start of a Pine Script?
Pine Script version and whether you’re creating an indicator or strategy
What does //@version=5 signify?
Specifies that we are using Pine Script v5
What does the indicator function do?
Defines an indicator instead of a strategy
What does overlay=true indicate?
Plots on the main price chart
What is the purpose of the input function?
To create configurable user inputs
What type of input does length = input(14, title=’Length’) create?
Configurable numeric input
What does src = input(close, title=’Source’) allow the user to do?
Choose a data source
What is the purpose of ma = ta.sma(close, length)?
Calculates a 14-period Simple Moving Average
What does highBreakout = high > ta.highest(high, length) check?
If current high is highest in last length bars
What do the variables bullishSignal and bearishSignal represent?
Trading signals based on closing price relative to the SMA
What happens if bullishSignal is true?
A label is plotted above the price
What does plot(ma, title=’Moving Average’, color=color.blue) do?
Plots the moving average
Fill in the blank: To open a long position, use _______.
strategy.entry(‘Long’, strategy.long)
What does strategy.close(‘Long’) do?
Closes the long position
What is the function of alertcondition(bullishSignal, title=’Bullish Alert’, message=’Price above SMA!’)?
Sends an alert when bullishSignal is true
What does the full Pine Script indicator example plot?
A simple moving average and displays buy/sell signals
What are the two colors defined for buy/sell signals in the example?
- Bullish Color: green
- Bearish Color: red
What is the role of plotshape in the Pine Script?
Plots buy/sell signals on the chart
True or False: The script provides alerts when the price crosses the SMA.
True