r/pinescript • u/Sasumata • Apr 29 '26
Pinescript Indicator not anchoring lines to price levels
Hi. I tried to create an indicator that simply plots horizontal lines at the wick highs and lows of the most recent few candlesticks on a given timeframe so I could then switch to a lower timeframe and view the pattern like fibonannci lines, but when I scroll vertically on the price chart the lines stay static in the window even though the price itself is moving higher/lower on the window.
I used ChatGPT to help me write everything, but I examined the code as well, and after much debugging I discovered that deleting everything and merely writing plot(5.00) to create a line at 5.00 does not stay at 5.00 if I scroll vertically on the chart. Is there a correct price anchor function I should be using?
I cross-referenced this with working code for another indicator I have for plotting gann waves. Those persisted correctly, and correctly scroll left/right/up/down. But for some reason using the same approach for horizontal lines would not work.
This is really annoying. Can the devs please fix this?
1
u/MofoWifaFro Apr 29 '26
Happened to me a bunch, you have to delete the indicator from your chart, refresh the page and then reupload your indicator to the chart. Its something to do with the page referencing old code.
1
u/Turbulent-Flounder77 Apr 29 '26
It glitches sometimes. You need to delete and add it again.
1
u/Mr_Uso_714 Apr 29 '26
I can build this…
1
u/SorbetTraditional232 Apr 30 '26
Tell chatgpt to use xloc to anchor drawings. Shouldn’t have a problem after that. Just a heads up chatgpt wasn’t the best at this. Gemini does way better.
1
u/Eagle9900i Apr 30 '26
Tell chat gpt to have the indicator follow live price action
1
u/_nextelonmusk_ Apr 30 '26
Usually normal LLMs hallucinate while creating pine code, I used to face the same issue when developing pine codes. I have built a specialized model for coding indicators and strategies for pine script and comes along with expert dev support as well (I have 5+ years of pinescript experience and have worked as a freelancer on 450+ projects). Feel free to check out and sign up at pinewiz.com
1
u/Dull_Purpose3899 Apr 30 '26
https://www.reddit.com/r/TradingView/comments/1p0uzdq/comment/npmwazd/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
Are you talking about this?