ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • pinescript: Operators
    개발 2023. 6. 2. 14:56
    • = is used to assign a value to a variable, but only when you declare the variable (the first time you use it)
    • := is used to assign a value to a previously declared variable. The following operators can also be used in such a way: +=, -=, *=, /=, %=

    -strength of forms: input<simple<series

     

    + Addition and string concatenation
    - Subtraction
    * Multiplication (also serve as the concatenation operator for strings)
    / Division
    % Modulo (remainder after division)

    아래 코드값의 결과는?

    //@version=5
    indicator("Modulo function")
    modulo(series int a, series int b) =>
        a - b * math.floor(nz(a/b))
    plot(modulo(-1, 100))

     

    < Less Than
    <= Less Than or Equal To
    != Not Equal
    == Equal
    > Greater Than
    >= Greater Than or Equal To
    not Negation
    and Logical Conjunction
    or Logical Disjunction

    ?: ternary operator

    condition ? valueWhenConditionIsTrue : valueWhenConditionIsFalse
    
    timeframe.isintraday ? color.red : timeframe.isdaily ? color.green : timeframe.ismonthly ? color.blue : na
    

    [] history-referencing operator

    -bar_index: counts from the oldest bar and its value 0

    -[]: counts from the current bar value 0 to backward.dynamically updated.

    -nz: null zero.built-in function).

    nz(series, series naValue) → series

    //@version=4 study("My Script") a = close[10] b = nz(a, 0) plot(b)

    plots 0 if there's no candle data

     

    PrecedenceOperator

    9 []
    8 unary +, unary -, not
    7 *, /, %
    6 +, -
    5 >, <, >=, <=
    4 ==, !=
    3 and
    2 or
    1 ?:

    var float  vs  float

     

     

    '개발' 카테고리의 다른 글

    pinescript: loops  (0) 2023.06.06
    pinescript: conditional structures  (0) 2023.06.05
    pinescript: variable declaration  (0) 2023.06.04
    pinescript: Identifiers  (0) 2023.06.02
    pinescript: objects,parameter  (0) 2023.06.01
Designed by Tistory.