PINE LIBRARY
WelcomeUDT

█ OVERVIEW
This is a simplest example of user-defined types (UDT) or objects, which simplify as alternative to hello world.
█ CREDITS
Tradingview
█ USAGE
These are the types used during initializations, commonly variables.
Pine Script®
Example of library function to print out label.
Pine Script®
Usage of types
Pine Script®
Alternative way to write types
Pine Script®
Usage of types into custom function / library function.
Pine Script®
printLabel(Settings)
Print out label
Parameters:
Settings: types
Returns: Label object
Settings
Initialize type values
Fields:
bar: X position for label
price: Y position for label
phrase: Text for label
bg: Color for label
variable: Boolean for enable new line and delete line
This is a simplest example of user-defined types (UDT) or objects, which simplify as alternative to hello world.
█ CREDITS
Tradingview
█ USAGE
These are the types used during initializations, commonly variables.
export type Settings
int bar
float price
string phrase
...
Example of library function to print out label.
export printLabel(Settings setup) =>
if setup.variable
var label lab = na
label.delete(lab)
lab := label.new(setup.bar, setup.price, setup.phrase, color = setup.bg)
else
label.new(setup.bar, setup.price, setup.phrase, color = setup.bg)
Usage of types
Settings setup = Settings.new(bar_index[0], priceInput, phraseInput, colorInput, variableInput)
Alternative way to write types
Settings setup = Settings.new(
bar = bar_index[0],
price = priceInput,
phrase = phraseInput,
variable = variableInput)
Usage of types into custom function / library function.
printLabel(setup)
printLabel(Settings)
Print out label
Parameters:
Settings: types
Returns: Label object
Settings
Initialize type values
Fields:
bar: X position for label
price: Y position for label
phrase: Text for label
bg: Color for label
variable: Boolean for enable new line and delete line
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。