Library "utils"
Provides a set of utility functions for use in strategies or indicators.

colorGreen(opacity)
  Parameters:
    opacity (int)

colorRed(opacity)
  Parameters:
    opacity (int)

colorTeal(opacity)
  Parameters:
    opacity (int)

colorBlue(opacity)
  Parameters:
    opacity (int)

colorOrange(opacity)
  Parameters:
    opacity (int)

colorPurple(opacity)
  Parameters:
    opacity (int)

colorPink(opacity)
  Parameters:
    opacity (int)

colorYellow(opacity)
  Parameters:
    opacity (int)

colorWhite(opacity)
  Parameters:
    opacity (int)

colorBlack(opacity)
  Parameters:
    opacity (int)

trendChangingUp(emaShort, emaLong)
  Signals when the trend is starting to change in a positive direction.
  Parameters:
    emaShort (float)
    emaLong (float)
  Returns: bool

trendChangingDown(emaShort, emaLong)
  Signals when the trend is starting to change in a negative direction.
  Parameters:
    emaShort (float)
    emaLong (float)
  Returns: bool

percentChange(start, end)
  Returns the percent change between a start number and end number. A positive change returns a positive value and vice versa.
  Parameters:
    start (float)
    end (float)
  Returns: float

percentOf(percent, n)
  Returns the number that's the percentage of the provided value.
  Parameters:
    percent (float): Use 0.2 for 20 percent, 0.35 for 35 percent, etc.
    n (float): The number to calculate the percentage of.
  Returns: float

targetPriceByPercent(percent, n)
  Parameters:
    percent (float)
    n (float)

hasNegativeSlope(start, end)
  Parameters:
    start (float)
    end (float)

timeinrange(resolution, session, timezone)
  Returns true when the current time is within a given session window. Note, the time is calculated in the "America/New_York" timezone.
  Parameters:
    resolution (simple string): The time interval to use to start/end the background color. Use "1" for the coloring the background up to the minute.
    session (simple string): The session string to use to identify the time window. Example: "0930-1600:23456" means normal market hours on weekdays.
    timezone (simple string)
  Returns: series bool

barsSinceLastEntry()
  Returns the number of bars since the last entry order.
  Returns: series int

barsSinceLastExit()
  Returns the number of bars since the last exit order.
  Returns: series int

calcSlope(ln, lookback)
  Calculates the slope of the provided line based on its x,y coordinates in the previous bar to the current bar.
  Parameters:
    ln (float)
    lookback (int)
  Returns: series float

openPL()
  Returns slope of the line given the start and end x,y coordinates.
  Returns: series float

hasConsecutiveNegativeCandles(lookbackInput)
  Returns true if the number of consecutive red candles matches the provided count.
  Parameters:
    lookbackInput (int): The amount of bars to look back to check for consecutive negative bars. Default = 1.
  Returns: series bool

stdevPercent(stdev, price)
  Returns the standard deviation as a percentage of price.
  Parameters:
    stdev (float): The standard deviation value
    price (float): The current price of the target ticker.
  Returns: series float
Pine脚本库

本着真正的TradingView精神,作者将此Pine代码以开源脚本库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码受网站规则约束。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想使用这个脚本库吗?

复制以下行并将其粘贴到您的脚本中。