TradingView
stavros
Jan 11, 2014 9:36 PM

Example using "offset" to get just a horizontal line 

Bitcoin / U.S. DollarMt.Gox

Description

This shows how to use Pine script to see only a horizontal line on your chart.
This example shows the line at 3% below the last candle's close price.
Comments
stavros
@sn0wcrash The code is available in this chart. Click the "()" button in the "Stop" indicator in the header.
vmirage
Can you share the code? seems like the button is no longer there
stavros
Sorry, vmirage, but it seems I never stored this in my own charts so I don't have the code myself anymore. :/
I don't remember how I accomplished this now, but I would hope this kind of this is simple in Pine script now; this created when Pine was only a few weeks old.
vmirage
Unfortunately it is not easy to do it as there is no way to convert series into a single float value to use in hline. And I can't find any way to do it. It seems like you are the only person who managed convert them. Do you have any other code that does this at all? Isn't the pine script in your library unless you deliberately delete them?
stavros
OK, it's no longer 06:00 on a work day so I had time to re-familiarise myself with this site, which I haven't frequented in 2-years.
I found this in one of my saved charts, which will hopefully give you a nudge in the right direction:

study(title = "Stop Loss", shorttitle="Stop")

// show a stop at -3%
stop = close * 0.97

plot(stop, color = red, trackprice=true, offset=-100000)

Hope that helps. :)
vmirage
thanks
Zorro-astrian
So it's because the offset was so high it had no other choice but to plot just that one value as a horizontal line (rather than a series)...
If you want to use this specific value in a calculation however (rather than the whole series of values), you're up a creek at the moment (until they add this functionality)...
sn0wcrash
Mind sharing the code?
More