简体   繁体   中英

what is [] in pine-script?

what is value of _smoothed[1] variable in below code?

f_zrsi( _source, _length ) => rsi( _source, _length ) - 50

f_rsi( _source, _length, _mode ) =>
    //  get base rsi
    float _zrsi = f_zrsi( _source, _length )

    //  smoothing in a manner similar to HA open, but rather using the realtime
    //  rsi in place of the prior close value.
    var float _smoothed = na
    _smoothed := na( _smoothed[1] ) ? _zrsi : ( _smoothed[1] + _zrsi ) / 2

    //  return the requested mode
    _mode ? _smoothed : _zrsi

It is called the History Reference Operator and is used to access historical data.

In your example, _smoothed[1] returns the previous value of _smoothed .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM