real_time_candlesIntroduction
The Real-Time Candles Library provides comprehensive tools for creating, manipulating, and visualizing custom timeframe candles in Pine Script. Unlike standard indicators that only update at bar close, this library enables real-time visualization of price action and indicators within the current bar, offering traders unprecedented insight into market dynamics as they unfold.
This library addresses a fundamental limitation in traditional technical analysis: the inability to see how indicators evolve between bar closes. By implementing sophisticated real-time data processing techniques, traders can now observe indicator movements, divergences, and trend changes as they develop, potentially identifying trading opportunities much earlier than with conventional approaches.
Key Features
The library supports two primary candle generation approaches:
Chart-Time Candles: Generate real-time OHLC data for any variable (like RSI, MACD, etc.) while maintaining synchronization with chart bars.
Custom Timeframe (CTF) Candles: Create candles with custom time intervals or tick counts completely independent of the chart's native timeframe.
Both approaches support traditional candlestick and Heikin-Ashi visualization styles, with options for moving average overlays to smooth the data.
Configuration Requirements
For optimal performance with this library:
Set max_bars_back = 5000 in your script settings
When using CTF drawing functions, set max_lines_count = 500, max_boxes_count = 500, and max_labels_count = 500
These settings ensure that you will be able to draw correctly and will avoid any runtime errors.
Usage Examples
Basic Chart-Time Candle Visualization
// Create real-time candles for RSI
float rsi = ta.rsi(close, 14)
Candle rsi_candle = candle_series(rsi, CandleType.candlestick)
// Plot the candles using Pine's built-in function
plotcandle(rsi_candle.Open, rsi_candle.High, rsi_candle.Low, rsi_candle.Close,
"RSI Candles", rsi_candle.candle_color, rsi_candle.candle_color)
Multiple Access Patterns
The library provides three ways to access candle data, accommodating different programming styles:
// 1. Array-based access for collection operations
Candle candles = candle_array(source)
// 2. Object-oriented access for single entity manipulation
Candle candle = candle_series(source)
float value = candle.source(Source.HLC3)
// 3. Tuple-based access for functional programming styles
= candle_tuple(source)
Custom Timeframe Examples
// Create 20-second candles with EMA overlay
plot_ctf_candles(
source = close,
candle_type = CandleType.candlestick,
sample_type = SampleType.Time,
number_of_seconds = 20,
timezone = -5,
tied_open = true,
ema_period = 9,
enable_ema = true
)
// Create tick-based candles (new candle every 15 ticks)
plot_ctf_tick_candles(
source = close,
candle_type = CandleType.heikin_ashi,
number_of_ticks = 15,
timezone = -5,
tied_open = true
)
Advanced Usage with Custom Visualization
// Get custom timeframe candles without automatic plotting
CandleCTF my_candles = ctf_candles_array(
source = close,
candle_type = CandleType.candlestick,
sample_type = SampleType.Time,
number_of_seconds = 30
)
// Apply custom logic to the candles
float ema_values = my_candles.ctf_ema(14)
// Draw candles and EMA using time-based coordinates
my_candles.draw_ctf_candles_time()
ema_values.draw_ctf_line_time(line_color = #FF6D00)
Library Components
Data Types
Candle: Structure representing chart-time candles with OHLC, polarity, and visualization properties
CandleCTF: Extended candle structure with additional time metadata for custom timeframes
TickData: Structure for individual price updates with time deltas
Enumerations
CandleType: Specifies visualization style (candlestick or Heikin-Ashi)
Source: Defines price components for calculations (Open, High, Low, Close, HL2, etc.)
SampleType: Sets sampling method (Time-based or Tick-based)
Core Functions
get_tick(): Captures current price as a tick data point
candle_array(): Creates an array of candles from price updates
candle_series(): Provides a single candle based on latest data
candle_tuple(): Returns OHLC values as a tuple
ctf_candles_array(): Creates custom timeframe candles without rendering
Visualization Functions
source(): Extracts specific price components from candles
candle_ctf_to_float(): Converts candle data to float arrays
ctf_ema(): Calculates exponential moving averages for candle arrays
draw_ctf_candles_time(): Renders candles using time coordinates
draw_ctf_candles_index(): Renders candles using bar index coordinates
draw_ctf_line_time(): Renders lines using time coordinates
draw_ctf_line_index(): Renders lines using bar index coordinates
Technical Implementation Notes
This library leverages Pine Script's varip variables for state management, creating a sophisticated real-time data processing system. The implementation includes:
Efficient tick capturing: Samples price at every execution, maintaining temporal tracking with time deltas
Smart state management: Uses a hybrid approach with mutable updates at index 0 and historical preservation at index 1+
Temporal synchronization: Manages two time domains (chart time and custom timeframe)
The tooltip implementation provides crucial temporal context for custom timeframe visualizations, allowing users to understand exactly when each candle formed regardless of chart timeframe.
Limitations
Custom timeframe candles cannot be backtested due to Pine Script's limitations with historical tick data
Real-time visualization is only available during live chart updates
Maximum history is constrained by Pine Script's array size limits
Applications
Indicator visualization: See how RSI, MACD, or other indicators evolve in real-time
Volume analysis: Create custom volume profiles independent of chart timeframe
Scalping strategies: Identify short-term patterns with precisely defined time windows
Volatility measurement: Track price movement characteristics within bars
Custom signal generation: Create entry/exit signals based on custom timeframe patterns
Conclusion
The Real-Time Candles Library bridges the gap between traditional technical analysis (based on discrete OHLC bars) and the continuous nature of market movement. By making indicators more responsive to real-time price action, it gives traders a significant edge in timing and decision-making, particularly in fast-moving markets where waiting for bar close could mean missing important opportunities.
Whether you're building custom indicators, researching price patterns, or developing trading strategies, this library provides the foundation for sophisticated real-time analysis in Pine Script.
Implementation Details & Advanced Guide
Core Implementation Concepts
The Real-Time Candles Library implements a sophisticated event-driven architecture within Pine Script's constraints. At its heart, the library creates what's essentially a reactive programming framework handling continuous data streams.
Tick Processing System
The foundation of the library is the get_tick() function, which captures price updates as they occur:
export get_tick(series float source = close, series float na_replace = na)=>
varip float price = na
varip int series_index = -1
varip int old_time = 0
varip int new_time = na
varip float time_delta = 0
// ...
This function:
Samples the current price
Calculates time elapsed since last update
Maintains a sequential index to track updates
The resulting TickData structure serves as the fundamental building block for all candle generation.
State Management Architecture
The library employs a sophisticated state management system using varip variables, which persist across executions within the same bar. This creates a hybrid programming paradigm that's different from standard Pine Script's bar-by-bar model.
For chart-time candles, the core state transition logic is:
// Real-time update of current candle
candle_data := Candle.new(Open, High, Low, Close, polarity, series_index, candle_color)
candles.set(0, candle_data)
// When a new bar starts, preserve the previous candle
if clear_state
candles.insert(1, candle_data)
price.clear()
// Reset state for new candle
Open := Close
price.push(Open)
series_index += 1
This pattern of updating index 0 in real-time while inserting completed candles at index 1 creates an elegant solution for maintaining both current state and historical data.
Custom Timeframe Implementation
The custom timeframe system manages its own time boundaries independent of chart bars:
bool clear_state = switch settings.sample_type
SampleType.Ticks => cumulative_series_idx >= settings.number_of_ticks
SampleType.Time => cumulative_time_delta >= settings.number_of_seconds
This dual-clock system synchronizes two time domains:
Pine's execution clock (bar-by-bar processing)
The custom timeframe clock (tick or time-based)
The library carefully handles temporal discontinuities, ensuring candle formation remains accurate despite irregular tick arrival or market gaps.
Advanced Usage Techniques
1. Creating Custom Indicators with Real-Time Candles
To develop indicators that process real-time data within the current bar:
// Get real-time candles for your data
Candle rsi_candles = candle_array(ta.rsi(close, 14))
// Calculate indicator values based on candle properties
float signal = ta.ema(rsi_candles.first().source(Source.Close), 9)
// Detect patterns that occur within the bar
bool divergence = close > close and rsi_candles.first().Close < rsi_candles.get(1).Close
2. Working with Custom Timeframes and Plotting
For maximum flexibility when visualizing custom timeframe data:
// Create custom timeframe candles
CandleCTF volume_candles = ctf_candles_array(
source = volume,
candle_type = CandleType.candlestick,
sample_type = SampleType.Time,
number_of_seconds = 60
)
// Convert specific candle properties to float arrays
float volume_closes = volume_candles.candle_ctf_to_float(Source.Close)
// Calculate derived values
float volume_ema = volume_candles.ctf_ema(14)
// Create custom visualization
volume_candles.draw_ctf_candles_time()
volume_ema.draw_ctf_line_time(line_color = color.orange)
3. Creating Hybrid Timeframe Analysis
One powerful application is comparing indicators across multiple timeframes:
// Standard chart timeframe RSI
float chart_rsi = ta.rsi(close, 14)
// Custom 5-second timeframe RSI
CandleCTF ctf_candles = ctf_candles_array(
source = close,
candle_type = CandleType.candlestick,
sample_type = SampleType.Time,
number_of_seconds = 5
)
float fast_rsi_array = ctf_candles.candle_ctf_to_float(Source.Close)
float fast_rsi = fast_rsi_array.first()
// Generate signals based on divergence between timeframes
bool entry_signal = chart_rsi < 30 and fast_rsi > fast_rsi_array.get(1)
Final Notes
This library represents an advanced implementation of real-time data processing within Pine Script's constraints. By creating a reactive programming framework for handling continuous data streams, it enables sophisticated analysis typically only available in dedicated trading platforms.
The design principles employed—including state management, temporal processing, and object-oriented architecture—can serve as patterns for other advanced Pine Script development beyond this specific application.
------------------------
Library "real_time_candles"
A comprehensive library for creating real-time candles with customizable timeframes and sampling methods.
Supports both chart-time and custom-time candles with options for candlestick and Heikin-Ashi visualization.
Allows for tick-based or time-based sampling with moving average overlay capabilities.
get_tick(source, na_replace)
Captures the current price as a tick data point
Parameters:
source (float) : Optional - Price source to sample (defaults to close)
na_replace (float) : Optional - Value to use when source is na
Returns: TickData structure containing price, time since last update, and sequential index
candle_array(source, candle_type, sync_start, bullish_color, bearish_color)
Creates an array of candles based on price updates
Parameters:
source (float) : Optional - Price source to sample (defaults to close)
candle_type (simple CandleType) : Optional - Type of candle chart to create (candlestick or Heikin-Ashi)
sync_start (simple bool) : Optional - Whether to synchronize with the start of a new bar
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
Returns: Array of Candle objects ordered with most recent at index 0
candle_series(source, candle_type, wait_for_sync, bullish_color, bearish_color)
Provides a single candle based on the latest price data
Parameters:
source (float) : Optional - Price source to sample (defaults to close)
candle_type (simple CandleType) : Optional - Type of candle chart to create (candlestick or Heikin-Ashi)
wait_for_sync (simple bool) : Optional - Whether to wait for a new bar before starting
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
Returns: A single Candle object representing the current state
candle_tuple(source, candle_type, wait_for_sync, bullish_color, bearish_color)
Provides candle data as a tuple of OHLC values
Parameters:
source (float) : Optional - Price source to sample (defaults to close)
candle_type (simple CandleType) : Optional - Type of candle chart to create (candlestick or Heikin-Ashi)
wait_for_sync (simple bool) : Optional - Whether to wait for a new bar before starting
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
Returns: Tuple representing current candle values
method source(self, source, na_replace)
Extracts a specific price component from a Candle
Namespace types: Candle
Parameters:
self (Candle)
source (series Source) : Type of price data to extract (Open, High, Low, Close, or composite values)
na_replace (float) : Optional - Value to use when source value is na
Returns: The requested price value from the candle
method source(self, source)
Extracts a specific price component from a CandleCTF
Namespace types: CandleCTF
Parameters:
self (CandleCTF)
source (simple Source) : Type of price data to extract (Open, High, Low, Close, or composite values)
Returns: The requested price value from the candle as a varip
method candle_ctf_to_float(self, source)
Converts a specific price component from each CandleCTF to a float array
Namespace types: array
Parameters:
self (array)
source (simple Source) : Optional - Type of price data to extract (defaults to Close)
Returns: Array of float values extracted from the candles, ordered with most recent at index 0
method ctf_ema(self, ema_period)
Calculates an Exponential Moving Average for a CandleCTF array
Namespace types: array
Parameters:
self (array)
ema_period (simple float) : Period for the EMA calculation
Returns: Array of float values representing the EMA of the candle data, ordered with most recent at index 0
method draw_ctf_candles_time(self, sample_type, number_of_ticks, number_of_seconds, timezone)
Renders custom timeframe candles using bar time coordinates
Namespace types: array
Parameters:
self (array)
sample_type (simple SampleType) : Optional - Method for sampling data (Time or Ticks), used for tooltips
number_of_ticks (simple int) : Optional - Number of ticks per candle (used when sample_type is Ticks), used for tooltips
number_of_seconds (simple float) : Optional - Time duration per candle in seconds (used when sample_type is Time), used for tooltips
timezone (simple int) : Optional - Timezone offset from UTC (-12 to +12), used for tooltips
Returns: void - Renders candles on the chart using time-based x-coordinates
method draw_ctf_candles_index(self, sample_type, number_of_ticks, number_of_seconds, timezone)
Renders custom timeframe candles using bar index coordinates
Namespace types: array
Parameters:
self (array)
sample_type (simple SampleType) : Optional - Method for sampling data (Time or Ticks), used for tooltips
number_of_ticks (simple int) : Optional - Number of ticks per candle (used when sample_type is Ticks), used for tooltips
number_of_seconds (simple float) : Optional - Time duration per candle in seconds (used when sample_type is Time), used for tooltips
timezone (simple int) : Optional - Timezone offset from UTC (-12 to +12), used for tooltips
Returns: void - Renders candles on the chart using index-based x-coordinates
method draw_ctf_line_time(self, source, line_size, line_color)
Renders a line representing a price component from the candles using time coordinates
Namespace types: array
Parameters:
self (array)
source (simple Source) : Optional - Type of price data to extract (defaults to Close)
line_size (simple int) : Optional - Width of the line
line_color (simple color) : Optional - Color of the line
Returns: void - Renders a connected line on the chart using time-based x-coordinates
method draw_ctf_line_time(self, line_size, line_color)
Renders a line from a varip float array using time coordinates
Namespace types: array
Parameters:
self (array)
line_size (simple int) : Optional - Width of the line, defaults to 2
line_color (simple color) : Optional - Color of the line
Returns: void - Renders a connected line on the chart using time-based x-coordinates
method draw_ctf_line_index(self, source, line_size, line_color)
Renders a line representing a price component from the candles using index coordinates
Namespace types: array
Parameters:
self (array)
source (simple Source) : Optional - Type of price data to extract (defaults to Close)
line_size (simple int) : Optional - Width of the line
line_color (simple color) : Optional - Color of the line
Returns: void - Renders a connected line on the chart using index-based x-coordinates
method draw_ctf_line_index(self, line_size, line_color)
Renders a line from a varip float array using index coordinates
Namespace types: array
Parameters:
self (array)
line_size (simple int) : Optional - Width of the line, defaults to 2
line_color (simple color) : Optional - Color of the line
Returns: void - Renders a connected line on the chart using index-based x-coordinates
plot_ctf_tick_candles(source, candle_type, number_of_ticks, timezone, tied_open, ema_period, bullish_color, bearish_color, line_width, ema_color, use_time_indexing)
Plots tick-based candles with moving average
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Type of candle chart to display
number_of_ticks (simple int) : Number of ticks per candle
timezone (simple int) : Timezone offset from UTC (-12 to +12)
tied_open (simple bool) : Whether to tie open price to close of previous candle
ema_period (simple float) : Period for the exponential moving average
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
line_width (simple int) : Optional - Width of the moving average line, defaults to 2
ema_color (color) : Optional - Color of the moving average line
use_time_indexing (simple bool) : Optional - When true the function will plot with xloc.time, when false it will plot using xloc.bar_index
Returns: void - Creates visual candle chart with EMA overlay
plot_ctf_tick_candles(source, candle_type, number_of_ticks, timezone, tied_open, bullish_color, bearish_color, use_time_indexing)
Plots tick-based candles without moving average
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Type of candle chart to display
number_of_ticks (simple int) : Number of ticks per candle
timezone (simple int) : Timezone offset from UTC (-12 to +12)
tied_open (simple bool) : Whether to tie open price to close of previous candle
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
use_time_indexing (simple bool) : Optional - When true the function will plot with xloc.time, when false it will plot using xloc.bar_index
Returns: void - Creates visual candle chart without moving average
plot_ctf_time_candles(source, candle_type, number_of_seconds, timezone, tied_open, ema_period, bullish_color, bearish_color, line_width, ema_color, use_time_indexing)
Plots time-based candles with moving average
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Type of candle chart to display
number_of_seconds (simple float) : Time duration per candle in seconds
timezone (simple int) : Timezone offset from UTC (-12 to +12)
tied_open (simple bool) : Whether to tie open price to close of previous candle
ema_period (simple float) : Period for the exponential moving average
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
line_width (simple int) : Optional - Width of the moving average line, defaults to 2
ema_color (color) : Optional - Color of the moving average line
use_time_indexing (simple bool) : Optional - When true the function will plot with xloc.time, when false it will plot using xloc.bar_index
Returns: void - Creates visual candle chart with EMA overlay
plot_ctf_time_candles(source, candle_type, number_of_seconds, timezone, tied_open, bullish_color, bearish_color, use_time_indexing)
Plots time-based candles without moving average
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Type of candle chart to display
number_of_seconds (simple float) : Time duration per candle in seconds
timezone (simple int) : Timezone offset from UTC (-12 to +12)
tied_open (simple bool) : Whether to tie open price to close of previous candle
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
use_time_indexing (simple bool) : Optional - When true the function will plot with xloc.time, when false it will plot using xloc.bar_index
Returns: void - Creates visual candle chart without moving average
plot_ctf_candles(source, candle_type, sample_type, number_of_ticks, number_of_seconds, timezone, tied_open, ema_period, bullish_color, bearish_color, enable_ema, line_width, ema_color, use_time_indexing)
Unified function for plotting candles with comprehensive options
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Optional - Type of candle chart to display
sample_type (simple SampleType) : Optional - Method for sampling data (Time or Ticks)
number_of_ticks (simple int) : Optional - Number of ticks per candle (used when sample_type is Ticks)
number_of_seconds (simple float) : Optional - Time duration per candle in seconds (used when sample_type is Time)
timezone (simple int) : Optional - Timezone offset from UTC (-12 to +12)
tied_open (simple bool) : Optional - Whether to tie open price to close of previous candle
ema_period (simple float) : Optional - Period for the exponential moving average
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
enable_ema (bool) : Optional - Whether to display the EMA overlay
line_width (simple int) : Optional - Width of the moving average line, defaults to 2
ema_color (color) : Optional - Color of the moving average line
use_time_indexing (simple bool) : Optional - When true the function will plot with xloc.time, when false it will plot using xloc.bar_index
Returns: void - Creates visual candle chart with optional EMA overlay
ctf_candles_array(source, candle_type, sample_type, number_of_ticks, number_of_seconds, tied_open, bullish_color, bearish_color)
Creates an array of custom timeframe candles without rendering them
Parameters:
source (float) : Input price source to sample
candle_type (simple CandleType) : Type of candle chart to create (candlestick or Heikin-Ashi)
sample_type (simple SampleType) : Method for sampling data (Time or Ticks)
number_of_ticks (simple int) : Optional - Number of ticks per candle (used when sample_type is Ticks)
number_of_seconds (simple float) : Optional - Time duration per candle in seconds (used when sample_type is Time)
tied_open (simple bool) : Optional - Whether to tie open price to close of previous candle
bullish_color (color) : Optional - Color for bullish candles
bearish_color (color) : Optional - Color for bearish candles
Returns: Array of CandleCTF objects ordered with most recent at index 0
Candle
Structure representing a complete candle with price data and display properties
Fields:
Open (series float) : Opening price of the candle
High (series float) : Highest price of the candle
Low (series float) : Lowest price of the candle
Close (series float) : Closing price of the candle
polarity (series bool) : Boolean indicating if candle is bullish (true) or bearish (false)
series_index (series int) : Sequential index identifying the candle in the series
candle_color (series color) : Color to use when rendering the candle
ready (series bool) : Boolean indicating if candle data is valid and ready for use
TickData
Structure for storing individual price updates
Fields:
price (series float) : The price value at this tick
time_delta (series float) : Time elapsed since the previous tick in milliseconds
series_index (series int) : Sequential index identifying this tick
CandleCTF
Structure representing a custom timeframe candle with additional time metadata
Fields:
Open (series float) : Opening price of the candle
High (series float) : Highest price of the candle
Low (series float) : Lowest price of the candle
Close (series float) : Closing price of the candle
polarity (series bool) : Boolean indicating if candle is bullish (true) or bearish (false)
series_index (series int) : Sequential index identifying the candle in the series
open_time (series int) : Timestamp marking when the candle was opened (in Unix time)
time_delta (series float) : Duration of the candle in milliseconds
candle_color (series color) : Color to use when rendering the candle
Pine
iteratorThe "Iterator" library is designed to provide a flexible way to work with sequences of values. This library offers a set of functions to create and manage iterators for various data types, including integers, floats, and more. Whether you need to generate an array of values with specific increments or iterate over elements in reverse order, this library has you covered.
Key Features:
Array Creation: Easily generate arrays of integers or floats with customizable steps, both inclusive and exclusive of the end values.
Flexible Iteration: Includes methods to iterate over arrays of different types, such as booleans, integers, floats, strings, colors, and drawing objects like lines and labels.
Reverse Iteration: Support for reverse iteration, giving you control over the order in which elements are processed.
Automatic Loop Control: One of the key advantages of this library is that when using the .iterate() method, it only loops over the array when there are values present. This means you don’t have to manually check if the array is populated before iterating, simplifying your code and reducing potential errors.
Versatile Use Cases: Ideal for scenarios where you need to loop over an array without worrying about empty arrays or checking conditions manually.
This library is particularly useful in cases where you need to perform operations on each element in an array, ensuring that your loops are efficient and free from unnecessary checks.
Library "iterator"
The "iterator" library provides a versatile and efficient set of functions for creating and managing iterators.
It allows you to generate arrays of integers or floats with customizable steps, both inclusive and exclusive of the end values.
The library also includes methods for iterating over various types, including booleans, integers, floats, strings, colors,
and drawing objects like lines and labels. With support for reverse iteration and flexible customization options.
iterator(stop, start, step)
Creates an array of integers from start to stop with a specified step, excluding the stop value.
Parameters:
stop (int) : The end value of the iterator, exclusive.
start (int) : The starting value of the iterator. Default is 0.
step (int) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of integers incremented by the step value from start to stop. Will return and empty array if start = stop.
iterator(stop, start, step)
Creates an array of floats from start to stop with a specified step, excluding the stop value.
Parameters:
stop (float) : The end value of the iterator, exclusive.
start (float) : The starting value of the iterator. Default is 0.
step (float) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of floats incremented by the step value from start to stop. Will return and empty array if start = stop.
iterator_inclusive(stop, start, step)
Creates an array of integers from start to stop with a specified step, including the stop value.
Parameters:
stop (int) : The end value of the iterator, inclusive.
start (int) : The starting value of the iterator. Default is 0.
step (int) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of integers incremented by the step value from start to stop, including the stop value.
iterator_inclusive(stop, start, step)
Creates an array of floats from start to stop with a specified step, including the stop value.
Parameters:
stop (float) : The end value of the iterator, inclusive.
start (float) : The starting value of the iterator. Default is 0.
step (float) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of floats incremented by the step value from start to stop, including the stop value.
itr(stop, start, step)
Creates an array of integers from start to stop with a specified step, excluding the stop value.
Parameters:
stop (int) : The end value of the iterator, exclusive.
start (int) : The starting value of the iterator. Default is 0.
step (int) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of integers incremented by the step value from start to stop.
itr(stop, start, step)
Creates an array of floats from start to stop with a specified step, excluding the stop value.
Parameters:
stop (float) : The end value of the iterator, exclusive.
start (float) : The starting value of the iterator. Default is 0.
step (float) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of floats incremented by the step value from start to stop.
itr_in(stop, start, step)
Creates an array of integers from start to stop with a specified step, including the stop value.
Parameters:
stop (int) : The end value of the iterator, inclusive.
start (int) : The starting value of the iterator. Default is 0.
step (int) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of integers incremented by the step value from start to stop, including the stop value.
itr_in(stop, start, step)
Creates an array of floats from start to stop with a specified step, including the stop value.
Parameters:
stop (float) : The end value of the iterator, inclusive.
start (float) : The starting value of the iterator. Default is 0.
step (float) : The increment value for each step in the iterator. Default is 1. Must be greater than 0.
Returns: An array of floats incremented by the step value from start to stop, including the stop value.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
method iterate(self, reverse)
Creates an iterator array for the indices of ana array, with an option to reverse the order.
Namespace types: array
Parameters:
self (array) : The array to iterate over.
reverse (bool) : A boolean flag indicating whether to reverse the iterator order. Default is false.
Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
Dark & Light Theme [TradingFinder] Switching Colors Library🔵 Introduction
One of the challenges of script users is matching the colors used in indicators or strategies. By default, colors are chosen to display based on either the dark theme or the light theme.
In scripts with a large number of colors used, changing all colors to better display in dark mode or light mode can be a difficult and tedious process.
This library provides developers with the ability to adjust the colors used in their scripts based on the theme of the display.
🔵 Logic
To categorize the color spectrum, the range from 0 to 255 of all three main colors red, green and blue was divided into smaller ranges.
Blue color, which is more effective in darkening or lightening colors, is divided into 8 categories, red color into 5 categories, and green color into 3 categories, because it has little effect on darkening or brightening colors.
The combination of these categories creates 120 different modes for the color range, which leads to a more accurate identification of the color and its brightness, and helps to decide how to change it.
Except for these 120 modes, there are 2 other modes that are related to colors almost white or black, which makes a total of 122 modes.
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/Dark_Light_Theme_TradingFinder_Switching_Colors_Library/1 as SC
🟣 Parameters
SwitchingColorMode(Color, Mode) =>
Parameters:
Color (color)
Mode (string)
Color : In this parameter, enter the color you want to adjust based on light mode and dark mode.
Mode : Three modes "Off", "Light" and "Dark" are included in this parameter. "Light" mode is for color adjustment for use in "Light Mode".
"Dark" mode is for color adjustment for use in "Dark Mode" and "Off" mode turns off the color adjustment function and the input color to the function is the same as the output color.
🔵 Function Outputs
OriginalColor = input.color(color.red)
= SC.SwitchingColorMode(OriginalColor, Mode)
LogLibrary "Log"
- Log methods that return input value for code readbility and cleaness.
method str(input)
str
Namespace types: series float, simple float, input float, const float
Parameters:
input (float)
method str(input)
str
Namespace types: series int, simple int, input int, const int
Parameters:
input (int)
method str(input)
str
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
input (bool)
method str(input)
str
Namespace types: series string, simple string, input string, const string
Parameters:
input (string)
method str(input)
str
Namespace types: series linefill
Parameters:
input (linefill)
method str(input)
str
Namespace types: series line
Parameters:
input (line)
method str(input)
str
Namespace types: series box
Parameters:
input (box)
method str(input)
str
Namespace types: series label
Parameters:
input (label)
method str(input)
str
Namespace types: chart.point
Parameters:
input (chart.point)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: array
Parameters:
input (array)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
str
Namespace types: matrix
Parameters:
input (matrix)
method str(input)
Namespace types: matrix
Parameters:
input (matrix)
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: chart.point
Parameters:
input (chart.point) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series float, simple float, input float, const float
Parameters:
input (float) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series int, simple int, input int, const int
Parameters:
input (int) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
input (bool) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series string, simple string, input string, const string
Parameters:
input (string) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series linefill
Parameters:
input (linefill) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series line
Parameters:
input (line) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input value with the 'info' log level.
Namespace types: series box
Parameters:
input (box) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: series label
Parameters:
input (label) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input array with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: array
Parameters:
input (array) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Logs the input matrix with the 'info' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method info(input, msg)
Namespace types: matrix
Parameters:
input (matrix)
msg (string)
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: chart.point
Parameters:
input (chart.point) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series float, simple float, input float, const float
Parameters:
input (float) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series int, simple int, input int, const int
Parameters:
input (int) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
input (bool) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series string, simple string, input string, const string
Parameters:
input (string) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series linefill
Parameters:
input (linefill) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series line
Parameters:
input (line) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input value with the 'warning' log level.
Namespace types: series box
Parameters:
input (box) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: series label
Parameters:
input (label) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input array with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: array
Parameters:
input (array) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Logs the input matrix with the 'warning' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method warn(input, msg)
Namespace types: matrix
Parameters:
input (matrix)
msg (string)
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: chart.point
Parameters:
input (chart.point) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series float, simple float, input float, const float
Parameters:
input (float) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series int, simple int, input int, const int
Parameters:
input (int) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
input (bool) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series string, simple string, input string, const string
Parameters:
input (string) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series linefill
Parameters:
input (linefill) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series line
Parameters:
input (line) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input value with the 'error' log level.
Namespace types: series box
Parameters:
input (box) : The input value to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input value.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: series label
Parameters:
input (label) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input array with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input array.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: array
Parameters:
input (array) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Logs the input matrix with the 'error' log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
Returns: The input matrix.
method error(input, msg)
Namespace types: matrix
Parameters:
input (matrix)
msg (string)
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: chart.point
Parameters:
input (chart.point) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series float, simple float, input float, const float
Parameters:
input (float) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series int, simple int, input int, const int
Parameters:
input (int) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
input (bool) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series string, simple string, input string, const string
Parameters:
input (string) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series linefill
Parameters:
input (linefill) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series line
Parameters:
input (line) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input value with the specified log level.
Namespace types: series box
Parameters:
input (box) : The input value to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input value.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: series label
Parameters:
input (label) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input array with the specified log level.
Namespace types: array
Parameters:
input (array) : The input array to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input array.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: array
Parameters:
input (array) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Logs the input matrix with the specified log level.
Namespace types: matrix
Parameters:
input (matrix) : The input matrix to log.
msg (string) : The message to log. Default is an empty string.
level (int) : The log level (1 - info, 2 - warning, 3 - error). Default is 1.
Returns: The input matrix.
method log(input, msg, level)
Namespace types: matrix
Parameters:
input (matrix)
msg (string)
level (int)
FrizBugLibrary "FrizBug"
Debug Tools | Pinescript Debugging Tool Kit
All in one Debugger - the benefit of wrapper functions to simply wrap variables or outputs and have the code still execute the same. Perfect for Debugging on Pine
str(inp)
Overloaded tostring like Function for all type+including Object Variables will also do arrays and matricies of all Types
Parameters:
inp : All types
Returns: string
print_label(str, x_offset, y, barstate, style, color, textcolor, text_align, size)
Label Helper Function - only needs the Str input to work
Parameters:
str :
x_offset : offset from last bar + or -
y : price of label
barstate : barstate built in variable
style : label style settin7
color : color setting
textcolor : textcolor
text_align : text align setting
size : text_sise
Returns: label
init()
initializes the database arrays
Returns: tuple | 2 matrix (1 matrix is varip(live) the other is reagular var (Bar))
update(log, live, live_console, log_console, live_lbl, log_lbl)
Put at the very end of your code / This updates all of the consoles
Parameters:
log : This matrix is the one used for Bar updates
live : This matrix is the one used for Real Time updates
live_console : on_offs for the consoles and lbls - call in the update function
log_console : on_offs for the consoles and lbls - call in the update function
live_lbl : on_offs for the consoles and lbls - call in the update function
log_lbl : on_offs for the consoles and lbls - call in the update function
Returns: void
log(log, inp, str_label, off, rows, index_cols, bars_back)
Function Will push to the Console offset to the right of Current bar, This is the main Console - it has 2 Feeds left and right (changeable)"
Parameters:
log : Matrix - Log or Live
inp : All types
str_label : (optional) This input will label it on the feed
off : Useful for when you don't want to remove the function"
rows : when printing or logging a matrix this will shorten the output will show last # of rows"
index_cols : When printing or logging a array or matrix this will shorten the array or the columns of a matrix by the #"
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)"
Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)
Print(log, str_label, off, bars_back)
Function can be used to send information to a label style Console, Can be used as a wrapper function, Similar to str.format use with str()
Parameters:
log :
str_label : (optional) Can be used to label Data sent to the Console
off : Useful for when you don't want to remove the function
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
Returns: string
print(inp, str_label, off, bars_back)
This Function can be used to send information to a label style Console, Can be used as a wrapper function, Overload print function
Parameters:
inp : All types
str_label : string (optional) Can be used to label Data sent to the Console
off : Useful for when you don't want to remove the function
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)
Credits:
@kaigouthro - for the font library
@RicardoSantos - for the concept I used to make this
Thanks!
Use cases at the bottom
The Divergent LibraryLibrary "TheDivergentLibrary"
The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator . This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.
Usage instructions:
1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent
---
isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Oscillator" or "Price".
getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Bodies" or "Wicks".
isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating the link status to The Divergent indicator.
init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
Parameters:
firstBarSignal : The signal from The Divergent indicator on the first bar.
displayLinkStatus : A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
debug : A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
Returns: A bool array containing the context of The Divergent Library.
processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
Parameters:
signal : The signal from The Divergent indicator.
Returns: A 5-tuple with the following values: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].