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.
Utility
Swing DistanceHello fellas,
This simple indicator helps to visualize the distance between swings. It consists of two lines, the highest and the lowest line, which show the highest and lowest value of the set lookback, respectively. Additionally, it plots labels with the distance (in %) between the highest and the lowest line when there is a change in either the highest or the lowest value.
Use Case:
This tool helps you get a feel for which trades you might want to take and which timeframe you might want to use.
Side Note: This indicator is not intended to be used as a signal emitter or filter!
Best regards,
simwai
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)
Multi-Chart Widget [LuxAlgo]The Multi-Chart Widget tool is a comprehensive solution crafted for traders and investors looking to analyze multiple financial instruments simultaneously. With the capability to showcase up to three additional charts, users can customize each chart by selecting different financial instruments, and timeframes.
Users can add various widely used technical indicators to the charts such as the relative strength index, Supertrend, moving averages, Bollinger Bands...etc.
🔶 USAGE
The tool offers traders and investors a comprehensive view of multiple charts simultaneously. By displaying up to three additional charts alongside the primary chart, users can analyze assets across different timeframes, compare their performance, and make informed decisions.
Users have the flexibility to choose from various customizable chart types, including the recently added "Volume Candles" option.
This tool allows adding to the chart some of the most widely used technical indicators, such as the Supertrend, Bollinger Bands, and various moving averages.
In addition to the charting capabilities, the tool also features a dynamic statistic panel that provides essential metrics and key insights into the selected assets. Users can track performance indicators such as relative strength, trend, and volatility, enabling them to identify trends, patterns, and trading opportunities efficiently.
🔶 DETAILS
A brief overview of the indicators featured in the statistic panel is given in the sub-section below:
🔹Dual Supertrend
The Dual Supertrend is a modified version of the Supertrend indicator, which is based on the concept of trend following. It generates buy or sell signals by analyzing the asset's price movement. The Dual Supertrend incorporates two Supertrend indicators with different parameters to provide potentially more accurate signals. It helps traders identify trend reversals and establish trend direction in a more responsive manner compared to a single Supertrend.
🔹Relative Strength Index
The Relative Strength Index is a momentum oscillator that measures the speed and change of price movements. RSI oscillates between 0 and 100 and is typically used to identify overbought or oversold conditions in a market. Traditionally, RSI values above 70 are considered overbought, suggesting that the asset may be due for a reversal or correction, while RSI values below 30 are considered oversold, indicating potential buying opportunities.
🔹Volatility
Volatility in trading refers to the degree of variation or fluctuation in the price of a financial instrument, such as a stock, currency pair, or commodity, over a certain period of time. It is a measure of the speed and magnitude of price changes and reflects the level of uncertainty or risk in the market. High volatility implies that prices are experiencing rapid and significant movements, while low volatility suggests that prices are relatively stable and are not changing much. Traders often use volatility as an indicator to assess the potential risk and return of an investment and to make informed decisions about when to enter or exit trades.
🔹R-Squared (R²)
R-squared, also known as the coefficient of determination, is a statistical measure that indicates the proportion of the variance in the dependent variable that is predictable from the independent variable(s). In other words, it quantifies the goodness of fit of a regression model to the observed data. R-squared values range from %0 to %100, with higher values indicating a better fit of the model to the data. An R-squared of 100% means that all movements of a security are completely explained by movements in the index, while an R-squared value of %0 indicates that the model does not explain any of the variability in the dependent variable.
In simpler terms, in investing, a high R-squared, from 85% to 100%, indicates that the stock’s or fund’s performance moves relatively in line with the index. Conversely, a low R-squared (around 70% or less) indicates that the fund's performance tends to deviate significantly from the movements of the index.
🔶 SETTINGS
🔹Mini Chart(s) Generic Settings
Mini Charts Separator: This option toggles the visibility of the separator lines.
Number Of Bars: Specifies the number of bars to be displayed for each mini chart.
Horizontal Offset: Determines the distance at which the mini charts will be displayed from the primary chart.
🔹Mini Chart Settings: Top - Middle - Bottom
Mini Chart Top/Middle/Bottom: Toggle the visibility of the selected mini chart.
Symbol: Choose the financial instrument to be displayed in the mini chart. If left as an empty string, it will default to the current chart instrument.
Timeframe: This option determines the timeframe used for calculating the mini charts. If a timeframe lower than the chart's timeframe is selected, the calculations will be based on the chart's timeframe.
Chart Type: Selection from various chart types for the mini charts, including candles, volume candles, line, area, columns, high-low, and Heikin Ashi.
Chart Size: Determines the size of the mini chart.
Technical Indicator: Selection from various technical indicators to be displayed on top of the mini charts.
Note : Chart sizing is relative to other mini charts. For example, If all the mini charts are sized to x5 relative to each other, the result will be the same as if they were all sized as x1. This is because the relative proportions between the mini charts remain consistent regardless of their absolute sizes. Therefore, their positions and sizes relative to each other remain unchanged, resulting in the same visual representation despite the differences in absolute scale.
🔹Supertrend Settings
ATR Length: is the lookback length for the ATR calculation.
Factor: is what the ATR is multiplied by to offset the bands from price.
Color: color customization option.
🔹Moving Average Settings
Type: is the type of the moving average, available types of moving averages include SMA (Simple Moving Average), EMA (Exponential Moving Average), RMA (Root Mean Square Moving Average), HMA (Hull Moving Average), WMA (Weighted Moving Average), and VWMA (Volume Weighted Moving Average).
Source: Determines what data from each bar will be used in calculations.
Length: The time period to be used in calculating the Moving Average.
Color: Color customization option.
🔹Bollinger Bands Settings
Basis Type: Determines the type of Moving Average that is applied to the basis plot line.
Source: Determines what data from each bar will be used in calculations.
Length: The time period to be used in calculating the Moving Average which creates the base for the Upper and Lower Bands.
StdDev: The number of Standard Deviations away from the Moving Average that the Upper and Lower Bands should be.
Color: Color customization options for basis, upper and lower bands.
🔹Mini Chart(s) Panel Settings
Mini Chart(s) Panel: Controls the visibility of the panel containing the mini charts.
Dual Supertrend: Toggles the display of the evaluated dual super trend, based on the super trend settings provided below the option. The definitions for the options are the same as stated above for the super trend.
Relative Strength Index: Toggles the display of the evaluated RSI, based on the source and length settings provided below the option.
Volatility: Toggles the display of the calculated Volatility, based on the length settings provided below the option.
R-Squared: Toggles the display of the calculated R-Squared (R²), based on the length settings provided below the option.
🔶 LIMITATIONS
The tool allows users to display mini charts featuring various types of instruments alongside the primary chart instrument. However, there's a limitation: the selected primary chart instrument must have an ACTIVE market status. Alternatively, if the primary chart instrument is not active, the mini chart instruments must belong to the same exchange and have the same type as the primary chart instrument.
[TTI] Closing Range Indicator📜 ––––HISTORY & CREDITS––––
This Pine Script Utility indicator, titled " Closing Range Indicator," is designed and developed by TintinTrading but inspired by the teaching of Investor's Business Daily (IBD) and William O'Neil. It aims to help traders identify the closing range of a given timeframe, either daily or weekly.
🦄 –––UNIQUENESS–––
The unique feature of this indicator lies in its ability to simulate a functionality of Closing Range calculation based on hovering of the mouse over the close. It employs a conditional display that allows the user to set the indicator as 'invisible' without removing it from the chart and hence provides a numerical closing range value when hovering over the indicator.
🛠️ ––––WHAT IT DOES––––
The Closing Range Indicator calculates the closing range of a trading bar in terms of percentages. It computes the difference between the closing price and the low price of the bar, and then divides it by the range of the bar.
A stock that closes on the high would display 100%
A stock that closes on the low would display 0%
Generally, the higher the percentage the more bullish the close but there are exceptions to this rule.
The indicator can operate on two timeframes:
Daily : Computes the closing range based on the daily high, low, and closing prices.
Weekly : Computes the closing range based on the weekly high, low, and closing prices. If you enable the weekly it will show the weekly close on all daily timeframes. Meaning that if the week Closing range is 54.15% on Friday, it will show the value 54.15% for all days prior to Friday from the same week.
The indicator places a label at the close of each bar, with the label's tooltip showing the calculated closing range percentage. I generally hide the label and just reference the tooltip calculation with a a hoover on top of the bar.
💡 ––––HOW TO USE IT––––
Installation: Add the indicator to your TradingView chart by searching for " Closing Range Indicator" in the indicator library.
Reorder: Reorder the indicator so that it sits as the first indicator (even above the price) on the Pane. This will make sure that you always trigger the tooltip functionality.
Go to Settings:
Timeframe: Choose between daily ('D') and weekly ('W') timeframes from the settings.
Visibility: Enable the 'Make Invisible' option if you want the indicator to be hidden.
Interpretation:
A higher percentage indicates that the closing price is closer to the high of the range, signaling bullish sentiment.
A lower percentage indicates bearish sentiment.
Tooltip: Hover over the label to view the closing range in percentage terms.
Hide Active Candle [SteinG]Hide Active Candle
An essential tool for disciplined traders seeking to avoid making hasty decisions based on active bars that have not yet closed.
Have you ever found yourself eagerly anticipating an entry, only to be tempted by an active candle that starts to pull away? Or perhaps you've been caught in a trade where an active candle pushes against you, stirring unease and uncertainty. Fear not, for we have a solution!
"Hide Active Candle" is a simple Pine Script indicator designed to ghost the active bar on your chart, reinforcing the importance of patiently waiting for its closure before making any trading decisions. By masking the active candle, this indicator serves as a constant reminder to exercise caution and to base your actions on solid, confirmed information.
To make the most of this powerful tool, ensure that you are using a candlestick chart, as this script operates optimally within that framework. Follow these simple steps to get started:
1. Right-click on your chart and select "Settings..."
2. From the drop-down menu, choose "Symbol" under the "Chart Settings" section.
3. Disable every item in the list to fully utilize the capabilities of "Hide Active Candle."
But wait, there's more! We understand that each trader has unique preferences and requirements. That's why we've included customizable settings within the script to tailor it to your specific needs. You have the option to adjust the following parameters:
- Countdown seconds left : Specify the number of seconds before the bar closes when the current candle becomes visible.
- Bull candle color : Select the color that represents bullish candles on your chart.
- Bear candle color : Choose the color that indicates bearish candles.
- Equal candle color : Define the color for Doji star candles.
- Theme : Opt for a dark or light theme, as the active candle mask will be based on your chosen theme.
- Custom hidden color : Personalize the mask color according to your preferences.
By fine-tuning these settings, you can create a trading environment that perfectly suits your style and enhances your decision-making process.
fast_utilsLibrary "fast_utils"
This library contains my favourite functions. Will be updated frequently
count_int_digits()
Count int digits in number
Returns: : number of int digits in number
count_float_digits()
Count float digits in number
Returns: : number of float digits in number
stringify()
Convert values in array or matrix into string values
Returns: : array or matrix of string values
arrcompare()
Compare values in arrays
Returns: : bool value
arrdedup()
Remove duplicate values in array
Returns: : array without duplicates
ResInMins()
Converts current resolution in minutes
Returns: : return float number of minuted
MultOfRes(res, mult)
Convert current float TF in minutes to target string TF in "timeframe.period" format.
Parameters:
res : : current resolution in minutes
mult : : Multiple of current TF to be calculated.
Returns: : timeframe format string
columnsLibrary "columns"
Error Tolerant Matrix Setter/Getter Operations. Easy ways to add/remove items into start and end of Columns as well as arrays to grow and shrink matrix.
if mismatched sizes occur the typified NA value will be there to prevent catastrophic crashing.
Rows and Columns are split into 2 libraries due to limitations on number of exports as well as ease of style (columns.shift(), rows.pop() )
pop(_matrix)
do pop last Column off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of Last Column, removing it from matrix
shift(_matrix)
do shift the first Column off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of First Column, removing it from matrix
get(_matrix, _clmnNum)
retrieve specific Column of matrix
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
Returns: Array of selected Column number, leaving in place
push(_matrix, _clmnNum, _item)
add single item onto end of Column
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
_item : Item to Push on Column
Returns: shifted item from Column start
push(_matrix, _array)
add single item onto end of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to Push on Matrix
Returns: Void
unshift(_matrix, _clmnNum, _item)
slide single item into start of Column remove last
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
_item : Item to Unshift on Column
Returns: popped item from Column end
unshift(_matrix, _array)
add single item into first Column of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift into Matrix
Returns: Void
set(_matrix, _clmnNum, _array)
replace an array to an existing Column
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
_array : Array to place in Matrix
Returns: Column that was replaced
insert(_matrix, _clmnNum, _array)
insert an array to a new Column
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
_array : Array to place in Matrix
Returns: void
slideDown(_matrix, _array)
add single item onto end of Column
Parameters:
_matrix : Matrix To Edit
_array : Array to push to Matrix
Returns: shifted first Column
slideUp(_matrix, _array)
add single item onto end of Column
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift to Matrix
Returns: poppeed last Column
pullOut(_matrix, _clmnNum)
add single item onto end of Column
Parameters:
_matrix : Matrix To Edit
_clmnNum : Column being Targeted
Returns: removed selected Column
rowsLibrary "rows"
Error Tolerant Matrix Setter/Getter Operations. Easy ways to add/remove items into start and end of rows as well as arrays to grow and shrink matrix.
if mismatched sizes occur the typified NA value will be there to prevent catastrophic crashing.
columns and rows are split into 2 libraries due to limitations on number of exports as well as ease of style (columns.shift(), rows.pop() )
pop(_matrix)
do pop last row off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of Last row, removing it from matrix
shift(_matrix)
do shift the first row off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of First row, removing it from matrix
get(_matrix, _rowNum)
retrieve specific row of matrix
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
Returns: Array of selected row number, leaving in place
push(_matrix, _rowNum, _item)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_item : Item to Push on Row
Returns: shifted item from row start
push(_matrix, _array)
add single item onto end of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to Push on Matrix
Returns: Void
unshift(_matrix, _rowNum, _item)
slide single item into start of row remove last
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_item : Item to Unshift on Row
Returns: popped item from row end
unshift(_matrix, _array)
add single item into first row of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift into Matrix
Returns: Void
set(_matrix, _rowNum, _array)
replace an array to an existing row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_array : Array to place in Matrix
Returns: row that was replaced
insert(_matrix, _rowNum, _array)
insert an array to a new row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_array : Array to place in Matrix
Returns: void
slideDown(_matrix, _array)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_array : Array to push to Matrix
Returns: shifted first row
slideUp(_matrix, _array)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift to Matrix
Returns: popped last row
pullOut(_matrix, _rowNum)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
Returns: removed selected row
String to NumberA library that exposes a method to translate strings to numbers. Adapted from MichelT 's String to Number indicator.
NNFX Exposure UtilityOVERVIEW
This tool allows the user to manually keep track of how much of their account is currently exposed to each currency, and keep that information handy and organized on the chart as a table.
It is specialized for NNFX traders who are trading all the pairs among the 9 major currency crosses: AUD, CAD, CHF, EUR, GBP, JPY, NZD, SGD, USD.
HOW DO I USE THIS INDICATOR?
Before you take a trade, you should open the indicator settings for this indicator and check off which currencies you are about to go long and short on. Here are 3 trades taken as examples:
If you go long on EUR/USD with 2% risk, your exposure is 2% long on EUR and 2% short on USD.
Then if you go short on GBP/SGD with 2% risk, your exposure is 2% short on GBP and 2% long on SGD.
But if you go long on SGD/JPY with 2% risk, your exposure would now be 4% long on SGD and 2% short on JPY. This is against your rules if you are trading the NNFX way. So this tool allows you to see when you are about to accidentally overexpose yourself to any currency pair.
catchChecksLibrary "catchChecks"
Type Check for Function Builders to allow Single item to be
passed in, and determine what to do with the item, ie: need an x value?
function that allows label, line, box, float, or even a string..
check item type? string ? 'str.tonumber(_item)' can be in the same
switch as a 'line.get_price(_item, bar_index)' both outputting float
or for pulling a value from simple, array, or matrix, one function
that can switch between them. reduce overhead of many functions.
there are many ways to use this tool, the simplest may be
string/floats on one switch or grabbing colors from line/fill/label
please Share any great recipes you come up with!
typeIs(_temp, _doMeth)
Input anything..
Determine what it is.
Parameters:
_temp : (any) Matrix, Array, or Simple Item
_doMeth : (bool) True for M/A/S , false for int/float/string.. etc..
Returns: (string) Type of item checked. ('bool' .. or 'array'.. etc..)
calcLibrary "calc"
Library for math functions. will expand over time.
split(_sumTotal, _divideBy, _forceMinimum, _haltOnError)
Split a large number into integer sized chunks
Parameters:
_sumTotal : (int) Total numbert of items
_divideBy : (int) Groups to make
_forceMinimum : (bool) force minimum number 1/group
_haltOnError : (bool) force error if too few groups
Returns: int array of items per group
UtilityFunctionsLibrary "UtilityFunctions"
Utility functions written by me
printLabelOnLastBar_string(string)
Prints string in a label on the last bar
Parameters:
string : value to print
Returns: void
printLabelOnLastBar_float(float)
Prints float in a label on the last bar
Parameters:
float : value to print
Returns: void
printSeriesInReverseOnLabels(series)
Prints a float series in labels in reverse (the first value is on the last candle, the second value is on the second to last candle, etc.)
Parameters:
series : float values to print
Returns: void
isPeriodDailyBased(string)
Returns true/false if the period is Daily based (1D, 3D, ...)
Parameters:
string : timeframe period
Returns: true/false
get_multiplier(string)
Gets the mutliplier of the timeframe passed compared to the current timeframe. If current TF is 5m and the passed timeframe period is 30m, the result will be 6
Parameters:
string : timeframe param
Returns: simple float of the multiplier
pineCalc- Calculator for PineHello and welcome to v1.00 of pineCalc - the calculator for Pine
A sleek, quick, and discrete calculator in a window pane in your chart!
Right now it supports basic math operation and series of two numbers but will try to update it and don't hesitate to comment any ideas
SOME FEATURES:
- Supports decimal numbers.
- Switch statement with option to choose Addition, Subtraction, Multiplication , or Division
- Choose any two numbers to use math on
- Inputs, Math Type and Result Output
"Swap" - Bool/Position/Value : Array / Matrix / Var AutoswapLibrary "swap"
Side / Boundary Based All Types Swapper
- three automagical types for Arrays, Matrixes, and Variables
-- no signal : Long/ Short position autoswap
-- true / false : Boolean based side choice
-- Src / Thresh : if source is above or below the threshold
- two operating modes for variables, Holding mode only for arrays/matrixes
-- with two items, will automatically change between the two caveat is it does not delete table/box/line(fill VAR items automatically)
-- with three items, a neutral is available for NA input or neutral
- one function name for all of them. One import name that's easy to type/remember
-- make life easy for your conditional items.
side(source, thresh, _a, _b, _c)
side Change outputs based on position or a crossing level
Parameters:
source : (float) OPTIONAL value input
thresh : (float) OPTIONAL boundary line to cross
_a : (any) if Long/True/Above
_b : (any) if Short/False/Below
_c : (any) OPTIONAL NOT FOR MTX OR ARR... Neutral Item, if var/varip on a/b it will leave behind, ie, a table or box or line will not erase , if it's a varip you're sending in.
Returns: first, second, or third items based on input conditions
Please notify if bugs found.
Thanks.
No Active BarThis is probably the only script on TradingView that's clinically proven to lower your blood pressure!***
This script in conjunction with some chart settings changes can completely hide the active candle, only showing historic candles, thus, reducing risk of cardiac arrest and or panic attack.
What to do:
0. Make sure you are using a candlestick chart or this script won't work properly
1. Right click the chart and select "Settings..."
2. Select "Symbol" under the "Chart Settings" menu
3. Disable every item EXCEPT for the "Body"
4. Click on the boxes next to "Body" to access the color picker then change both box's transparency settings down to 0
(the script only colors closed bars, so the active bar will be present just transparent)
5. Right click on the price scale on the far left or far right side of the screen and hover the mouse over "Labels". If any selections have a check mark next to them click them to disable them (especially the "Ask & Bid" price setting since it tracks current price)
That's it! Instead of wicks the High & Low prices are plotted above and below the candles using a step line. It looks a bit strange at first but you'll get used to it. Check out the indicator settings to change the color and style of the High & Low lines.
***The statement could prove true for some but is mostly complete bullshit
matrixautotableLibrary "matrixautotable"
Automatic Table from Matrixes with pseudo correction for na values and default color override for missing values. uses overloads in cases of cheap float only, with additional addon for strings next, then cell colors, then text colors, and tooltips last.. basic size and location are auto, include the template to speed this up...
TODO : make bools version
var string group_table = ' Table'
var int _tblssizedemo = input.int ( 10 )
string tableYpos = input.string ( 'middle' , '↕' , inline = 'place' , group = group_table, options= )
string tableXpos = input.string ( 'center' , '↔' , inline = 'place' , group = group_table, options= , tooltip='Position on the chart.')
int _textSize = input.int ( 1 , 'Table Text Size' , inline = 'place' , group = group_table)
var matrix _floatmatrix = matrix.new (_tblssizedemo, _tblssizedemo, 0 )
var matrix _stringmatrix = matrix.new (_tblssizedemo, _tblssizedemo, 'test' )
var matrix _bgcolormatrix = matrix.new (_tblssizedemo, _tblssizedemo, color.white )
var matrix _textcolormatrix = matrix.new (_tblssizedemo, _tblssizedemo, color.black )
var matrix _tooltipmatrix = matrix.new (_tblssizedemo, _tblssizedemo, 'tool' )
// basic table ready to go with the aboec matrixes (replace in your code)
// for demo purpose, random colors, random nums, random na vals
if barstate.islast
varip _xsize = matrix.rows (_floatmatrix) -1
varip _ysize = matrix.columns (_floatmatrix) -1
for _xis = 0 to _xsize -1 by 1
for _yis = 0 to _ysize -1 by 1
_randomr = int(math.random(50,250))
_randomg = int(math.random(50,250))
_randomb = int(math.random(50,250))
_randomt = int(math.random(10,90 ))
bgcolor = color.rgb(250 - _randomr, 250 - _randomg, 250 - _randomb, 100 - _randomt )
txtcolor = color.rgb(_randomr, _randomg, _randomb, _randomt )
matrix.set(_bgcolormatrix ,_yis,_xis, bgcolor )
matrix.set(_textcolormatrix ,_yis,_xis, txtcolor)
matrix.set(_floatmatrix ,_yis,_xis, _randomr)
// random na
_ymiss = math.floor(math.random(0, _yis))
_xmiss = math.floor(math.random(0, _xis))
matrix.set( _floatmatrix ,_ymiss, _xis, na)
matrix.set( _stringmatrix ,_ymiss, _xis, na)
matrix.set( _bgcolormatrix ,_ymiss, _xis, na)
matrix.set( _textcolormatrix ,_ymiss, _xis, na)
matrix.set( _tooltipmatrix ,_ymiss, _xis, na)
// import here
import kaigouthro/matrixautotable/1 as mtxtbl
// and render table..
mtxtbl.matrixtable(_floatmatrix, _stringmatrix, _bgcolormatrix, _textcolormatrix, _tooltipmatrix, _textSize ,tableYpos ,tableXpos)
matrixtable(_floatmatrix, _stringmatrix, _bgcolormatrix, _textcolormatrix, _tooltipmatrix, _textSize, tableYpos, tableXpos) matrixtable
Parameters:
_floatmatrix : float vals
_stringmatrix : string
_bgcolormatrix : color
_textcolormatrix : color
_tooltipmatrix : string
_textSize : int
tableYpos : string
tableXpos : string
matrixtable(_floatmatrix, _stringmatrix, _bgcolormatrix, _textcolormatrix, _textSize, tableYpos, tableXpos) matrixtable
Parameters:
_floatmatrix : float vals
_stringmatrix : string
_bgcolormatrix : color
_textcolormatrix : color
_textSize : int
tableYpos : string
tableXpos : string
matrixtable(_floatmatrix, _stringmatrix, _bgcolormatrix, _txtdefcol, _textSize, tableYpos, tableXpos) matrixtable
Parameters:
_floatmatrix : float vals
_stringmatrix : string
_bgcolormatrix : color
_txtdefcol : color
_textSize : int
tableYpos : string
tableXpos : string
matrixtable(_floatmatrix, _stringmatrix, _txtdefcol, _bgdefcol, _textSize, tableYpos, tableXpos) matrixtable
Parameters:
_floatmatrix : float vals
_stringmatrix : string
_txtdefcol : color
_bgdefcol : color
_textSize : int
tableYpos : string
tableXpos : string
matrixtable(_floatmatrix, _txtdefcol, _bgdefcol, _textSize, tableYpos, tableXpos) matrixtable
Parameters:
_floatmatrix : float vals
_txtdefcol : color
_bgdefcol : color
_textSize : int
tableYpos : string
tableXpos : string
Syminfo [Epi]Hello! This little script tells you everything TradingView lets you access in a ticker's syminfo in Pine Script:
- description
- type: crypto, economic, forex, fund, futures, index, spread, stock
- tickerid, such as AMEX:BLOK
- prefix, such as AMEX
- Ticker, such as BLOK
- root: for derivatives such as futures contracts
- currency, such as USD
- base currency: returns 'BTC' for the ticker 'BTCUSD'
- mintick
- point value
- session: regular, extended
- timezone
Some surprises I found in my development:
- there are some more types than mentioned in the documentation,
- the tickerid takes on additional information if you adjust for dividends or show extended session,
- the prefix contains "_DL" additions depending on your data subscriptions, .e.g. "CME_MINI_DL:ES1!",
- with futures, TV will show session.regular both for the 'regular' and the 'electronic' session.
- Unfortunately, syminfo does not contain the 'sector', although TV has the information in the database (the sector is shown in the screener but not accessed in Pine Script).
I use this little utility in my development and hope it's useful for the community. I see such a great number of contributions from the community and would like to give back, even if it's not much.
[TEMPLATE] Code Block Comments█ OVERVIEW
Here I present to the community at large a collection of code comment blocks that I think will be useful, especially for larger script projects bordering on 2,000 lines or above of code.
█ PLANNED FUTURE UPDATES
Work with the community to expand this template to be even more useful with the inclusion of useful global colour sets, variables, tooltips, groups, etc.
better script thumbnail.
full-screen table or label outlining the script's use-cases.
AbdulLibraryLibrary "AbdulLibrary"
The library consists of three sections:
Technical Analysis Functions - A collection of tools commonly used by day traders
Trading Setup Filters Functions - A number of filters that help day traders to screen trading signals
Candlestick Pattern Detection Functions - To detect different candlestick patterns that are used in day trading setups
Note that this would have been possible without the help of @ZenAndTheArtOfTrading as I build-up this library after completing his pine script mastery course so big thanks to him
The content of the library are:-
fibLevels(preDayClose, preDayHigh, preDayLow) Calculates Daily Pivot Point and Fibonacci Key Levels
Parameters:
preDayClose : The previous day candle close
preDayHigh : The previous day candle high
preDayLow : The previous day candle low
Returns: Returns Daily Pivot Point and Fibonacci Key Levels as a tuple
bullishFib(canHigh, canLow, fibLevel) Calculates Fibonacci Levels in Bullish move
Parameters:
canHigh : The high of the move
canLow : The low of the move
fibLevel : The Fib level as % you want to calculate
Returns: Returns The Fib level for the Bullish move
bearishFib(canHigh, canLow, fibLevel) Calculates Fibonacci Levels in Bearish move
Parameters:
canHigh : The high of the move
canLow : The low of the move
fibLevel : The Fib level as % you want to calculate
Returns: Returns The Fib level for the Bearish move
getCandleSize() Calculates the size of candle (high - low) in points
Returns: Returns candle size in points
getCandleBodySize() Calculates the size of candle (close - open) in points
Returns: Returns candle body size in points
getHighWickSize() Calculates the high wick size of candle in points
Returns: Returns The high wick size of candle in points
getLowWickSize() Calculates the low wick size of candle in points
Returns: Returns The low wick size of candle in points
getBodyPercentage() Calculates the candle body size as % of overall candle size
Returns: Returns The candle body size as % of overall candle size
isSwingHigh(period) Checks if the price has created new swing high over a period of time
Parameters:
period : The lookback time we want to check for swing high
Returns: Returns True if the current candle or the previous candle is a swing high
isSwingLow(period) Checks if the price has created new swing low over a period of time
Parameters:
period : The lookback time we want to check for swing low
Returns: Returns True if the current candle or the previous candle is a swing low
isDojiSwingHigh(period) Checks if a doji is a swing high over a period of time
Parameters:
period : The lookback time we want to check for swing high
Returns: Returns True if the doji is a swing high
isDojiSwingLow(period) Checks if a doji is a swing low over a period of time
Parameters:
period : The lookback time we want to check for swing low
Returns: Returns True if the doji is a swing low
isBigBody(atrFilter, atr, candleBodySize, multiplier) Checks if a candle has big body compared to ATR
Parameters:
atrFilter : Check if user wants to use ATR to filter candle-setup signals
atr : The ATR value to be used to compare candle body size
candleBodySize : The candle body size
multiplier : The multiplier to be used to compare candle body size
Returns: Returns Boolean true if the candle setup is big
isSmallBody(atrFilter, atr, candleBodySize, multiplier) Checks if a candle has small body compared to ATR
Parameters:
atrFilter : Check if user wants to use ATR to filter candle-setup signals
atr : The ATR value to be used to compare candle body size
candleBodySize : The candle body size
multiplier : The multiplier to be used to compare candle body size
Returns: Returns Boolean true if the candle setup is small
isHammer(fibLevel, colorMatch) Checks if a candle is a hammer based on user input parameters and candle conditions
Parameters:
fibLevel : Fib level to base candle body on
colorMatch : Checks if user needs for the candel to be green
Returns: Returns Boolean - True if the candle setup is hammer
isShootingStar(fibLevel, colorMatch) Checks if a candle is a shooting star based on user input parameters and candle conditions
Parameters:
fibLevel : Fib level to base candle body on
colorMatch : Checks if user needs for the candel to be red
Returns: Returns Boolean - True if the candle setup is star
isBullEngCan(allowance, period) Check if a candle is a bullish engulfing candle
Parameters:
allowance : How many points the candle open is allowed to be off (To allow for gaps)
period : The lookback period for swing low check
Returns: Boolean - True only if the candle is a bullish engulfing candle
isBearEngCan(allowance, period) Check if a candle is a bearish engulfing candle
Parameters:
allowance : How many points the candle open is allowed to be off (To allow for gaps)
period : The lookback period for swing high check
Returns: Boolean - True only if the candle is a bearish engulfing candle
isBullDoji(maxSize, wickLimit, colorFilter) Check if a candle is a bullish doji candle
Parameters:
maxSize : Maximum candle body size as % of total candle size to be considered as doji
wickLimit : Maximum wick size of one wick compared to the other wick
colorFilter : Checks if the doji is green
Returns: Boolean - True if the candle is a bullish doji
isBearDoji(maxSize, wickLimit, colorFilter) Check if a candle is a bearish doji candle
Parameters:
maxSize : Maximum candle body size as % of total candle size to be considered as doji
wickLimit : Maximum wick size of one wick compared to the other wick
colorFilter : Checks if the doji is red
Returns: Boolean - True if the candle is a bearish doji
isBullOutBar() Check if a candle is a bullish outside bar
Returns: Boolean - True if the candle is a bullish outside bar
isInsideBar() Check if a candle is an inside bar
Returns: Returns Boolean - True if a candle is an inside bar
Punchline_LibLibrary "Punchline_Lib"
roundSmart(float) Truncates decimal points of a float value based on the amount of digits before the decimal point
Parameters:
float : _value any number
Returns: float
tostring_smart(float) converts a float to a string, intelligently cutting off decimal points
Parameters:
float : _value any number
Returns: string
Stock Dividend Periodicityexperimental:
a basic method to evaluate stock dividend periodicity.
known issues:
* it does not adapt well to changes in periodicity, if there is a big enough change on the dividend period plan.