Trade-o-Scope: Plot Custom DataTrade-o-Scope team presents the "Plot Custom Data" indicator.
"Plot Custom Data" is designed to help you bring the custom timeseries data and plot it on the chart.
Motivation:
In the fast-evolving landscape of markets, traders often find themselves analyzing a plethora of data sources, specialized market information, various metrics, etc. While TradingView offers a rich catalog of instruments and market data, there are cases where traders rely on unique data sources, custom calculations, bespoke metrics, or refined analytics that demand visualization.
In some cases, traditional visualization approaches for custom data like plotting in Excel or other platforms may suffice for some. still, we really adore all the great features TradingView supercharts have - native scaling and scrolling, drawing, combining data, applying indicators and strategies on top of any series, etc. The ability to play with custom data on TradingView charts is just a whole new level compared to any alternatives.
With this indicator, we aim to empower traders to effortlessly bring their custom data to the familiar and friendly interface of the TradingView chart.
Basic Features:
Easy Data Input : Simply paste your numerical timeseries data, whether it's a column from Excel, Google Sheets, CSV file, or multiline text from any text editor.
Flexible Configuration : Define the order of values, starting date, and timeframe to match the specifications of your data.
Custom appearance : Personalize your chart by assigning a title to your data and selecting colors for the plot.
Advanced Features:
Value Multiplier : Set a multiplier for the provided values to adjust their scale as needed.
Formatting Options : Customize the display format of values on the chart, whether as price, percentage, or volume.
Conditional Coloring : Define conditions for changing the plot color based on a specific threshold.
Plot Style Selection : Choose from various plot styles such as line, histogram, area, columns, and more, to best visualize your data.
Additional Visual References : Enhance data analysis by activating fixed horizontal lines to aid in visual interpretation.
Leverage TradingView Capabilities : Seamlessly apply various indicators from the TradingView catalog, such as Bollinger Bands or RSI, onto your custom data chart for comprehensive analysis.
Chart Example:
On the chart above, you can observe several "Plot Custom Data" indicators added to demonstrate what your custom data can look like and how multiple indicators can be combined, as well as the indicator configuration screen.
How it works:
The "Plot Custom Data" indicator processes the list of values provided on the configuration form and converts it into data points to be plotted on the chart. To determine the timing of plotting each value, the indicator uses the configured 'starting date' and 'timeframe'. This means the indicator will always plot each subsequent value from your list at the distance of one timeframe from the previous one.
Limitations and Best Practices:
1) The way timeseries data is inputted on the "Plot Custom Data" indicator configuration page, leverages a standard input text field. This input type has a limited character capacity, approximately 4000-4400 symbols. Therefore, the timeseries data cannot exceed this limit.
Let's illustrate this with an example.
Suppose you have a column in Excel that you wish to plot using the indicator. Consider the first 5 rows of values in your column:
| -123.45
| -43.5
| 3.12
| 9.6
| 146.78
To calculate the total symbols used, we need to account for the minus sign, numbers, decimal point, and two invisible symbols at the end of each line, which helps structure the text into multiple lines. So, in total, these 5 rows will use:
row_1 + row_2 + row_3 + row_4 + row_5 = 9 + 7 + 6 + 5 + 8 = 35 symbols or 7 symbols per row on avarage.
If we assume the remaining data follows a similar format, we can estimate the number of rows that can be inputted on the indicator configuration page:
from ~4000 / 7 = 571 rows
to ~4400 / 7 = 628 rows
The right approach to overcome this limitation is to reduce the number of symbols representing each value as much as possible. In our example, consider dropping all decimals, which would lead to an average of 5.4 symbols per row and allow for up to ~800 rows to be accepted by the input field.
If your data primarily consists of large values such as thousands or millions, consider dividing it by a multiplier like x1000 and activating the same multiplier in the indicator settings.
For example, instead of storing values like 5,620,000 in your list, store the value 562 and activate an x10,000 multiplier in the configuration to display the original value on the chart.
It is also possible to combine multiple indicators on one chart and split a larger list of values between them. If you need to display significantly more custom data on charts, you may contact us in DM to find\develop a proper solution.
2) Another important consideration is to ensure that all your data aligns with the selected timeframe in the indicator configuration.
Remember, you provide only the values to the indicator without corresponding dates. Dates are calculated automatically by the indicator based on the configured starting date and chosen timeframe. This means the indicator will always plot each subsequent value from your list at the distance of one timeframe from the previous one.
Here's an example:
Suppose you have a timeseries with 'date' and 'value' columns and a timeframe of 30 minutes:
# | date | value
--|---------------------------|---------
1 | 2024-01-01 11:30:00 | -241.45
2 | 2024-01-01 12:02:13 | -11.56
3 | 2024-01-01 13:00:00 | 21.87
..
..
6 | 2024-01-01 14:30:00 | 19.6
7 | 2024-01-01 15:00:00 |
8 | 2024-01-01 15:30:00 | 46.78
Rows 1-3 represent bad practice:
Row 2 is not precisely aligned with the timeframe, as it has a time of 12:02:13 instead of the expected 12:00:00. This won't cause errors, but the plot will show this value at 12:00:00.
Row 3 has a 1-hour difference from Row 2, which poses a real problem. As the indicator doesn't know the actual dates, it expects Row 3 to be 30 minutes later than Row 2, so it will plot 21.87 at 12:30:00 instead of the actual 13:00:00. And the rest of the values from your list will have offset on the chart as well.
Rows 6-7 represent the correct approach to overcome gaps in your data:
If, for some reason, there is no value for 15:00:00 in the original dataset, adding an empty Row 7 ensures each subsequent row is located 30 minutes from the previous one. The indicator will treat the empty row correctly, not plotting anything at this date on the chart, but will plot a line connecting the value of 19.6 from Row 6 with the value of 46.78 from Row 8.
How to use:
1) Add the "Plot Custom Data" indicator to the chart.
Voila! You'll see the plot based on the default timeseries values list and settings.
2) Paste your numerical timeseries data.
Define the order of values, starting date, and timeframe.
Assign a title to your data and select colors for the plot.
Voila! You'll see the plot based on your timeseries values list and settings.
3) Customize the indicator's settings:
Set a values multiplier if needed.
Specify the appropriate format for the values (price, percentage, or volume).
Choose whether to change the plot color based on conditions.
Select the plot style.
Add horizontal lines.
4) Explore your data, apply additional indicators and strategies from the TradingView catalog, or develop your own scripts using Pine.
Series
Range Adaptive EMA Float Series Inputuses range and change distance on arrays to allow for more control as well as any choice of input value as a controller for how tightly it grips the input signal.
Function - Sequence From SeriesFunction to create a array from a sample taken from a series (ex:. close, hlc3...).
Example - Switching LineExample of manipulating a float series to:
• switch from one source to another
• maintain a level by referencing itself
This script publication is intended for:
• Educational Purposes
Who is it for?
Anyone who wants to learn how to change the position or state of an active float series.
Bullish/Bearish Candle Series DistributionThe tool counts the number of consecutive bullish or bearish candles in a row and build a distribution of those series lengths. The entire history of an instrument is used.
Available modes:
Strict Bullish ( close > open )
Bullish ( close >= open )
Strict Bearish ( close <= open )
Bearish ( close < open )
Different chart types have different distributions:
Renko
Line Break
Min/Max Value Multiple Series FunctionTrying different solutions to find the minimum/maximum value in a set of predefined series
Back to zero: Understanding seriestype: pine series basic example
time required: 10 minutes
level: medium (need to know the "array" data variable as a generic programming concept, basic Pine syntax)
tl;dr how variables and series work in Pine
Pine is an array/vector language. That's something that twists how it behaves, and how we have to think about it. A lot of misunderstandings come from forgetting this fact. This example tries to clear that concept.
First, you need to know what an array is, and how it works in a programmig language. Also, having javascript under your belt helps too. If you don't, google "javascript array basic tutorial" is your friend :)
So, in pine arrays are called "series". Every variable is an array with values for each candle in the chart. if we do:
myVar = true
this is not a constant. It is a series of values for each candle, { true, true,....., true }
In practice, the result is the same, but we can access each of the values in the series, like myVar{0}, myVar{7}, myVar{anyNumber}....
Again, it is not a constant, since you can access/modify the each value individually
so, lets show it:
plot (myVar, clolor = gray)
this plots an horizontal line of value 1 ( 1 is equal to true ) so it's all good.
On to a more usual series:
tipicalSeries = close > open ? true : false
plot(tipicalSeries, color= blue)
This gives the expected result, a tipical up and down line with values at 1 or 0. Naturally, "tipicalSeries" is an array, the "ups" and "downs" are all stored under the same variable, indexed by the candles.
In Pine, the ZERO position in the array is the last one, which corresponds to the last candle on the right. Say you have a chart with 12 candles. The close would be the closing value of what we intuitively think as first candle, the one on the left. then close ... and so on.... until close , the value of the "last" candle, the one on the right. It actually helps to start thinking of the positions backwards, counting down to zero, rocket launch style :)
And back to our series. The myVar will also be the same size, from myVar to myVar .
When we do some operation with them, something simple like
if ( myVar == tipicalSeries)
what is really happening is that internally, Pine is checking each of the indexes, as in myVar == tipicalSeries , myVar == tipicalSeries .... myVar == tipicalSeries
And we can store that stuff to check it. simply:
result = (myVar == tipicalSeries) ? true : false //yes, this is the same as tipicalSeries, but we're not in a boolean logic tut ;)
plot (result)
The reason we can plot the result is that it is an array, not a single value. The example indicator i provide shows a plot where the values are obtained from different places in the array, this line here:
mySeries3 = mySeries2 and mySeries1
this creates a series that is the result of the PREVIOUS values stored (the zero index is the one most at the right, or the "current" one), which here just causes a shift in the plotted line by one candle.
Go ahead, grab a copy of my code, try to change the indexes and see the results. Understanding this stuff is critical to go deeper into Pine :)
Substratum Module [snowsilence]This module is meant to act as a framework and platform over which to develop other indicators. On its own it does essentially nothing, yet simplifies the work of adding basic customizations and flexibility to ideas immediately. The chart on this post is not a demo, so its better to just try adding the indicator to a test chart — you may find it more convenient to set "overlay=true" in the study header — and look into the settings for an intuitive sense of its purpose.
Please build off of this, let me know if you find it useful, and credit/reference me where it seems reasonable. Feedback is always appreciated!