PINE LIBRARY
Atualizado MTFToolkit-Library

Library "MTFToolkit"
Multi-Timeframe Utilities Library: conversions, Fibonacci, TF sorting, MTF helpers, color gradients, demo table
timeframeToMinutes(tf)
Converts a timeframe string to minutes
Parameters:
tf (string): Timeframe string (e.g., "1", "15", "1D", "1W", "1M")
Returns: Number of minutes as float
minutesToTimeframe(minutes)
Converts minutes to a timeframe string
Parameters:
minutes (float): Number of minutes
Returns: Timeframe string
timeframeToSeconds(tf)
Converts a timeframe string to seconds
Parameters:
tf (string): Timeframe string
Returns: Number of seconds
secondsToTimeframe(seconds)
Converts seconds to a timeframe string
Parameters:
seconds (float): Number of seconds
Returns: Timeframe string
fiboGenerate(n)
Generates Fibonacci sequence up to n elements
Parameters:
n (int): Number of elements
Returns: Array of Fibonacci numbers
fiboMapToTV(arrFibo)
Maps Fibonacci values to TradingView timeframe strings
Parameters:
arrFibo (array<float>): Array of Fibonacci numbers
Returns: Array of timeframe strings
arrayMergeUnique(arr1, arr2)
Merges two string arrays and keeps unique values
Parameters:
arr1 (array<string>): First array
arr2 (array<string>): Second array
Returns: Merged array with unique strings
arrayFilterMax(arr, maxMinutes)
Filters TF array by max minutes
Parameters:
arr (array<string>): Array of timeframe strings
maxMinutes (float): Maximum allowed minutes
Returns: Filtered array
arraySortTF(tf_array, show_array, ascending)
Sorts TF array by minutes, optionally ascending
Parameters:
tf_array (array<string>): Array of timeframes
show_array (array<string>): Array of bool flags (for visibility)
ascending (bool)
masterTF(arr)
Returns the largest TF from array (master)
Parameters:
arr (array<string>): Array of TF strings
Returns: Master TF
slaveTF(arr)
Returns all TFs except master (slaves)
Parameters:
arr (array<string>): Array of TF strings
Returns: Array of slave TFs
isTFIncreasing(prevTF, nextTF)
Checks if next TF is larger than previous
Parameters:
prevTF (string): Previous timeframe
nextTF (string): Next timeframe
Returns: true if nextTF > prevTF
TFScore(values)
Computes simple average as score
Parameters:
values (array<float>): Array of float
Returns: Simple average (na if empty)
gradient_triangular(value, mid_point, min_color, mid_color, max_color)
Produces a triangular gradient between 3 colors
Parameters:
value (float): Current value (0–100 or any scale)
mid_point (float): Center point of gradient
min_color (color): Color at low end
mid_color (color): Color at midpoint
max_color (color): Color at high end
Returns: A color value
TFColorGradient(tf_val, min_val, max_val)
Timeframe color gradient helper
Converts a timeframe (in minutes) into a color using a
red → yellow → green gradient.
Parameters:
tf_val (float): Timeframe value in minutes
min_val (float): Minimum expected minutes
max_val (float): Maximum expected minutes
Returns: Color based on position between min_val and max_val
------------------------------------------------------------
TFColorGradientEx(tf_val, min_val, mid_val, max_val, low_color, mid_color, high_color)
Extended customizable timeframe gradient
Parameters:
tf_val (float): Timeframe value in minutes
min_val (float): Minimum minutes
mid_val (float): Middle minutes
max_val (float): Maximum minutes
low_color (color): Color at min_val
mid_color (color): Color at mid_val
high_color (color): Color at max_val
Returns: Color determined by TF position
------------------------------------------------------------
demoTable(tf_arr, show_arr, dashboard_position, horizontal_table, show_header)
Creates a demo table for testing TF arrays
Parameters:
tf_arr (array<string>): Array of TF strings
show_arr (array<bool>): Array of bools to show TFs
dashboard_position (string): Position string
horizontal_table (bool): true=horizontal, false=vertical
show_header (bool): Show header row
Multi-Timeframe Utilities Library: conversions, Fibonacci, TF sorting, MTF helpers, color gradients, demo table
timeframeToMinutes(tf)
Converts a timeframe string to minutes
Parameters:
tf (string): Timeframe string (e.g., "1", "15", "1D", "1W", "1M")
Returns: Number of minutes as float
minutesToTimeframe(minutes)
Converts minutes to a timeframe string
Parameters:
minutes (float): Number of minutes
Returns: Timeframe string
timeframeToSeconds(tf)
Converts a timeframe string to seconds
Parameters:
tf (string): Timeframe string
Returns: Number of seconds
secondsToTimeframe(seconds)
Converts seconds to a timeframe string
Parameters:
seconds (float): Number of seconds
Returns: Timeframe string
fiboGenerate(n)
Generates Fibonacci sequence up to n elements
Parameters:
n (int): Number of elements
Returns: Array of Fibonacci numbers
fiboMapToTV(arrFibo)
Maps Fibonacci values to TradingView timeframe strings
Parameters:
arrFibo (array<float>): Array of Fibonacci numbers
Returns: Array of timeframe strings
arrayMergeUnique(arr1, arr2)
Merges two string arrays and keeps unique values
Parameters:
arr1 (array<string>): First array
arr2 (array<string>): Second array
Returns: Merged array with unique strings
arrayFilterMax(arr, maxMinutes)
Filters TF array by max minutes
Parameters:
arr (array<string>): Array of timeframe strings
maxMinutes (float): Maximum allowed minutes
Returns: Filtered array
arraySortTF(tf_array, show_array, ascending)
Sorts TF array by minutes, optionally ascending
Parameters:
tf_array (array<string>): Array of timeframes
show_array (array<string>): Array of bool flags (for visibility)
ascending (bool)
masterTF(arr)
Returns the largest TF from array (master)
Parameters:
arr (array<string>): Array of TF strings
Returns: Master TF
slaveTF(arr)
Returns all TFs except master (slaves)
Parameters:
arr (array<string>): Array of TF strings
Returns: Array of slave TFs
isTFIncreasing(prevTF, nextTF)
Checks if next TF is larger than previous
Parameters:
prevTF (string): Previous timeframe
nextTF (string): Next timeframe
Returns: true if nextTF > prevTF
TFScore(values)
Computes simple average as score
Parameters:
values (array<float>): Array of float
Returns: Simple average (na if empty)
gradient_triangular(value, mid_point, min_color, mid_color, max_color)
Produces a triangular gradient between 3 colors
Parameters:
value (float): Current value (0–100 or any scale)
mid_point (float): Center point of gradient
min_color (color): Color at low end
mid_color (color): Color at midpoint
max_color (color): Color at high end
Returns: A color value
TFColorGradient(tf_val, min_val, max_val)
Timeframe color gradient helper
Converts a timeframe (in minutes) into a color using a
red → yellow → green gradient.
Parameters:
tf_val (float): Timeframe value in minutes
min_val (float): Minimum expected minutes
max_val (float): Maximum expected minutes
Returns: Color based on position between min_val and max_val
------------------------------------------------------------
TFColorGradientEx(tf_val, min_val, mid_val, max_val, low_color, mid_color, high_color)
Extended customizable timeframe gradient
Parameters:
tf_val (float): Timeframe value in minutes
min_val (float): Minimum minutes
mid_val (float): Middle minutes
max_val (float): Maximum minutes
low_color (color): Color at min_val
mid_color (color): Color at mid_val
high_color (color): Color at max_val
Returns: Color determined by TF position
------------------------------------------------------------
demoTable(tf_arr, show_arr, dashboard_position, horizontal_table, show_header)
Creates a demo table for testing TF arrays
Parameters:
tf_arr (array<string>): Array of TF strings
show_arr (array<bool>): Array of bools to show TFs
dashboard_position (string): Position string
horizontal_table (bool): true=horizontal, false=vertical
show_header (bool): Show header row
Notas de Lançamento
v2Mis à jour:
timeframeToMinutes(tf)
Parameters:
tf (string)
minutesToTimeframe(minutes)
Parameters:
minutes (float)
timeframeToSeconds(tf)
Parameters:
tf (string)
secondsToTimeframe(seconds)
Parameters:
seconds (float)
fiboGenerate(n)
Parameters:
n (int)
fiboMapToTV(arrFibo)
Parameters:
arrFibo (array<float>)
arrayMergeUnique(arr1, arr2)
Parameters:
arr1 (array<string>)
arr2 (array<string>)
arrayFilterMax(arr, maxMinutes)
Parameters:
arr (array<string>)
maxMinutes (float)
arraySortTF(tf_array, show_array, ascending)
Parameters:
tf_array (array<string>)
show_array (array<string>)
ascending (bool)
masterTF(arr)
Parameters:
arr (array<string>)
slaveTF(arr)
Parameters:
arr (array<string>)
isTFIncreasing(prevTF, nextTF)
Parameters:
prevTF (string)
nextTF (string)
TFScore(values)
Parameters:
values (array<float>)
gradient_triangular(value, mid_point, min_color, mid_color, max_color)
Parameters:
value (float)
mid_point (float)
min_color (color)
mid_color (color)
max_color (color)
TFColorGradient(tf_val, min_val, max_val)
Parameters:
tf_val (float)
min_val (float)
max_val (float)
TFColorGradientEx(tf_val, min_val, mid_val, max_val, low_color, mid_color, high_color)
Parameters:
tf_val (float)
min_val (float)
mid_val (float)
max_val (float)
low_color (color)
mid_color (color)
high_color (color)
demoTable(tf_arr, show_arr, dashboard_position, horizontal_table, show_header)
Parameters:
tf_arr (array<string>)
show_arr (array<bool>)
dashboard_position (string)
horizontal_table (bool)
show_header (bool)
Biblioteca do Pine
Em verdadeiro espírito TradingView, o autor publicou este código Pine como uma biblioteca de código aberto para que outros programadores Pine da nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar esta biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização deste código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Biblioteca do Pine
Em verdadeiro espírito TradingView, o autor publicou este código Pine como uma biblioteca de código aberto para que outros programadores Pine da nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar esta biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização deste código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.