Convert TradingView indicators to Python

Chad-Thackray

Convert TradingView indicators to Python by Chad-Thackray

The video demonstrates how to convert TradingView indicators to Python and provides tips for creating an optimized library of indicators in Python. The speaker advises finding the indicator definition in TradingView's language reference manual or within the indicator menu itself and translating Pine script into Python code. They also show how to create a new function in Python that converts TradingView indicators to Python with optimized performance and resistance to NaNs. Additionally, the video covers using numpy and the ‘jit’ decorator from the ‘numba’ package to optimize indicators for faster execution, and emphasizes the importance of having a library of trusted indicators by comparing their values gathered from Python with those of TradingView for accuracy assessment.

00:00:00

In this section of the video, the speaker provides tips for converting TradingView indicators to Python code. They suggest finding the definition of the indicator in TradingView's language reference manual or within the indicator menu itself. Pine script can then be translated into Python code. They also recommend creating a library of optimized indicators that traders can rely on rather than relying on someone else's library. The speaker notes that there may be slight differences between results obtained from these libraries and TradingView, which can affect the accuracy of backtests and performance of live trading. To get 100% accurate indicators, traders can use data from TradingView, available through either the Pro Plus plan or the Python package TV data feed.

00:05:00

In this section of the video, the speaker explains how to create a new function in Python that converts TradingView indicators to Python. The function starts by creating an empty array filled with values of the EMA indicator, and then Alpha and values are assigned. The function is optimized for faster performance by creating an array of the same size as the source, rather than appending arrays or expanding their sizes. The function is also made resistant to NaNs. Finally, the function matches TradingView by slicing the array from zero to the length minus one.

00:10:00

In this section of the video, the presenter demonstrates how to optimize a TradingView indicator by using numpy and the ‘jit’ decorator from the ‘numba’ package which allows for just-in-time compilation of functions to increase the speed of execution. The presenter notes that one issue with the numpy approach is that it doesn’t retain information about the different times, but this can be addressed by assigning a new column in the data frame. The presenter notes the significant increase in speed from optimizing indicators using the ‘jit’ decorator and considers it worthwhile for the rest of one’s trading career in Python. Finally, the presenter benchmarks the optimized numpy version against the pandas version in pandas ta and shows that the numpy version is roughly ten times faster.

00:15:00

In this section, the presenter discusses the importance of having a library of indicators that traders trust and how they can analyze the robustness of these indicators by feeding them into themselves. The presenter then proceeds to compare the values gathered from Python to that of TradingView to assess the accuracy of the indicators. Overall, the video provides a helpful guide on how to convert TradingView indicators to Python for better trading strategies.

More from
Chad-Thackray

No videos found.

Related Videos

No related videos found.

Trending
AI Music

No music found.