PINE LIBRARY

ta

已更新
Library "ta"
This library is a Pine Script™ programmer’s tool containing calcs for my oscillators and some helper functions.

buoyancy(src, targetPeriod, maxLookback)
  Calculates buoyancy using a target of `src` summed over `targetPeriod` bars, not searching back farther than `maxLookback` bars. See:
Volume Buoyancy [LucF]

  Parameters:
    src: (series float) The source value that is summed to constitute the target.
    targetPeriod: (series int) The qty of bars to sum `src` for in order to calculate the target.
    maxLookback: (simple int) The maximum number of bars back the function will search.
  Returns: (series float) Buoyancy: the gap between the avg distance of past up and dn bars added to reach the target, divided by the max distance reached. Returns zero when an error condition occurs.

efficientWork(length)
  Calculates Efficient Work on `length` bars. See:
Efficient Work [LucF]

  Parameters:
    length: (simple int) The length of the ALMA used to calculate the result.
  Returns: (series float) A -1 to +1 value representing the efficiency of price travel, bar to bar.

ma(type, src, length)
  Returns the `type` MA of the `src` over the `length`.
  Parameters:
    type: (simple string) The type of MA required (uses constants that must be defined earlier in the script).
    src: (series float) The source value used to calculate the MA.
    length: (simple int) The length value used to calculate the MA.
  Returns: (series float) The MA value.

divergenceChannel(divergence, hiSrc, loSrc, breachHiSrc, breachLoSrc)
  Calculates the levels and states of divergence channels, which are created when divergences occur.
  Parameters:
    divergence: (series bool) `true` on divergences, which can be defined any way. On breached channels it creates a new channel, otherwise, channel levels are expanded.
    hiSrc: (series float) The price source used to set the channel's hi level when a divergence occurs.
    loSrc: (series float) The price source used to set the channel's lo level when a divergence occurs.
    breachHiSrc: (series float) The price source that must breach over the channel's `channelHi` level for a breach to occur.
    breachLoSrc: (series float) The price source that must breach under the channel's `channelLo` level for a breach to occur.
  Returns: A tuple containing the following values:
[
(series float) channelHi — the channel's high level,
(series float) channelLo — the channel's low level,
(series bool) channelIsBull — `true` when `breachHiSrc` is higher than the channel's high,
(series bool) channelIsBear — `true` when `breachLoSrc` is lower than the channel's low,
(series bool) channelWasBreached — `true` on the first bar where `breachHiSrc`/`breachHiSrc` breaches the channel's high/low level,
(series bool) newChannel — `true` when a new divergence on a breached channel causes a new channel to be created,
(series int) preBreachUpChanges — Number of times the channel's high level was increased,
(series int) preBreachDnChanges — Number of times the channel's low level was decreased
]

sourceStrToFloat(srcString)
  Converts the name of a source in the `srcString` to its numerical equivalent.
  Parameters:
    srcString: (series string) The string representing the name of the source value to be returned.
  Returns: (series float) The source's value.
發布通知
v2

Added:
sott()
  Calculates an instant value for Signs of the Times, a directional measure of bar strength.
  Returns: (series float) SOTT: a value between -1 and +1.
發布通知
v3

Added:
zeroOne(cond)
  Converts a "bool" cond to 1 when it is `true`, 0 when it's false.
  Parameters:
    cond (bool): (bool) The "bool" value to be converted.
  Returns: (int) 1 when `cond` is `true`, `false` otherwise.

addTextIf(cond, msg, txt, sep)
  Appends `sep` and `txt` to `msg` when `cond` is true.
  Parameters:
    cond (bool): (bool) The condition determining if text will be added.
    msg (string): (string) The string to which we add text.
    txt (string): (string) The text to be added.
    sep (string): (string) A separator string to be added before `txt` when `msg` already contains text.
  Returns: (int) The modified `msg` string if `cond` is `true`. Returns `msg` unchanged if `cond` is `false`.

gradientAdvDecPro(source, center, steps, bearWeakColor, bearStrongColor, bullWeakColor, bullStrongColor)
  Calculates a gradient between two bull or two bear colors, depending on whether the source signal is above/below the centerline.
The gradient is proportional to the current qty of advances/declines of the `source`.
The count of advances/declines resets to one when the `source` crosses the `center` and is limited by `steps`.
  Parameters:
    source (float): (float) input signal.
    center (float): (float) (- ∞ to ∞) centerline used to determine if signal is bullish/bearish.
    steps (float): (float) Maximum number of steps in the gradient from the weak color to the strong color.
    bearWeakColor (color): (color) bear color at adv/dec qty of 1.
    bearStrongColor (color): (color) bear color at adv/dec qty of `steps`.
    bullWeakColor (color): (color) bull color at adv/dec qty of 1.
    bullStrongColor (color): (color) bull color at adv/dec qty of `steps`.
  Returns: (color) The calculated color.

upDnIntrabarVolumesByPolarity()
  Determines if the volume for an intrabar is up or down.
  Returns: ([float, float]) A tuple of two values, one of which contains the bar's volume. `upVol` is the positive volume of up bars. `dnVol` is the negative volume of down bars.
Note that when this function is designed to be called with `request.security_lower_tf()`,
which will return a tuple of "array<float>" arrays containing up and dn volume for all the intrabars in a chart bar.
techindicator

Pine腳本庫

在真正的TradingView精神中,作者將這段Pine程式碼發佈為開源程式庫,以便我們社群的其他Pine程式設計師可以重複使用它。請向作者致敬!您可以私下使用這個函式庫,或在其他開源出版品中使用,但在出版物中再次使用這段程式碼將受到網站規則的約束。


"The stock market is a device for transferring money from the impatient to the patient."
— Buffet

tradingview.com/u/PineCoders/
tradingview.com/u/TradingView/
更多:

免責聲明