liyugen

LYGLibrary

liyugen Aggiornato   
Library "LYGLibrary"
A collection of custom tools & utility functions commonly used with my scripts

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(number, decimalPlaces)
  Truncates (cuts) excess decimal places
  Parameters:
    number (float)
    decimalPlaces (simple float)
  Returns: The given number truncated to the given decimalPlaces

toWhole(number)
  Converts pips into whole numbers
  Parameters:
    number (float)
  Returns: The converted number

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

getPctChange(value1, value2, lookback)
  Gets the percentage change between 2 float values over a given lookback period
  Parameters:
    value1 (float)
    value2 (float)
    lookback (int)

av_getPositionSize(balance, risk, stopPoints, conversionRate)
  Calculates OANDA forex position size for AutoView based on the given parameters
  Parameters:
    balance (float)
    risk (float)
    stopPoints (float)
    conversionRate (float)
  Returns: The calculated position size (in units - only compatible with OANDA)

bullFib(priceLow, priceHigh, fibRatio)
  Calculates a bullish fibonacci value
  Parameters:
    priceLow (float): The lowest price point
    priceHigh (float): The highest price point
    fibRatio (float): 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 (float): The lowest price point
    priceHigh (float): The highest price point
    fibRatio (float): The fibonacci % ratio to calculate
  Returns: The fibonacci value of the given ratio between the two price points

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

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

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

barsAboveMA(lookback, ma)
  Counts how many candles are above the MA
  Parameters:
    lookback (int)
    ma (float)
  Returns: The bar count of how many recent bars are above the MA

barsBelowMA(lookback, ma)
  Counts how many candles are below the MA
  Parameters:
    lookback (int)
    ma (float)
  Returns: The bar count of how many recent bars are below the EMA

barsCrossedMA(lookback, ma)
  Counts how many times the EMA was crossed recently
  Parameters:
    lookback (int)
    ma (float)
  Returns: The bar count of how many times price recently crossed the EMA

getPullbackBarCount(lookback, direction)
  Counts how many green & red bars have printed recently (ie. pullback count)
  Parameters:
    lookback (int)
    direction (int)
  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(fib, colorMatch)
  Checks if the current bar is a hammer candle based on the given parameters
  Parameters:
    fib (float)
    colorMatch (bool)
  Returns: A boolean - true if the current bar matches the requirements of a hammer candle

isStar(fib, colorMatch)
  Checks if the current bar is a shooting star candle based on the given parameters
  Parameters:
    fib (float)
    colorMatch (bool)
  Returns: A boolean - true if the current bar matches the requirements of a shooting star candle

isDoji(wickSize, bodySize)
  Checks if the current bar is a doji candle based on the given parameters
  Parameters:
    wickSize (float)
    bodySize (float)
  Returns: A boolean - true if the current bar matches the requirements of a doji candle

isBullishEC(allowance, rejectionWickSize, engulfWick)
  Checks if the current bar is a bullish engulfing candle
  Parameters:
    allowance (float)
    rejectionWickSize (float)
    engulfWick (bool)
  Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle

isBearishEC(allowance, rejectionWickSize, engulfWick)
  Checks if the current bar is a bearish engulfing candle
  Parameters:
    allowance (float)
    rejectionWickSize (float)
    engulfWick (bool)
  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(sess, useFilter)
  Determines if the current price bar falls inside the specified session
  Parameters:
    sess (simple string)
    useFilter (bool)
  Returns: A boolean - true if the current bar falls within the given time session

barOutSession(sess, useFilter)
  Determines if the current price bar falls outside the specified session
  Parameters:
    sess (simple string)
    useFilter (bool)
  Returns: A boolean - true if the current bar falls outside the given time session

dateFilter(startTime, endTime)
  Determines if this bar's time falls within date filter range
  Parameters:
    startTime (int)
    endTime (int)
  Returns: A boolean - true if the current bar falls within the given dates

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

atrFilter(atrValue, maxSize)
  Parameters:
    atrValue (float)
    maxSize (float)

fillCell(tableID, column, row, title, value, bgcolor, txtcolor)
  This updates the given table's cell with the given values
  Parameters:
    tableID (table)
    column (int)
    row (int)
    title (string)
    value (string)
    bgcolor (color)
    txtcolor (color)
  Returns: A boolean - true if the current bar falls within the given dates
Note di rilascio:
v2

Added:
barInSession2(sess, useFilter)
  Determines if the current price bar falls inside the specified session
  Parameters:
    sess (simple string)
    useFilter (bool)
  Returns: A boolean - true if the current bar falls within the given time session

Libreria Pine

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzare questa libreria in privato o all'interno di altre pubblicazioni open-source, ma il riutilizzo del codice è subordinato al rispetto del Regolamento.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questa libreria?

Copia il testo ed incollalo nel tuo script.