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提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想使用這個腳本庫嗎?

複製以下行並將其黏貼到您的腳本中。