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.
crossover signals are used as an example in this script. When the 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.
Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.