PINE LIBRARY

WelcomeUDT

932
█  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®
export type Settings int bar float price string phrase ...


Example of library function to print out label.
Pine Script®
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
Pine Script®
Settings setup = Settings.new(bar_index[0], priceInput, phraseInput, colorInput, variableInput)


Alternative way to write types
Pine Script®
Settings setup = Settings.new( bar = bar_index[0], price = priceInput, phrase = phraseInput, variable = variableInput)


Usage of types into custom function / library function.
Pine Script®
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

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.