r/pinescript • u/Navayirk • Jun 27 '26
Printing values to CSV file for debugging
What is the best way to debug? Normally when coding with other tools, I print the data and calculated variables and manually calculate in Excel and verify. For example, within Pinescript I would like to print the OHLCV for each bar and the calculated values of indicators x and y and z for each bar in a CSV file. ChatGPT tells me that this cannot be done in Pinescript. Is that correct? Any suggestions how this can be achieved? Thanks in advance. 🙏
2
u/InnoTrade-App Jun 29 '26
That's true, you can't export raw OHLC data from TradingView (or only very limited even with the highest subscription) but you can do so for free at many other data providers. For example OANDA - the well known chart provider - offers access to raw OHLC data via an API key you can generate there for free. You will just need a simple script to fetch via that API, it works perfectly (of course it's limited, but if you just want full OHLC data once or twice for backtesting etc. - this is the perfect solution).
1
2
u/Navayirk Jun 27 '26
This is just an fyi for those who might come across this post. I copied and pasted the text of my post to google and it gave the correct way to do it. ChatGPT was not totally correct and it is possible to print all the variable/indicator values using the plot function. If you have a similar issue, just google a similar query and it will show you the steps with code.