yptestrsilibLibrary "RSIBackgroundLib"
RSI 배경색 라이브러리
rsi_background(_symbol, _timeframe)
RSI 계산 및 배경색 반환
Parameters:
_symbol (simple string) : string 심볼
_timeframe (simple string) : string 타임프레임
Returns: RSI, RSI MA, RSI MA10, 배경색
Colors
NumberOfVisibleBarsLibrary "NumberOfVisibleBars"
TODO: add library description here
NumberOfVisibleBars()
Calculates the number of visible bars on the user screen
Returns: The numbers of visible bars on the user screen (int)
Color Library // AlgoFyreAlgoFyre's Color Library is a Pine Script v5 library offering fire-themed palettes with light and dark modes. It helps traders easily integrate consistent, visually appealing color schemes into TradingView indicators. Used in AlgoFyre's Scripts and Indicators.
Color Overview
The AlgoFyreColorLibrary includes a comprehensive set of colors inspired by fire, ranging from light reds and oranges to dark browns and deep reds. The library is divided into two main themes:
Light Theme:
Includes lighter shades of red, orange, and brown, suitable for use on light backgrounds.
Dark Theme:
Includes darker shades of red, orange, and brown, suitable for use on dark backgrounds.
How to Use
To use the AlgoFyreColorLibrary in your Pine Script indicators and strategies, follow these steps:
Import the Library:
Import the AlgoFyreColorLibrary at the beginning of your script.
Call the getColor Function:
Use the getColor function to retrieve the desired color with the specified transparency.
Example
//@version=5
import "AF-L-0001" as af
// Example usage of getColor function
color primaryColor = af.getColor("af_primary1", 50)
color signalColor = af.getColor("af_green", 80)
// Plotting example
plot(close, color=primaryColor, linewidth=2, title="Primary Color Line")
plot(close, color=signalColor, linewidth=2, title="Signal Color Line")
The library AF-L-0001 is imported with the alias af.
The getColor function is used to get colors with specified transparency.
The colors are then used to plot lines on the chart.
ToClrToStrContains functions for conversion of color to string and vice versa:
method toClr( string this ) - converts string reperesentation of color (in hex format) to color
method toHex( color this ) - converts color to string (hex form)
method toRgb( color this ) - converts color to string ("rgb(11,11,11,0)" form)
Thanks to @ImmortalFreedom for his `color_tostring()` function from "RGB Color Fiddler"
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)
ChartUtilsLibrary "ChartUtils"
Library for chart utilities, including managing tables
initTable(rows, cols, bgcolor)
Initializes a table with specific dimensions and color
Parameters:
rows (int) : (int) Number of rows in the table
cols (int) : (int) Number of columns in the table
bgcolor (color) : (color) Background color of the table
Returns: (table) The initialized table
updateTable(tbl, is_price_below_avg, current_investment_USD, strategy_position_size, strategy_position_avg_price, strategy_openprofit, strategy_opentrades, isBullishRate, isBearishRate, mlRSIOverSold, mlRSIOverBought)
Updates the trading table
Parameters:
tbl (table) : (table) The table to update
is_price_below_avg (bool) : (bool) If the current price is below the average price
current_investment_USD (float) : (float) The current investment in USD
strategy_position_size (float) : (float) The size of the current position
strategy_position_avg_price (float) : (float) The average price of the current position
strategy_openprofit (float) : (float) The current open profit
strategy_opentrades (int) : (int) The number of open trades
isBullishRate (bool) : (bool) If the current rate is bullish
isBearishRate (bool) : (bool) If the current rate is bearish
mlRSIOverSold (bool) : (bool) If the ML RSI is oversold
mlRSIOverBought (bool) : (bool) If the ML RSI is overbought
updateTableNoPosition(tbl)
Updates the table when there is no position
Parameters:
tbl (table) : (table) The table to update
SessionBoxLibrary "SessionBox"
This library provides functions to manage and visualize session boxes and labels on chart. A session box is a visual representation of a trading session with properties like time, name, color and the ability to track the high and low price within that session.
SessionBox
SessionBox: stores session data and provides methods to manage that data and visualize it on the chart.
Fields:
session_time (series bool)
session_name (series string)
session_color (series color)
signalLib_yashgode9Signal Generation Library = "signalLib_yashgode9"
This library, named "signalLib_yashgode9", is designed to generate buy and sell signals based on the price action of a financial instrument. It utilizes various technical indicators and parameters to determine the market direction and provide actionable signals for traders.
Key Features:-
1.Trend Direction Identification: The library calculates the trend direction by comparing the number of bars since the highest and lowest prices within a specified depth. This allows the library to determine the overall market direction, whether it's bullish or bearish.
2.Dynamic Price Tracking: The library maintains two chart points, zee1 and zee2, which dynamically track the price levels based on the identified market direction. These points serve as reference levels for generating buy and sell signals.
3.Customizable Parameters: The library allows users to adjust several parameters, including the depth of the price analysis, the deviation threshold, and the number of bars to consider for the trend direction. This flexibility enables users to fine-tune the library's behavior to suit their trading strategies.
4.Visual Representation: The library provides a visual representation of the buy and sell signals by drawing a line between the zee1 and zee2 chart points. The line's color changes based on the identified market direction, with red indicating a bearish signal and green indicating a bullish signal.
Usage and Integration:
To use this library, you can call the "signalLib_yashgode9" function and pass in the necessary parameters, such as the lower and higher prices, the depth of the analysis, the deviation threshold, and the number of bars to consider for the trend direction. The function will return the direction of the market (1 for bullish, -1 for bearish), as well as the zee1 and zee2 chart points.You can then use these values to generate buy and sell signals in your trading strategy. For example, you could use the direction value to determine when to enter or exit a trade, and the zee1 and zee2 chart points to set stop-loss or take-profit levels.
Potential Use Cases:
This library can be particularly useful for traders who:
1.Trend-following Strategies: The library's ability to identify the market direction can be beneficial for traders who employ trend-following strategies, as it can help them identify the dominant trend and time their entries and exits accordingly.
2.Swing Trading: The dynamic price tracking provided by the zee1 and zee2 chart points can be useful for swing traders, who aim to capture medium-term price movements.
3.Automated Trading Systems: The library's functionality can be integrated into automated trading systems, allowing for the development of more sophisticated and rule-based trading strategies.
4.Educational Purposes: The library can also be used for educational purposes, as it provides a clear and concise way to demonstrate the application of technical analysis concepts in a trading context.
Important Notice:- This library effectively work on timeframe of 5-minute and 15-minute.
ColourUtilitiesLibrary "ColourUtilities"
Utility functions for colour manipulation
adjust_colour(rgb, desaturation_amount, transparency_amount)
to reduce saturation or increase transparency of an RGB colour
Parameters:
rgb (color)
desaturation_amount (float) : 0 means no desaturation (colours remains as-is), and 1 means full desaturation (colour turns grey). Can also be used inversely with negative numbers
transparency_amount (float) : How much more transparent the default transparency should become. E.g. with a value of 0.5, a transparency of 0 becomes 50 and 40 becomes 70. A value of 1 makes it fully transparent, en -1 fully opaque.
Returns: color with adjusted saturation and transparency
method apply_default_palette(self, palette_name)
Some nice looking colour palettes, consisting of 6 gradient colours, are already defined here and can be quickly applied to the Palette class
Namespace types: Palette
Parameters:
self (Palette)
palette_name (string) : Currently there are 4 6-coloured palettes available: "GYTS flux signal", "GYTS purple", "GYTS flux filter" and "GYTS maroon"
Returns: None, as it populates the Palette class with pre-defined colours
method get_colour(self, colour_no, transparency)
Retrieves colour from the palette and possibly changes transparency if set
Namespace types: Palette
Parameters:
self (Palette)
colour_no (int) : from the palette
transparency (int) : to possibly change the default transparency of the palette
Returns: colour
method get_dynamic_colour(self, x, mid_point, colour_lb, colour_ub, trend_lookback, use_rate)
Retrieves a colour based on strength and direction of the passed series
Namespace types: Palette
Parameters:
self (Palette)
x (float) : the input data series
mid_point (float) : value as a cutoff point where the bullish/bearish colour scenario
colour_lb (float) : value (lower bound) where to apply the bearish colour at full strength
colour_ub (float) : value (upper bound) where to apply the bullish colour at full strength
trend_lookback (int) : how much bars back to check if there was a consistent move into a certain direction, otherwise a the neutral colour from the centre of the palette will be used.
use_rate (bool) : whether to use the rate (proportional difference with previous `x` value) or the input series `x` directly
Returns: colour
Palette
Fields:
transparency (series__integer)
palette (array__color)
colorLabLibrary "colorLab"
The ColorLab library presents an essential solution for color optimization, leveraging color terms and philosophy. Through its capabilities, it furnishes the necessary versatility to attain optimal color representation and coherence by integrating functions.
tint_level(colour, level)
Determines a Tinted color
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is white color.
Returns: (series color) A color Computed from a linear "Tint" gradient.
shade_level(colour, level)
Determines a Shaded color.
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Black color.
Returns: (series color) A color Computed from a linear "Shade" gradient.
tone_level(colour, level)
Determines a Tone color.
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Gray color.
Returns: (series color) A color Computed from a linear "Tone" gradient.
lightness_gradient(colour, value, bottom_value, top_value, bottom_lightness, top_lightness)
Determines a color from a "Lightness" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_lightness (simple float) : (simple float) Optional argument, default = 70. Lightness Percentage. 100% is lightest and 0% is darkest
top_lightness (simple float) : (simple float) Optional argument, default = 30. Lightness Percentage. 100% is lightest and 0% is darkest
Returns: (series color) A color Computed a the linear "Lightness" gradient.
saturation_gradient(colour, value, bottom_value, top_value, bottom_saturated, top_saturated)
Determines a color from a "Saturation" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_saturated (simple float) : (simple float) Optional argument, default = 15. Low Saturated Percentage.
top_saturated (simple float) : (simple float) Optional argument, default = 80. High Saturated Percentage.
Returns: (series color) A color Computed from a linear "Saturation" gradient.
hue_gradient(colour, value, bottom_value, top_value, bottom_hue, top_hue)
Determines a color from a "Hue" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_hue (simple float) : (simple float) Optional argument, Default = 0. Low Hue is a degree where value in range 0 to 360 degrees.
top_hue (simple float) : (simple float) Optional argument, default = 300. High Hue is a degree where value in range 0 to 360 degrees.
Returns: (series color) A color Computed from a linear "Saturation" gradient.
opposColor(colour)
Generates the opposite color of inputted color.
Parameters:
colour (color) : (series color) Pure color.
Returns: (series color) An opposite color.
randColor(seed)
Generates a random color.
Parameters:
seed (simple int) : (simple int) Optional argument. With identifying seed, it will generate similar color sequence.
Returns: (series color) A random color.
bk_or_wh(colour, lightness)
Determines a white or back fits with an inputted color.
Parameters:
colour (color) : (series color) Pure color.
lightness (float) : (series float) Optional argument, default = 50. If the lightness percentage of inputted color is higher, the output is white; otherwise, it's black.
Returns: (series color) white or back color.
monochrome(colour, lightness, saturation)
Generates a monochromatic color scheme.
Parameters:
colour (color) : (series color) Pure color.
lightness (float) : (series float) Optional argument, default = NA. To custom Lightness percentage manually, 100% is lightest and 0% is darkest.
saturation (float) : (series float) Optional argument, default = NA. To custom Saturation percentage manually, 100% is highest and 0% is lowest saturated.
Returns: (tuple of two color series) .
complementary(colour)
Generates a complementary color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of two color series) .
analogous(colour)
Generates an analogous color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of three color series) .
triadic(colour)
Generates an Triadic color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of three color series) .
tetradic(colour)
Generates an Tetradic color scheme.
Parameters:
colour (color) : (series color) Main color.
Returns: (tuple of four color series) .
tst_scheme(colour, size, _type)
Generates an array of requested type (tint, shade, or tone) scheme colors.
Parameters:
colour (simple color) : (simple color) Pure color.
size (simple int) : (simple input) Number of elements in color array.
_type (simple string) : (simple string) Type of color scheme, possible input "tint", "shade", and "tone".
Returns: (simple array) An array contains elements of the requested type scheme colors.
lsh_scheme(colour, size, _type, topLevel, botLevel)
Generates an array of requested type (lightness, saturation or hue) scheme colors.
Parameters:
colour (simple color) : (simple color) Pure color.
size (simple int) : (simple input) Number of elements in color array.
_type (simple string) : (simple string) Type of color scheme, possible input "lightness", "saturation" and "hue".
topLevel (simple float) : (simple float) Optional argument, default = NA.
1. if "lightness", in a percentage where value in range 0 to 100, 100% lightest.
2. if "saturation", in a percentage where value in range 0 to 100, 100% highest saturated.
3. if "hue", in a degree where value in range 0 to 360 degrees.
botLevel (simple float) : (simple float) Optional argument, default = NA.
1. if "lightness", in a percentage where value in range 0 to 100, 0% darkest.
2. if "saturation", in a percentage where value in range 0 to 100, 0% lowest saturated.
3. if "hue", in a degree where value in range 0 to 360 degrees.
Returns: (simple array) An array contains elements of the requested type scheme colors.
display_color(colour, location)
Displays color including RGB and HSL.
Parameters:
colour (simple color) : (simple color) Pure color.
location (simple string) : (simple string) Optional argument, default = "top_right". cell location.
Returns: (simple table) A table cell contains RGB and HSL of entered color.
display_scheme(arrayColour, location)
Displays Scheme colors including RGB and HSL.
Parameters:
arrayColour (array)
location (simple string) : (simple string) Optional argument, default = "top_right". cell location.
Returns: (simple table) A table cells contain RGB and HSL of entered color.
utilsLibrary "utils"
Provides a set of utility functions for use in strategies or indicators.
colorGreen(opacity)
Parameters:
opacity (int)
colorRed(opacity)
Parameters:
opacity (int)
colorTeal(opacity)
Parameters:
opacity (int)
colorBlue(opacity)
Parameters:
opacity (int)
colorOrange(opacity)
Parameters:
opacity (int)
colorPurple(opacity)
Parameters:
opacity (int)
colorPink(opacity)
Parameters:
opacity (int)
colorYellow(opacity)
Parameters:
opacity (int)
colorWhite(opacity)
Parameters:
opacity (int)
colorBlack(opacity)
Parameters:
opacity (int)
trendChangingUp(emaShort, emaLong)
Signals when the trend is starting to change in a positive direction.
Parameters:
emaShort (float)
emaLong (float)
Returns: bool
trendChangingDown(emaShort, emaLong)
Signals when the trend is starting to change in a negative direction.
Parameters:
emaShort (float)
emaLong (float)
Returns: bool
percentChange(start, end)
Returns the percent change between a start number and end number. A positive change returns a positive value and vice versa.
Parameters:
start (float)
end (float)
Returns: float
percentOf(percent, n)
Returns the number that's the percentage of the provided value.
Parameters:
percent (float) : Use 0.2 for 20 percent, 0.35 for 35 percent, etc.
n (float) : The number to calculate the percentage of.
Returns: float
targetPriceByPercent(percent, n)
Parameters:
percent (float)
n (float)
hasNegativeSlope(start, end)
Parameters:
start (float)
end (float)
timeinrange(resolution, session, timezone)
Returns true when the current time is within a given session window. Note, the time is calculated in the "America/New_York" timezone.
Parameters:
resolution (simple string) : The time interval to use to start/end the background color. Use "1" for the coloring the background up to the minute.
session (simple string) : The session string to use to identify the time window. Example: "0930-1600:23456" means normal market hours on weekdays.
timezone (simple string)
Returns: series bool
barsSinceLastEntry()
Returns the number of bars since the last entry order.
Returns: series int
barsSinceLastExit()
Returns the number of bars since the last exit order.
Returns: series int
calcSlope(ln, lookback)
Calculates the slope of the provided line based on its x,y coordinates in the previous bar to the current bar.
Parameters:
ln (float)
lookback (int)
Returns: series float
openPL()
Returns slope of the line given the start and end x,y coordinates.
Returns: series float
hasConsecutiveNegativeCandles(lookbackInput)
Returns true if the number of consecutive red candles matches the provided count.
Parameters:
lookbackInput (int) : The amount of bars to look back to check for consecutive negative bars. Default = 1.
Returns: series bool
stdevPercent(stdev, price)
Returns the standard deviation as a percentage of price.
Parameters:
stdev (float) : The standard deviation value
price (float) : The current price of the target ticker.
Returns: series float
Material Design ColorsThis library provides a standard set of colors defined in Material Design 2.0.
🔵 API
Step 1: Import this library.
import algotraderdev/material/1
// remember to check the latest version of this library and replace the 1 above.
Step 2: Get the color you like. Check the source code or the screenshot above to see all the supported colors.
material.red()
Each color function (except for `black()` and `white()`) accepts an optional `variant` parameter. You can choose any of 50, 100, 200, 300, 400, 500, 600, 700, 800, and 900. By default, 500 is chosen if this parameter is not provided.
ColorPalettesThis is my first public (and I hope not the last) library providing different color palettes used for data visualization. Each palette can contain either 3 to 9 colors or 3 to 11 colors.
So there you go. Happy New Year!
I want your new year to be as colorful, vibrant and rich as these color palettes.
Dedicated to @veryfid . RIP, dude.
---
Library "ColorPalettes"
A library of various color palettes for data visualization
Reds(n)
A function to generate the sequential `Reds` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Reds` palette.
Blues(n)
A function to generate the sequential `Blues` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Blues` palette.
Greens(n)
A function to generate the sequential `Greens` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Greens` palette.
Purples(n)
A function to generate the sequential `Purples` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Purples` palette.
Oranges(n)
A function to generate the sequential `Oranges` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Oranges` palette.
Greys(n)
A function to generate the sequential `Greys` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Greys` palette.
YlGn(n)
A function to generate the sequential `YlGn` (Yellow/Green) palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `YlGn` palette.
YlGnBu(n)
A function to generate the sequential `YlGnBu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `YlGnBu` palette.
GnBu(n)
A function to generate the sequential `GnBu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `GnBu` palette.
BuGn(n)
A function to generate the sequential `BuGn` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `BuGn` palette.
PuBuGn(n)
A function to generate the sequential `PuBuGn` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PuBuGn` palette.
PuBu(n)
A function to generate the sequential `PuBu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PuBu` palette.
BuPu(n)
A function to generate the sequential `BuPu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `BuPu` palette.
RdPu(n)
A function to generate the sequential `RdPu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `RdPu` palette.
PuRd(n)
A function to generate the sequential `PuRd` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PuRd` palette.
OrRd(n)
A function to generate the sequential `OrRd` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `OrRd` palette.
YlOrRd(n)
A function to generate the sequential `YlOrRd` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `YlOrRd` palette.
YlOrBr(n)
A function to generate the sequential `YlOrBr` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `YlOrBr` palette.
Inferno(n)
A function to generate the sequential `Inferno` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Inferno` palette.
Magma(n)
A function to generate the sequential `Magma` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Magma` palette.
Plasma(n)
A function to generate the sequential `Plasma` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Plasma` palette.
Viridis(n)
A function to generate the sequential `Viridis` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Viridis` palette.
Cividis(n)
A function to generate the sequential `Cividis` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Cividis` palette.
Spectral(n)
A function to generate the diverging `Spectral` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Spectral` palette.
Turbo(n)
A function to generate the diverging `Turbo` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `Turbo` palette.
BrBG(n)
A function to generate the diverging `BrBG` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `BrBG` palette.
PiYG(n)
A function to generate the diverging `PiYG` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PiYG` palette.
PRGn(n)
A function to generate the diverging `PRGn` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PRGn` palette.
PuOr(n)
A function to generate the diverging `PuOr` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `PuOr` palette.
RdBu(n)
A function to generate the diverging `RdBu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `RdBu` palette.
RdGy(n)
A function to generate the diverging `RdGy` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `RdGy` palette.
RdYlBu(n)
A function to generate the diverging `RdYlBu` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `RdYlBu` palette.
RdYlGn(n)
A function to generate the diverging `RdYlGn` palette of the specified size.
Parameters:
n (int) The size of the output palette to generate. Default is 9.
Returns: An array of colors from the `RdYlGn` palette.
Contrast Color LibraryThis lightweight library provides a utility method that analyzes any provided background color and automatically chooses the optimal black or white foreground color to ensure maximum visual contrast and readability.
🟠 Algorithm
The library utilizes the HSP Color Model to calculate the brightness of the background color. The formula for this calculation is as follows:
brightness = sqrt(0.299 * R^2 + 0.587 * G^2 + 0.114 * B^2 )
The library chooses black as the foreground color if the brightness exceeds the threshold (default 0.5), and white otherwise.
rezgaaLibrary "rezgaa"
Provides functions calculating the all-time high/low of values.
hi(val)
Calculates the all-time high of a series.
Parameters:
val (float) : Series to use (`high` is used if no argument is supplied).
Returns: The all-time high for the series.
lo(val)
Calculates the all-time low of a series.
Parameters:
val (float) : Series to use (`low` is used if no argument is supplied).
Returns: The all-time low for the series.
PScolorLibrary "PScolor"
TODO: add library description here
////variable/////////////////////////////
//COLOR brightness
Each color has 0–9 / A1–A4
(5th standard: Bright if small, dark if big)
(Fluorescence based on A2)
//Color Name
1 = RED
2 = DEEP_ORANGE
3 = ORANGE
4 = AMBER
5 = YELLOW
6 = LIME
7 = LIGHT_GREEN
8 = GREEN
9 = TEAL
10= CYAN
11= LIGHT_BLUE
12= BLUE
13= INDIGO
14= DEEP_PURPLE
15= PURPLE
16= PINK
0= GRAY
// Transparency
///////////////////////////////////////
lvcol(colormode, Number, trans)
Parameters:
colormode (int)
Number (simple int)
trans (float)
lvcolA(colormode, Number, trans)
Parameters:
colormode (int)
Number (simple int)
trans (float)
lvcol2(colormode, colorName, trans)
Parameters:
colormode (int)
colorName (simple string)
trans (float)
lvcol2A(colormode, colorName, trans)
Parameters:
colormode (int)
colorName (simple string)
trans (float)
imlibLibrary "imlib"
Description
The library allows you to display images in your scripts utilising the objects. You can change the image size and screen aspect ratio (the ratio of width to height which you can change if the image is too wide / tall). The library has "example()" function which you can use to see how it works. It also has a handy "logo()" function which you can use to quickly display an image by passing the "Image data string", table position, image size and aspect ratio. And of course you can use it in your own custom way by taking the "logo()" function as an example and modifying the code to your needs.
Since tables in Pinescript are limited to 100 by 100 cells, the limit for image's size is also 100x100 px. All the necessary data to display an image is passed as a string variable, and since Pinescript has a limit of 4096 characters for variables of type, that string can have a maximum length of 4096 characters, which is enough to display a 64x64px image (but can be enough to display a 100x100 image, depending on the image itself).
Below you can find the definitions of functions for this library.
_decompress(data)
: Decompresses string with data image
Parameters:
data (string)
Returns: : Array of with decompressed data
load(data)
: Splits the string with image data into components and builds an object
Parameters:
data (string)
Returns: : An object
show(imgdata, table_id, image_size, screen_ratio)
: Displays an image in a table
Parameters:
imgdata (ImgData)
table_id (table)
image_size (float)
screen_ratio (string)
Returns: : nothing
example()
: Use it as an example of how this library works and how to use it in your own scripts
Returns: : nothing
logo(imgdata, position, image_size, screen_ratio)
: Displays logo using image data string
Parameters:
imgdata (string)
position (string)
image_size (float)
screen_ratio (string)
Returns: : nothing
ImgData
Fields:
w (series__integer)
h (series__integer)
s (series__string)
pal (series__string)
data (array__string)
lib_colorLibrary "lib_color"
offset_mono(original, offset, transparency)
get offset color
Parameters:
original (simple color) : original color
offset (float) : offset for new color
transparency (float) : transparency for new color
Returns: offset color
DarkWaveColorThemesLibrary "DarkWaveColorThemes"
Description:
A simple, binary color-theming library that provides you with easy-access 'bullish and bearish' colors which you can use to make your indicators more aesthetically pleasing. These color themes were developed to help the community make indicators look excellent with ease.
Functions:
1. getThemeColor(themeName, colorType)
Description:
This function returns a color (either a 'Bullish' or 'Bearish' color, depending on your 'colorType' parameter input) according to the theme you have supplied as the 'themeName' parameter.
Parameters:
themeName (string) : Specify the theme you want to reference. Options include: 'DarkWave', 'Synthwave', 'DarkWave Crypto', 'Crystal Pool', 'Aquafarer', 'Mystic Armor', 'Futurist', 'Electric Zest', 'Stealth Ride', 'Long Trader', 'Short Trader', 'Emerald Glow', 'Gold Heist', 'Floral', 'Cobalt Twilight', and 'Sunrise'.
colorType (string) : Specify which color you want to reference from the theme. Options include: 'Bullish' and 'Bearish'.
Returns:
Your specified color type according to your specified theme.
Boxes_PlotIn the world of data visualization, heatmaps are an invaluable tool for understanding complex datasets. They use color gradients to represent the values of individual data points, allowing users to quickly identify patterns, trends, and outliers in their data. In this post, we will delve into the history of heatmaps, and then discuss how its implemented.
The "Boxes_Plot" library is a powerful and versatile tool for visualizing multiple indicators on a trading chart using colored boxes, commonly known as heatmaps. These heatmaps provide a user-friendly and efficient method for analyzing the performance and trends of various indicators simultaneously. The library can be customized to display multiple charts, adjust the number of rows, and set the appropriate offset for proper spacing. This allows traders to gain insights into the market and make informed decisions.
Heatmaps with cells are interesting and useful for several reasons. Firstly, they allow for the visualization of large datasets in a compact and organized manner. This is especially beneficial when working with multiple indicators, as it enables traders to easily compare and contrast their performance. Secondly, heatmaps provide a clear and intuitive representation of the data, making it easier for traders to identify trends and patterns. Finally, heatmaps offer a visually appealing way to present complex information, which can help to engage and maintain the interest of traders.
History of Heatmaps
The concept of heatmaps can be traced back to the 19th century when French cartographer and sociologist Charles Joseph Minard used color gradients to visualize statistical data. He is well-known for his 1869 map, which depicted Napoleon's disastrous Russian campaign of 1812 using a color gradient to represent the dwindling size of Napoleon's army.
In the 20th century, heatmaps gained popularity in the fields of biology and genetics, where they were used to visualize gene expression data. In the early 2000s, heatmaps found their way into the world of finance, where they are now used to display stock market data, such as price, volume, and performance.
The boxes_plot function in the library expects a normalized value from 0 to 100 as input. Normalizing the data ensures that all values are on a consistent scale, making it easier to compare different indicators. The function also allows for easy customization, enabling users to adjust the number of rows displayed, the size of the boxes, and the offset for proper spacing.
One of the key features of the library is its ability to automatically scale the chart to the screen. This ensures that the heatmap remains clear and visible, regardless of the size or resolution of the user's monitor. This functionality is essential for traders who may be using various devices and screen sizes, as it enables them to easily access and interpret the heatmap without needing to make manual adjustments.
In order to create a heatmap using the boxes_plot function, users need to supply several parameters:
1. Source: An array of floating-point values representing the indicator values to display.
2. Name: An array of strings representing the names of the indicators.
3. Boxes_per_row: The number of boxes to display per row.
4. Offset (optional): An integer to offset the boxes horizontally (default: 0).
5. Scale (optional): A floating-point value to scale the size of the boxes (default: 1).
The library also includes a gradient function (grad) that is used to generate the colors for the heatmap. This function is responsible for determining the appropriate color based on the value of the indicator, with higher values typically represented by warmer colors such as red and lower values by cooler colors such as blue.
Implementing Heatmaps as a Pine Script Library
In this section, we'll explore how to create a Pine Script library that can be used to generate heatmaps for various indicators on the TradingView platform. The library utilizes colored boxes to represent the values of multiple indicators, making it simple to visualize complex data.
We'll now go over the key components of the code:
grad(src) function: This function takes an integer input 'src' and returns a color based on a predefined color gradient. The gradient ranges from dark blue (#1500FF) for low values to dark red (#FF0000) for high values.
boxes_plot() function: This is the main function of the library, and it takes the following parameters:
source: an array of floating-point values representing the indicator values to display
name: an array of strings representing the names of the indicators
boxes_per_row: the number of boxes to display per row
offset (optional): an integer to offset the boxes horizontally (default: 0)
scale (optional): a floating-point value to scale the size of the boxes (default: 1)
The function first calculates the screen size and unit size based on the visible chart area. Then, it creates an array of box objects representing each data point. Each box is assigned a color based on the value of the data point using the grad() function. The boxes are then plotted on the chart using the box.new() function.
Example Usage:
In the example provided in the source code, we use the Relative Strength Index (RSI) and the Stochastic Oscillator as the input data for the heatmap. We create two arrays, 'data_1' containing the RSI and Stochastic Oscillator values, and 'data_names_1' containing the names of the indicators. We then call the 'boxes_plot()' function with these arrays, specifying the desired number of boxes per row, offset, and scale.
Conclusion
Heatmaps are a versatile and powerful data visualization tool with a rich history, spanning multiple fields of study. By implementing a heatmap library in Pine Script, we can enhance the capabilities of the TradingView platform, making it easier for users to visualize and understand complex financial data. The provided library can be easily customized and extended to suit various use cases and can be a valuable addition to any trader's toolbox.
Library "Boxes_Plot"
boxes_plot(source, name, boxes_per_row, offset, scale)
Parameters:
source (float ) : - an array of floating-point values representing the indicator values to display
name (string ) : - an array of strings representing the names of the indicators
boxes_per_row (int) : - the number of boxes to display per row
offset (int) : - an optional integer to offset the boxes horizontally (default: 0)
scale (float) : - an optional floating-point value to scale the size of the boxes (default: 1)
ObjectHelpersLibrary "ObjectHelpers"
Line | Box | Label | Linefill -- Maker, Setter, Getter Library
TODO: add table functionality
set(object)
set all params for `line`, `box`, `label`, `linefill` objects with 1 function
***
## Overloaded
***
```
method set(line Line, int x1=na, float y1=na, int x2=na, float y2=na,string xloc=na,string extend=na,color color=na,string style=na,int width=na,bool update=na) => line
```
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1
- **y1** `float` - value to set y1
- **x2** `int` - value to set x2
- **y2** `float` - value to set y2
- **xloc** `int` - value to set xloc
- **yloc** `int` - value to set yloc
- **extend** `string` - value to set extend
- **color** `color` - value to set color
- **style** `string` - value to set style
- **width** `int` - value to set width
- **update** `bool` - value to set update
***
```
method set(box Box,int left=na,float top=na,int right=na, float bottom=na,color bgcolor=na,color border_color=na,string border_style=na,int border_width=na,string extend=na,string txt=na,color text_color=na,string text_font_family=na,string text_halign=na,string text_valign=na,string text_wrap=na,bool update=false) => box
```
### Params
- **Box** `box` - box object
- **left** `int` - value to set left
- **top** `float` - value to set top
- **right** `int` - value to set right
- **bottom** `float` - value to set bottom
- **bgcolor** `color` - value to set bgcolor
- **border_color** `color` - value to set border_color
- **border_style** `string` - value to set border_style
- **border_width** `int` - value to set border_width
- **extend** `string` - value to set extend
- **txt** `string` - value to set _text
- **text_color** `color` - value to set text_color
- **text_font_family** `string` - value to set text_font_family
- **text_halign** `string` - value to set text_halign
- **text_valign** `string` - value to set text_valign
- **text_wrap** `string` - value to set text_wrap
- **update** `bool` - value to set update
***
```
method set(label Label,int x=na,float y=na, string txt=na,string xloc=na,color color=na,color textcolor=na,string size=na,string style=na,string textalign=na,string tooltip=na,string text_font_family=na,bool update=false) => label
```
### Paramas
- **Label** `label` - label object
- **x** `int` - value to set x
- **y** `float` - value to set y
- **txt** `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
- **textcolor** `color` - value to set textcolor
- **size** `string` - value to set size
- **style** `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
- **text_font_family** `string` - value to set text_font_family
- **textalign** `string` - value to set textalign
- **tooltip** `string` - value to set tooltip
- **update** `bool` - update label to next bar
***
```
method set(linefill Linefill=na,line line1=na,line line2=na,color color=na) => linefill
```
### Params
- **linefill** `linefill` - linefill object
- **line1** `line` - line object
- **line2** `line` - line object
- **color** `color` - color
Parameters:
object (obj)
Returns: `line`, `box`, `label`, `linefill`
method set(Line, x1, y1, x2, y2, xloc, extend, color, style, width, update)
set the location params of a line with 1 function auto detects time or bar_index for xloc param
Namespace types: series line
Parameters:
Line (line) : `line` - line object | `required`
x1 (int) : `int` - value to set x1
y1 (float) : `float` - value to set y1
x2 (int) : `int` - value to set x2
y2 (float) : `float` - value to set y2
xloc (string) : `int` - value to set xloc
extend (string) : `string` - value to set extend
color (color) : `color` - value to set color
style (string) : `string` - value to set style
width (int) : `int` - value to set width
update (bool) : `bool` - value to set update
Returns: `line`
method set(Box, left, top, right, bottom, bgcolor, border_color, border_style, border_width, extend, txt, text_color, text_font_family, text_halign, text_valign, text_wrap, update)
set the location params of a box with 1 function
Namespace types: series box
Parameters:
Box (box) : `box` - box object | `required`
left (int) : `int` - value to set left
top (float) : `float` - value to set top
right (int) : `int` - value to set right
bottom (float) : `float` - value to set bottom
bgcolor (color) : `color` - value to set bgcolor
border_color (color) : `color` - value to set border_color
border_style (string) : `string` - value to set border_style
border_width (int) : `int` - value to set border_width
extend (string) : `string` - value to set extend
txt (string) : `string` - value to set _text
text_color (color) : `color` - value to set text_color
text_font_family (string) : `string` - value to set text_font_family
text_halign (string) : `string` - value to set text_halign
text_valign (string) : `string` - value to set text_valign
text_wrap (string) : `string` - value to set text_wrap
update (bool) : `bool` - value to set update
Returns: `box`
method set(Label, x, y, txt, xloc, color, textcolor, size, style, textalign, tooltip, text_font_family, update)
set the location params of a label with 1 function auto detects time or bar_index for xloc param
Namespace types: series label
Parameters:
Label (label) : `label` | `required`
x (int) : `int` - value to set x
y (float) : `float` - value to set y
txt (string) : `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
xloc (string)
color (color)
textcolor (color) : `color` - value to set textcolor
size (string) : `string` - value to set size
style (string) : `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
textalign (string) : `string` - value to set textalign
tooltip (string) : `string` - value to set tooltip
text_font_family (string) : `string` - value to set text_font_family
update (bool) : `bool` - update label to next bar
Returns: `label`
method set(Linefill, line1, line2, color)
change the 1 or 2 of the lines in a linefill object
Namespace types: series linefill
Parameters:
Linefill (linefill)
line1 (line) : `line` - line object
line2 (line) : `line` - line object
color (color) : `color` - color
Returns: `linefill`
get(object)
get all of the location variables for `line`, `box`, `label` objects or the line objects from a `linefill`
***
## Overloaded
***
```
method get(line Line) =>
```
### Params
- **Line** `line` - line object | `required`
***
```
method get(box Box) =>
```
### Params
- **Box** `box` - box object | `required`
***
```
method get(label Label) =>
```
### Paramas
- **Label** `label` - label object | `required`
***
```
method get(linefill Linefill) =>
```
### Params
- **Linefill** `linefill` - linefill object | `required`
Parameters:
object (obj)
Returns: ` `
method get(Line)
Gets the location paramaters of a Line
Namespace types: series line
Parameters:
Line (line) : `line` - line object
Returns:
method get(Box)
Gets the location paramaters of a Box
Namespace types: series box
Parameters:
Box (box) : `box` - box object
Returns:
method get(Label)
Gets the `x`, `y`, `text` of a Label
Namespace types: series label
Parameters:
Label (label) : `label` - label object
Returns:
method get(Linefill)
Gets `line 1`, `line 2` from a Linefill
Namespace types: series linefill
Parameters:
Linefill (linefill) : `linefill` - linefill object
Returns:
method set_x(Line, x1, x2)
set the `x1`, `x2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1 | `required`
- **x2** `int` - value to set x2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
x1 (int) : `int` - value to set x1
x2 (int) : `int` - value to set x2
Returns: `line`
method set_y(Line, y1, y2)
set `y1`, `y2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **y1** `float` - value to set y1 | `required`
- **y2** `float` - value to set y2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
y1 (float) : `float` - value to set y1
y2 (float) : `float` - value to set y2
Returns: `line`
method Line(x1, y1, x2, y2, extend, color, style, width)
Similar to `line.new()` but can detect time or bar_index for xloc param and has defaults for all params but `x1`, `y1`, `x2`, `y2`
***
### Params
- **x1** `int` - value to set
- **y1** `float` - value to set
- **x2** `int` - value to set
- **y2** `float` - value to set
- **extend** `string` - extend value to set line
- **color** `color` - color to set line
- **style** `string` - style to set line
- **width** `int` - width to set line
Namespace types: series int, simple int, input int, const int
Parameters:
x1 (int) : `int` - value to set
y1 (float) : `float` - value to set
x2 (int) : `int` - value to set
y2 (float) : `float` - value to set
extend (string) : `string` - extend value to set line
color (color) : `color` - color to set line
style (string) : `string` - style to set line
width (int) : `int` - width to set line
Returns: `line`
method Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() with the but can detect xloc param and has defaults for everything but location params
***
### Params
- **left** `int` - value to set
- **top** `float` - value to set
- **right** `int` - value to set
- **bottom** `float` - value to set
- **extend** `string` - extend value to set box
- **border_color** `color` - color to set border
- **bgcolor** `color` - color to set background
- **text_color** `color` - color to set text
- **border_width** `int` - width to set border
- **border_style** `string` - style to set border
- **txt** `string` - text to set
- **text_halign** `string` - horizontal alignment to set text
- **text_valign** `string` - vertical alignment to set text
- **text_size** `string` - size to set text
- **text_wrap** `string` - wrap to set text
Namespace types: series int, simple int, input int, const int
Parameters:
left (int) : `int` - value to set
top (float) : `float` - value to set
right (int) : `int` - value to set
bottom (float) : `float` - value to set
extend (string) : `string` - extend value to set box
border_color (color) : `color` - color to set border
bgcolor (color) : `color` - color to set background
text_color (color) : `color` - color to set text
border_width (int) : `int` - width to set border
border_style (string) : `string` - style to set border
txt (string) : `string` - text to set
text_halign (string) : `string` - horizontal alignment to set text
text_valign (string) : `string` - vertical alignment to set text
text_size (string) : `string` - size to set text
text_wrap (string) : `string` - wrap to set text
Returns: `box`
method Label(txt, x, y, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
Similar to label.new() but can detect time or bar_index for xloc param and has defaults for all params but x, y, txt, tooltip
***
### Params
- **txt** `string` - string to set
- **x** `int` - value to set
- **y** `float` - value to set
- **yloc** `string` - y location to set
- **color** `color` - label color to set
- **textcolor** `color` - text color to set
- **style** `string` - style to set
- **size** `string` - size to set
- **textalign** `string` - text alignment to set
- **text_font_family** `string` - font family to set
- **tooltip** `string` - tooltip to set
Namespace types: series string, simple string, input string, const string
Parameters:
txt (string) : `string` - string to set
x (int) : `int` - value to set
y (float) : `float` - value to set
yloc (string) : `string` - y location to set
color (color) : `color` - label color to set
textcolor (color) : `color` - text color to set
style (string) : `string` - style to set
size (string) : `string` - size to set
textalign (string) : `string` - text alignment to set
text_font_family (string) : `string` - font family to set
tooltip (string) : `string` - tooltip to set
Returns: `label`
obj
Fields:
obj (series__string)
UtilsLibrary "Utils"
Utility functions. Mathematics, colors, and auxiliary algorithms.
setTheme(vc, theme)
Set theme for levels (predefined colors).
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels.
theme : (int) Theme (predefined colors).
0 = 'User defined'
1 = 'Spectrum Blue-Green-Red'
2 = 'Monokai'
3 = 'Green'
4 = 'Purple'
5 = 'Blue'
6 = 'Red'
Returns: (void)
setTheme(vc, colorLevel_Lv1, colorLevel_Lv1_Lv2, colorLevel_Lv2_Lv3, colorLevel_Lv3_Lv4, colorLevel_Lv4_Lv5, colorLevel_Lv5)
Set theme for levels (customized colors).
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
colorLevel_Lv1 : (color) Color associeted with value when below Level 1.
colorLevel_Lv1_Lv2 : (color) Color associeted with value when between Level 1 and 2.
colorLevel_Lv2_Lv3 : (color) Color associeted with value when between Level 2 and 3.
colorLevel_Lv3_Lv4 : (color) Color associeted with value when between Level 3 and 4.
colorLevel_Lv4_Lv5 : (color) Color associeted with value when between Level 4 and 5.
colorLevel_Lv5 : (color) Color associeted with value when above Level 5.
Returns: (void)
setCurrentColorValue(vc)
Set color to a current value, taking into account the previous value and its levels
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
Returns: (void)
setCurrentColorValue(vc, gradient)
Set color to a current value, taking into account the previous value.
Parameters:
vc : (valueColor) Object to associate a color with a value, taking into account the previous value
gradient
Returns: (void)
setCustomLevels(vc, level1, level2, level3, level4, level5)
Set boundaries for custom levels.
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
level1 : (float) Boundary for level 1
level2 : (float) Boundary for level 2
level3 : (float) Boundary for level 3
level4 : (float) Boundary for level 4
level5 : (float) Boundary for level 5
Returns: (void)
getPeriodicColor(originalColor, density)
Returns a periodic color. Useful for creating dotted lines for example.
Parameters:
originalColor : (color) Original color.
density : (float) Density of color. Expression used in modulo to obtain the integer remainder.
If the remainder equals zero, the color appears, otherwise it remains hidden.
Returns: (color) Periodic color.
dinamicZone(source, sampleLength, pcntAbove, pcntBelow)
Get Dynamic Zones
Parameters:
source : (float) Source
sampleLength : (int) Sample Length
pcntAbove : (float) Calculates the top of the dynamic zone, considering that the maximum values are above x% of the sample
pcntBelow : (float) Calculates the bottom of the dynamic zone, considering that the minimum values are below x% of the sample
Returns: A tuple with 3 series of values: (1) Upper Line of Dynamic Zone;
(2) Lower Line of Dynamic Zone; (3) Center of Dynamic Zone (x = 50%)
valueColorSpectrum
# Object to associate a color with a value, taking into account the previous value and its levels.
Fields:
currentValue
previousValue
level1
level2
level3
level4
level5
currentColorValue
colorLevel_Lv1
colorLevel_Lv1_Lv2
colorLevel_Lv2_Lv3
colorLevel_Lv3_Lv4
colorLevel_Lv4_Lv5
colorLevel_Lv5
theme
valueColor
# Object to associate a color with a value, taking into account the previous value
Fields:
currentValue
previousValue
currentColorValue
colorUp
colorDown
L_Trade_BoundariesLibrary "L_Trade_Boundaries"
Trade Boundaries suggest a strength of the security with respect to previous lows. The "L" implies library, and the trade boundaries implies it could be utilized for price strengths. Though, this should not be used as a single parameter to trade wildly. This library can be imported to a custom indicator to utilized the custom functions. There are moving averages attached at the bottom right of the canvas (overlay) to benchmark the closing price with respect to Moving Averages: 20, 28, and 200 (i.e., "D" if timeframe == "D") respectively. The Volume Indicator located at the top of the canvas is a default function (function already made by the trading view) this shows the volume with respect to the selected time frame. All of the indicators tell a story with regard to the security price (in strength terms).
What is available in this Library?
Litmus Color
> This is a function will change color of two numbers, if the first number is less than the second, the color will be red; otherwise, the color will be green.
Lister
> This is simply using an array by revisiting previous lows and plotting to the current time frame (i.e., "D"). There is a custom frequency input for the function, it will go back as much as the implied/specified length. Note: I am still learning how to use array, use this function with discretion. I would also appreciate if there are suggestions commented below.
Moving Average
> This function invokes three moving average metrics: 20, 28, and 200 respectively. The values are displayed at the bottom right of the canvas.
Timeframe Highlight
> This function checks for the input timeframe (i.e., "D", "W", "M") and if the time frame happens to be the same, it will give a "true" result. This result can be utilized for highlighting the positive results on the canvas (the red lines).
litmus_color(value1, value2)
Parameters:
value1
value2
lister(length)
Parameters:
length
moving_averages()
timeframe_highlight(timeframe)
Parameters:
timeframe