Wheeelman

Library Common

Library "LibraryCommon"
A collection of custom tools & utility functions commonly used with my scripts
@description TODO: add library description here

getDecimals() Calculates how many decimals are on the quote price of the current market
  Returns: The current decimal places on the market quote price

truncate(float, float) Truncates (cuts) excess decimal places
  Parameters:
    float: number The number to truncate
    float: decimalPlaces (default=2) The number of decimal places to truncate to
  Returns: The given number truncated to the given decimalPlaces

toWhole(float) Converts pips into whole numbers
  Parameters:
    float: number The pip number to convert into a whole number
  Returns: The converted number

toPips(float) Converts whole numbers back into pips
  Parameters:
    float: number The whole number to convert into pips
  Returns: The converted number

getPctChange(float, float, int) Gets the percentage change between 2 float values over a given lookback period
  Parameters:
    float: value1 The first value to reference
    float: value2 The second value to reference
    int: lookback The lookback period to analyze

av_getPositionSize(float, float, float, float) Calculates OANDA forex position size for AutoView based on the given parameters
  Parameters:
    float: balance The account balance to use
    float: risk The risk percentage amount (as a whole number - eg. 1 = 1% risk)
    float: stopPoints The stop loss distance in POINTS (not pips)
    float: conversionRate The conversion rate of our account balance currency
  Returns: The calculated position size (in units - only compatible with OANDA)

bullFib(priceLow, priceHigh, fibRatio) Calculates a bullish fibonacci value
  Parameters:
    priceLow: The lowest price point
    priceHigh: The highest price point
    fibRatio: The fibonacci % ratio to calculate
  Returns: The fibonacci value of the given ratio between the two price points

bearFib(priceLow, priceHigh, fibRatio) Calculates a bearish fibonacci value
  Parameters:
    priceLow: The lowest price point
    priceHigh: The highest price point
    fibRatio: The fibonacci % ratio to calculate
  Returns: The fibonacci value of the given ratio between the two price points

getMA(int, string) Gets a Moving Average based on type (MUST BE CALLED ON EVERY CALCULATION)
  Parameters:
    int: length The MA period
    string: maType The type of MA
  Returns: A moving average with the given parameters

getEAP(float) Performs EAP stop loss size calculation (eg. ATR >= 20.0 and ATR < 30, returns 20)
  Parameters:
    float: atr The given ATR to base the EAP SL calculation on
  Returns: The EAP SL converted ATR size

getEAP2(float) Performs secondary EAP stop loss size calculation (eg. ATR < 40, add 5 pips, ATR between 40-50, add 10 pips etc)
  Parameters:
    float: atr The given ATR to base the EAP SL calculation on
  Returns: The EAP SL converted ATR size

barsAboveMA(int, float) Counts how many candles are above the MA
  Parameters:
    int: lookback The lookback period to look back over
    float: ma The moving average to check
  Returns: The bar count of how many recent bars are above the MA

barsBelowMA(int, float) Counts how many candles are below the MA
  Parameters:
    int: lookback The lookback period to look back over
    float: ma The moving average to reference
  Returns: The bar count of how many recent bars are below the EMA

barsCrossedMA(int, float) Counts how many times the EMA was crossed recently
  Parameters:
    int: lookback The lookback period to look back over
    float: ma The moving average to reference
  Returns: The bar count of how many times price recently crossed the EMA

getPullbackBarCount(int, int) Counts how many green & red bars have printed recently (ie. pullback count)
  Parameters:
    int: lookback The lookback period to look back over
    int: direction The color of the bar to count (1 = Green, -1 = Red)
  Returns: The bar count of how many candles have retraced over the given lookback & direction

getBodySize() Gets the current candle's body size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's body size in POINTS

getTopWickSize() Gets the current candle's top wick size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's top wick size in POINTS

getBottomWickSize() Gets the current candle's bottom wick size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's bottom wick size in POINTS

getBodyPercent() Gets the current candle's body size as a percentage of its entire size including its wicks
  Returns: The current candle's body size percentage

isHammer(float, bool) Checks if the current bar is a hammer candle based on the given parameters
  Parameters:
    float: fib (default=0.382) The fib to base candle body on
    bool: colorMatch (default=false) Does the candle need to be green? (true/false)
  Returns: A boolean - true if the current bar matches the requirements of a hammer candle

isStar(float, bool) Checks if the current bar is a shooting star candle based on the given parameters
  Parameters:
    float: fib (default=0.382) The fib to base candle body on
    bool: colorMatch (default=false) Does the candle need to be red? (true/false)
  Returns: A boolean - true if the current bar matches the requirements of a shooting star candle

isDoji(float, bool) Checks if the current bar is a doji candle based on the given parameters
  Parameters:
    float: wickSize (default=2) The maximum top wick size compared to the bottom (and vice versa)
    bool: bodySize (default=0.05) The maximum body size as a percentage compared to the entire candle size
  Returns: A boolean - true if the current bar matches the requirements of a doji candle

isBullishEC(float, float, bool) Checks if the current bar is a bullish engulfing candle
  Parameters:
    float: allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
  Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle

isBearishEC(float, float, bool) Checks if the current bar is a bearish engulfing candle
  Parameters:
    float: allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
    float: rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
    bool: engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
  Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle

isInsideBar() Detects inside bars
  Returns: Returns true if the current bar is an inside bar

isOutsideBar() Detects outside bars
  Returns: Returns true if the current bar is an outside bar

barInSession(string, bool) Determines if the current price bar falls inside the specified session
  Parameters:
    string: sess The session to check
    bool: useFilter (default=true) Whether or not to actually use this filter
  Returns: A boolean - true if the current bar falls within the given time session

barOutSession(string, bool) Determines if the current price bar falls outside the specified session
  Parameters:
    string: sess The session to check
    bool: useFilter (default=true) Whether or not to actually use this filter
  Returns: A boolean - true if the current bar falls outside the given time session

dateFilter(int, int) Determines if this bar's time falls within date filter range
  Parameters:
    int: startTime The UNIX date timestamp to begin searching from
    int: endTime the UNIX date timestamp to stop searching from
  Returns: A boolean - true if the current bar falls within the given dates

dayFilter(bool, bool, bool, bool, bool, bool, bool) Checks if the current bar's day is in the list of given days to analyze
  Parameters:
    bool: monday Should the script analyze this day? (true/false)
    bool: tuesday Should the script analyze this day? (true/false)
    bool: wednesday Should the script analyze this day? (true/false)
    bool: thursday Should the script analyze this day? (true/false)
    bool: friday Should the script analyze this day? (true/false)
    bool: saturday Should the script analyze this day? (true/false)
    bool: sunday Should the script analyze this day? (true/false)
  Returns: A boolean - true if the current bar's day is one of the given days

atrFilter()

fillCell()

Pinebibliotek

I sann TradingView-anda har författaren publicerat denna Pine-kod som ett bibliotek med öppen källkod så att andra Pine-programmerare från vår community kan återanvända den. Hatten av för författaren! Du kan använda det här biblioteket privat eller i andra publikationer med öppen källkod, men återanvändning av den här koden i en publikation regleras av våra ordningsregler.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här biblioteket?

Kopiera följande rad och klistra in det i ditt skript.