intersectLibrary "intersect"
Find Line Intersection X/Y coordinates.
Simple to use, will find intersection if it exists on the segments
if the line segments do not cross on segment, an 'na' value will be returned
if you plot new items with the output coords, they still plot.
avoid this by setting a na(x) condition before plotting new items
get(l1, l2, ( optional _round) )
line intersection coordinates
Parameters:
l1 : (line) first line
l2 : (line) second line
_round : True to make an INT for plotting
if not used, will not round ( overload loophole)
Returns: with x as int if bool is used
LINE
[FFriZz]Priceline/TicksFFriZz | FrizLabz -- Priceline/Ticks
Due to TradingView not allowing us to change the size or style of the Priceline I decided to make this
You can change the style, size, color of the Price line with this Script
There is also an option for the closing price to be plotted on the Priceline
-- Colors --
You can have the Line and/or the Closing price change colors with the price movements
both are adjustable to your preference
-- Ticks --
Will show the difference in price from tick to tick
when Volume moves but price doesn't it will show '▲▼'
-- Adjustments --
The offset of the Close and Ticks can be adjusted from left to right
Can Extend Priceline in all directions
Can change the Line style and Width
Can change all the Text sizes and Colors
Can also Change Colors to change with Price movements
Can Change number of Ticks to show
-- Priceline --
You don't have to but I suggest going to the settings of your Chart and turning off the Priceline
-- Challenge --
There is Some code at the bottom that will move the Label and Ticks to the x% of your screen in from the right once
the last bar is no longer visible. I decided not to use it because even when the feature is turned off any movement of the
chart resets the Ticks. If you find out a way to have it not reset the Ticks Let me know!
If you find any bugs or have any suggestions feel free to DM me or leave a comment!
Hope you Enjoy! -- FFriZz | FrizLabz
AlgebraLibrary "Algebra"
Algebra functions.
line_fromXy(x1, y1, x2, y2)
Get line slope and y-intercept from coordinates
Parameters:
x1 : x coordinate 1 (int - bar index)
y1 : y coordinate 1 (float - price/value)
x2 : x coordinate 2 (int - bar index)
y2 : y coordinate 2 (float - price/value)
Returns: of line
line_getPrice(x, slope, yInt)
Get line slope and y-intercept from coordinates
Parameters:
x : x coordinate to solve for y (int - bar index)
slope : slope of line (float)
yInt : y-intercept of line (float)
Returns: y (price/value)
Line Chart with circles on sub chart / LineChart no CandlesLine Chart with circles as a subchart. The circle will appear only after the candle has been confirmed.
Things you can change:
- Source: open, high, low, close, hl2, hlc3, ohlc4, hlcc4
- Color: change the color of the line and the circles
have fun with it!
B1rd's Level ToolV0.1
Allows you to create arbitrary support levels based on bar data from a selected point in time and source.
Features:
- An interactive chart that lets you pick the level simply by dragging the vertical line associated with its start point.
- A secondary vertical line (end point) sets up a point in time from where this indicator is going to check for price crossing the level. (so it doesn't trigger immediately if you are on a lower time frame)
- There is also an option to hide the vertical lines once you're done initializing.
- No matter what timeframe you are on, you can just pick the source and timeframe the level should be locked in on.
- Optionally when line is crossed it stops plotting the line from that point onward and shows you a signal.
- You can customize the name, color, size and style of each level.
TODO:
- Add the option to set up multiple levels.
- Add Alerts.
- Work on Improving the layout.
- Bugfixed.
- Give proper title names to the style tab.
BoxLine_LibLibrary "BoxLine_Lib"
personal Library for line and box built in functions
lineXY(x)
get x1,y1,x2,y2 in a tuple
Parameters:
x : TODO: line
Returns: tuple of x1,y1,x2,y2
line(x)
Create line with only the y1 value(when line == na) or all
when line != na set x1,y1,x2,y2 individually just 1 or all
- use just the line value to set the x2 to current bar or time will set to time
- will auto pick xloc.bar_index or xloc.bar_time if not used
Parameters:
x : (line line,int x1,float y1,int x2,float y2,
string xloc,string extend,color color,string style,int width)
Returns: Line
boxXY(x)
get left,top,right,bottom in a tuple
Parameters:
x : box
Returns: tuple of left,top,right,bottom
box(x)
Create line with only the top,bottom value(when line == na) or all
when box != na set left,top,right,bottom individually just 1 or all
- use just the box value to set the right to current bar or time will set to time
- if right is above a number that a bar_index wouldnt be
Parameters:
x : box box,int left,float top,int right,
float bottom,color border_color, int border_width,
string border_style,string extend,string xloc,
color bgcolor,string text,string text_size, color text_color,
string text_halign,string text_valign,string text_wrap)
Returns: TODO: Box
Auto Trendline Indicator (based on fractals)A tool that automatically draws out trend lines by connecting the most recent fractals.
Description:
The process of manual drawing out trend lines is highly subjective. Many times, we don’t trade what we see, but what we “want to see”. As a result, we draw lines pointing to the direction that we wishfully want price to move towards. While there are no right/wrong ways to draw trend lines, there are, however, systematic/unsystematic ways to draw trend lines. This tool will systematically draw out trend lines based on fractals.
Additional feature:
This tool will also plot out symbols (default symbol “X”) to signify points of crossings. This can be useful for traders considering to use trend lines as part of their trading strategies.
Here is an interesting observation on the price actions of NASDAQ futures on a 5 second chart during regular trading hours on July 14, 2022.
It’s a phenomenon. People like to see straight lines connecting HL/LH, etc., so it's possible for the market as a whole to psychologically react to these lines. However, it is important to note that is is impossible to predict the direction of price. In the case above, price could have tanked below auto-drawn trend line. Fractal based trend lines should only be taken as references and regarded as price levels. No studies have ever proven that the slope of trend lines can indicate price's future direction.
More about fractals:
To understand more about fractals:
www.investopedia.com
www.tradingview.com
Contrary to what it sounds like, fractal in "technical analysis" does not refer to the recursive self-repeating patterns that appear in nature, such as the mesmerizing patterns found in snowflakes. The Fractal Markets Hypothesis claims that market prices exhibit fractal properties over time. Assuming this assertion to be true, then fractals can be used a tool to represent the chaotic movements of price is a simplified manner.
The purpose of this exercise is to take a tool that is readily available (ie. in this case, TradingView’s built-in fractals tool), and to create a newer tool based on it.
Parameters:
Fractal period (denoted as ‘n’ in code): It is the number of bars bounding a high/low point that must be lower/higher than it, respectively, in order for fractal to be considered valid. Period ‘n’ can be adjusted in this tool. Traditionally, chartists pick the value of 5. The longer it is, the less noise seen on the chart, and the pivot point may also be exhibited in higher timeframes. The drawback is that it will increase the period of lag, and it will take more bars to confirm the printed fractal.
Others: Intuitive parameters such as whether to draw historical trend lines, what color to use, which way to extend the lines, and whether or not to show points of crossings.
Support & Resistance[VTA]Description:
This indicator uses pivot points to draw support and resistance for you in different timeframes.
It also shows you the decrease in the increase of the currency compared to the resistance and support line, and you can see the end of the failures by the label.
Manufacturer:
This indicator was designed and developed by the VTA team.
DeleteArrayObject█ OVERVIEW
Delete array object according to array size such as label, line, linefill, box and table.
█ CREDITS
HeWhoMustNotBeNamed
Custom Price LineThis indicator lets you freely customize your price line. Choose between static or dynamic colors for falling/rising prices. In addition you can adjust the following:
Line style
Thickness
Length
Direction
It is also possible to mix different designs by using a single indicator.
Gap calculatorVERSION 1
This indicator base on detection of climax candles (Trend or Trading Range candles also available) then calculate average of open and close of those climax one.
Key-features of Gap line :
1 - forecast pullback
2 - finding support and resistance lines
3 - finding behavior of market
RelicusRoad - Signal LineWhen you have charts full of too many indicators, it can mess up with your analysis and cause analysis paralysis. Use RelicusRoad Signal Line to simply your charts with a beautiful color changing moving average line as per the strategies selected.
4 different strategies to choose from:
1) MACD
2) PMACD (Price Action + MACD)
3) Parabolic SAR
4) Momentum
GREEN: BUY ZONE
RED: SELL ZONE
FUNCTIONS OVERVIEW
MACD: Moving average convergence divergence ( MACD ) is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The MACD is calculated by subtracting the 26-period exponential moving average ( EMA ) from the 12-period EMA .
The result of that calculation is the MACD line. A 9 EMA of the MACD called the "signal line," is then plotted on top of the MACD line, which can function as a trigger for buy and sell signals. Traders may buy the security when the MACD crosses above its signal line and sell—or short—the security when the MACD crosses below the signal line. Moving average convergence divergence ( MACD ) indicators can be interpreted in several ways, but the more common methods are crossovers, divergences, and rapid rises/falls.
Moving average convergence divergence ( MACD ) is calculated by subtracting the 26-period exponential moving average ( EMA ) from the 12-period EMA .
MACD triggers technical signals when it crosses above (to buy) or below (to sell) its signal line.
The speed of crossovers is also taken as a signal of a market is overbought or oversold.
MACD helps investors understand whether the bullish or bearish movement in the price is strengthening or weakening.
PMACD: It's an improvement to MACD that you can use the Red/Green indications to make better decisions.
Parabolic SAR: The parabolic SAR indicator, developed by J. Wells Wilder, is used by traders to determine trend direction and potential reversals in price. The indicator uses a trailing stop and reverse method called "SAR," or stop and reverse, to identify suitable exit and entry points. Traders also refer to the indicator as the parabolic stop and reverse , parabolic SAR , or PSAR.
The parabolic SAR indicator appears on a chart as a series of dots, either above or below an asset's price, depending on the direction the price is moving. A dot is placed below the price when it is trending upward, and above the price when it is trending downward.
The parabolic SAR (stop and reverse) indicator is used by technical traders to spot trends and reversals.
The indicator utilizes a system of dots superimposed onto a price chart.
A reversal occurs when these dots flip, but a reversal signal in the SAR does not necessarily mean a reversal in the price. A PSAR reversal only means that the price and indicator have crossed.
Momentum: On paper, momentum investing seems less like an investing strategy and more like a knee-jerk reaction to market information. The idea of selling losers and buying winners is seductive, but it flies in the face of the tried and true Wall Street adage, "buy low, sell high."
Momentum investing is a trading strategy in which investors buy securities that are rising and sell them when they look to have peaked.
The goal is to work with volatility by finding buying opportunities in short-term uptrends and then sell when the securities start to lose momentum.
Then, the investor takes the cash and looks for the next short-term uptrend, or buying opportunity, and repeats the process.
Skilled traders understand when to enter into a position, how long to hold it for, and when to exit; they can also react to short-term, news-driven spikes or selloffs.
Risks of momentum trading include moving into a position too early, closing out too late, and getting distracted and missing key trends and technical deviations.
VPLineVPLine is a brand-new line indicator which automatically draws historical POC line with volume profile histograms based on user input session and configurations.
A colossal amount of function is deployed on the indicator: historical POC line, historical VA, historical VA high/low, volume profile histograms, volume profile value text (bid/ask/total), threshold function that limits the extension of the POC line based on user input etc.
Dashed Line Moving AveragesHere's a simple script which i concocted using ideas from various authors with the goal of creating a slightly better Moving Average dashed line script imo...I think i managed to do just that and a bit more.. =)
Features:
- Contains one of each VWMA SMA EMA. You can set the input length.
- Ability to set spacing between characters of the plotted moving average line
- Horizontal offset of the moving average lines (just in case)
- Can add any fancy characters that suits your taste e.g ( . , _ , -, !, *, rocket, lava, etc) to the moving average
- If you duplicate the script and modify the "Size" parameter of the plotchar() function's variables with the choices provided in the commented-out code; you can have some fun!
This script is for entertainment & educational purposes only.
Average Directional Index W/ 20Line (adjustable)This is basically trading views standard ADX indicator
All i added was an adjustable horizontal line since i could not find one anywhere on TV.
i did not like manually adding a horizontal line every time i loaded an instance of the ADX ...
sooooo here you go
enjoy!
Psychological LineThis indicator can be shown by the number of bars with consecutive higher closing prices over a period of time. The maximum value is equal to the period.
The default period value is 12.
Thresholds used with this period are 3, 6, and 9.
A drop below 3 suggests an approaching low, and a crossover above 9 warns about an upcoming top.
In this period, 6 is a neutral value and represents the borderline separating uptrends and downtrends.
[e2] Drawing Library :: Horizontal Ray█ OVERVIEW
Library "e2hray"
A drawing library that contains the hray() function, which draws a horizontal ray/s with an initial point determined by a specified condition. It plots a ray until it reached the price. The function let you control the visibility of historical levels and setup the alerts.
█ HORIZONTAL RAY FUNCTION
hray(condition, level, color, extend, hist_lines, alert_message, alert_delay, style, hist_style, width, hist_width)
Parameters:
condition : Boolean condition that defines the initial point of a ray
level : Ray price level.
color : Ray color.
extend : (optional) Default value true, current ray levels extend to the right, if false - up to the current bar.
hist_lines : (optional) Default value true, shows historical ray levels that were revisited, default is dashed lines. To avoid alert problems set to 'false' before creating alerts.
alert_message : (optional) Default value string(na), if declared, enables alerts that fire when price revisits a line, using the text specified
alert_delay : (optional) Default value int(0), number of bars to validate the level. Alerts won't trigger if the ray is broken during the 'delay'.
style : (optional) Default value 'line.style_solid'. Ray line style.
hist_style : (optional) Default value 'line.style_dashed'. Historical ray line style.
width : (optional) Default value int(1), ray width in pixels.
hist_width : (optional) Default value int(1), historical ray width in pixels.
Returns: void
█ EXAMPLES
• Example 1. Single horizontal ray from the dynamic input.
//@version=5
indicator("hray() example :: Dynamic input ray", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
inputTime = input.time(timestamp("20 Jul 2021 00:00 +0300"), "Date", confirm = true)
inputPrice = input.price(54, 'Price Level', confirm = true)
e2draw.hray(time == inputTime, inputPrice, color.blue, alert_message = 'Ray level re-test!')
var label mark = label.new(inputTime, inputPrice, 'Selected point to start the ray', xloc.bar_time)
• Example 2. Multiple horizontal rays on the moving averages cross.
//@version=5
indicator("hray() example :: MA Cross", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
float sma1 = ta.sma(close, 20)
float sma2 = ta.sma(close, 50)
bullishCross = ta.crossover( sma1, sma2)
bearishCross = ta.crossunder(sma1, sma2)
plot(sma1, 'sma1', color.purple)
plot(sma2, 'sma2', color.blue)
// 1a. We can use 2 function calls to distinguish long and short sides.
e2draw.hray(bullishCross, sma1, color.green, alert_message = 'Bullish Cross Level Broken!', alert_delay = 10)
e2draw.hray(bearishCross, sma2, color.red, alert_message = 'Bearish Cross Level Broken!', alert_delay = 10)
// 1b. Or a single call for both.
// e2draw.hray(bullishCross or bearishCross, sma1, bullishCross ? color.green : color.red)
• Example 3. Horizontal ray at the all time highs with an alert.
//@version=5
indicator("hray() example :: ATH", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
var float ath = 0, ath := math.max(high, ath)
bool newAth = ta.change(ath)
e2draw.hray(nz(newAth ), high , color.orange, alert_message = 'All Time Highs Tested!', alert_delay = 10)
MACD + Divergence + Line █ OVERVIEW
Here's the classic MACD with some simples features in plus.
█ CONCEPTS
4 features
1 — Classic MACD histogram, with 4 different colors such as above or below 0, and above or below the previous bar
2 — Display option to disable EMA
3 — A signal line that show the exact point, because the histogram view might be hard to be precise
4 — Looking for previous Divergences, Bullish, Bearish and Hidden Bullish and Bearish but I don't like Hidden divergences
█ OTHER SECTIONS
An oscillator is good to know where we are in the trends, but it's not enough to run a small business of trading, you need to learn how to use it.
What is a divergence ?
Thanks to The rational investor for teaching me how to use this indicator.
regressLibrary "regress"
produces the slope (beta), y-intercept (alpha) and coefficient of determination for a linear regression
regress(x, y, len) regress: computes alpha, beta, and r^2 for a linear regression of y on x
Parameters:
x : the explaining (independent) variable
y : the dependent variable
len : use the most recent "len" values of x and y
Returns: : alpha is the x-intercept, beta is the slope, an r2 is the coefficient of determination
Note: the chart does not show anything, use the return values to compute model values in your own application, if you wish.
Vertical LinesThis script plots vertical lines on charts or indicators. Unfortunately pinescript is lacking a vertical line plotting function. Vertical lines are useful to mark events, such as crossover of levels, indicators signals or as a time marker.
After searching the internet for a long time and trying different scripts, this script is the simplest and visually the best. You would think that plotting a vertical line would be relatively easy, it is not! I thank the unknow author for sharing this solution and now I will share it on tradingview to make it readily available to anybody that needs it.
RSI crossover signals are used as an example in this script. When the RSI crosses over 70 or below 30, the script plots a red or green vertical line.
The script plots a vertical line as a histogram bar. The histogram bar must have a height.
Setting the height near infinity like 1e20 will cover all the ranges from top to bottom in most charts, but doesn't work all the time. If the chart range is small in values, the line is not plotted or the chart is visually compressed because the top of the bar is also a data point in the chart. Another solution is to find the highest point in the chart and multiply it by a number from 2 to 10 to set the top of the histogram bar. But this solution doesn't work if the line is drawn in the indicator window. additionally if the chart or indicator includes negative values, a histogram bar with a negative height must be concatenated to the histogram bar with a positive height to cover the positive and negative range.
It would seem intuitive to include a vertical plot function since it is very useful and pinescript already has a horizontal line plot function called Hline. But pinescript is becoming less intuitive, and redundant. A case in point is Version 4 variable declaration and naming, it less intuitive and more redundant than previous versions. I beg Tradingview to adopt a more refined scripting language such as Matlab or Python for charting purposes. These languages can be easily ported to other analysis programs for AI or statistical analysis.
Logarithmic Trend ChannelThis indicator automatically draws a regression channel plotted on logarithmic scale from the first quotation.
This model is useful for the long term series data (such as 10 or 20 years time span).
The Pearson correlation measures the strength of the linear relationship between two variables. It has a value between to 1, with a value of 0 meaning no correlation, and + 1 meaning a total positive correlation.
Logarithmic price scales are a type of scale used on a chart, plotted such that two equivalent price changes are represented by the same vertical changes on the scale.
They differ from linear price scales because they display percentage points and not dollar price increases for a stock.
Technical issues
*The user have to pan over the chart from the beginning to the end of the study range (such as 10 years of bars) so the pine script could generate those lines on the chart.
*If on the chart the number of bar is less than the lookback period, it won't generate any lines as well.
Just a Vertical Line█ OVERVIEW
This is Just a Vertical Line. Nothing fancy or complicated.
Sometime, you might just need one vertical line on a specific date to appear on all of your charts for a quick comparison -or any other purposes-. With this script you you can do just that.
You will need to select that date ONCE and scroll through your charts and through different assets and that line will still be there. You can also activate a label to appear on top on that line! and customize what it says.
Perhaps.. you might want to see the asset's performance on that day, or since that day. Well... We got you. This script is equipped with a statistics box that includes the performance on that candle you chose or the performance TD -to date.-
It's not really hard, you can drag that date and change it without going through the settings as well.
█ Future Plans and upgrades to this script may include :
1. More statistics!
2. Range tools
█ How to use :
1. Add the script to your chart.
2. Open the settings, activate the date then choose it.
3. Change the date -if you want to- outside the settings box by dragging the vertical line across the chart
HAP Auto Trend Line [PRO]Hello Traders!
The trend line is among the most important tools used by technical analysts. Instead of looking at past business performance or other fundamentals, technical analysts look for trends in price action. A trend line helps technical analysts determine the current direction in market prices. Technical analysts believe the trend is your friend, and identifying this trend is the first step in the process of making a good trade, and it can tell Support/resistance is very good.
But when drawing Trend Lines, sometimes we're not sure where to start. From where is the starting point? And sometimes it can be drawn multiple lines with different support/resistance lines over time. This itself can be confusing, so I tried to create a tool that allows it to draw lines automatically. According to price movement.
Let's take a look at the variables you need to understand from our indicators.
For this indicator it works in two main parts:
Section of Trend Line
Trend Reversal section
Therefore, these two parts have separate functions. To be used as a component for easier decision-making.
Trend Line, as I said before, what it is. Next is Trend Reversal. I will simply say it is. A period of time when the candle tries to pump and dump. This will help point out the potential price reversal. And if there is a trend line area, it is an interesting point to consider. To identify possibilities.
Some variables from the settings page
Number of Bars to Check : It is the number of past candlesticks to consider. To identify the start of the Trend Line, if it meets the condition, it will automatically draw the Trend Line for you.
Trend Line Depth : It is the frequency. Of identifying the starting point Trend Line. If the value is large, it will find a low Trend Line, and if it is low, it will find more Trend Line. This is flexible. So you have to try it yourself. On demand.
Overview
You can turn it on or off. Support/resistance position either.
Select Emoji Support/resistance. Freely
Line style you want
your favorite color
customizable line intensity
the script is fast enough to run on 1sec chart:
fun !