{"id":23454,"date":"2023-04-09T13:18:47","date_gmt":"2023-04-09T13:18:47","guid":{"rendered":"https:\/\/www.highcharts.com\/blog\/?p=23454"},"modified":"2026-01-13T11:29:42","modified_gmt":"2026-01-13T11:29:42","slug":"stock-charts-in-python-with-highcharts-stock-using-technical-indicators","status":"publish","type":"post","link":"https:\/\/www.highcharts.com\/blog\/integration\/stock-charts-in-python-with-highcharts-stock-using-technical-indicators\/","title":{"rendered":"Stock charts in Python with Highcharts stock &#8211; Using Technical Indicators"},"content":{"rendered":"<p><a href=\"https:\/\/www.highcharts.com\/products\/stock\/\" target=\"_blank\" rel=\"noopener\">Highcharts Stock<\/a> is a powerful JavaScript data visualization library that enables you to design rich, beautiful, and highly interactive data visualizations of time series data \u2013 including asset (stock, bond, real estate, etc.) prices. And using Highcharts Stock for Python, which is part of the broader <a href=\"https:\/\/github.com\/highcharts-for-python\" target=\"_blank\" rel=\"noopener\">Highcharts for Python Toolkit<\/a>, you can easily and rapidly use Highcharts Stock in your Python code.<\/p>\n<p><i><b>Tip<\/b><br \/>\nThe Highcharts Stock for Python capabilities are quite extensive, and this tutorial is meant to just be a quick intro to using technical indicators in Highcharts Stock for Python. But we definitely recommend that you review our <a href=\"https:\/\/www.highcharts.com\/blog\/posts\/python\/\" target=\"_blank\" rel=\"noopener\">other tutorials<\/a> to see more detail on how you can enrich your data visualizations using Highcharts Stock for Python and Highcharts Stock itself.<\/i><\/p>\n<p>In addition to providing you with over 70 different base visualizations, Highcharts Stock and Highcharts Stock for Python also give you more than 40 different technical indicators, which are built-in statistical and analytical visualizations that the library will automatically calculate and visualize for you on your charts. No more calculating moving averages in your data frames or determining banding bounds! For a full <a href=\"https:\/\/stock-docs.highchartspython.com\/en\/latest\/visualizations.html#technical-indicators\" target=\"_blank\" rel=\"noopener\">list of the technical indicators offered by Highcharts Stock for Python<\/a>, please take a look at the <a href=\"https:\/\/stock-docs.highchartspython.com\/en\/latest\/visualizations.html#technical-indicators\" target=\"_blank\" rel=\"noopener\">Supported Visualizations &gt; Technical Indicators section<\/a> of the library\u2019s documentation,<\/p>\n<p>This tutorial will show you how you can easily and rapidly add and configure technical indicators to your Highcharts Stock visualizations using Highcharts Stock for Python.<\/p>\n<h2>Getting Started with Highcharts Stock for Python<\/h2>\n<p>To use Highcharts Stock for Python, like with any Python library, you first have to install it. That\u2019s super easy: just open your Python project (in your virtual environment \u2013 you are using virtual environments, right?) and execute:<\/p>\n<pre>$ pip install highcharts-stock<\/pre>\n<p>And that\u2019s it! Highcharts Stock for Python will now be installed in your project and available for use. To use it in your code, you just have to import it the way you would any other library.<\/p>\n<h2>Importing Highcharts Stock for Python<\/h2>\n<p>The Highcharts Stock for Python library is quite big. It\u2019s got a rich (read: complicated) API, with lots of different objects and modules. That\u2019s a reflection of the visualization power that Highcharts offers you, but it does make the decision of what to import and how to import it a little more complicated.<\/p>\n<p>Python best practice is to import only what you need, which helps to maximize the performance of your Python code and prevents your application\u2019s namespace from getting cluttered with various things (and further reducing the memory footprint of your Python code, which is always good).<\/p>\n<p>You can either import specific things from their precise locations, or you can also just import the catch-all highcharts module, which flattens the entire API and exposes just about every class\/object in one location. We definitely recommend importing things from their precise location like so:<\/p>\n<pre># Import classes using precise module indications. For example:\r\nfrom highcharts_stock.chart import Chart\r\nfrom highcharts_stock.global_options.shared_options import SharedStockOptions\r\nfrom highcharts_stock.options import HighchartsStockOptions\r\nfrom highcharts_stock.options.plot_options.candlestick import CandlestickOptions\r\nfrom highcharts_stock.options.series.candlestick import CandlestickSeries<\/pre>\n<p>In Highcharts Stock for Python, technical indicators are treated the same as any other series type. This means that they have corresponding <code>.options.plot_options<\/code> classes and <code>.options.series<\/code> classes, so you can import them and work with them in ways very similar to standard series types \u2013 even if their APIs are a little different since they don\u2019t expect their own data (they are calculated from the other series in your chart).<\/p>\n<h2>A Super Simple Example<\/h2>\n<p>While the fact that you can import and work with technical indicator series the same way you would any other series, there\u2019s a much easier way to work with them. And that\u2019s to use the <code>.add_indicator()<\/code> method.<\/p>\n<p>Let\u2019s assume that you have created a Highcharts Stock Chart instance called <code>my_chart<\/code>, and that in that chart you have created a CandlestickSeries which has an <code>.id<\/code> of <code>\u201cmy_series\u201d<\/code> and which is also stored in an instance called <code>my_series<\/code>. Now, let\u2019s say that we want to add a Linear Regression based on <code>my_series<\/code>. You have two different ways to do this:<\/p>\n<h3>Using Chart.add_indicator()<\/h3>\n<p>You can call the <code>.add_indicator()<\/code> method on your <code>Chart<\/code> instance as below:<\/p>\n<pre># Add a Linear Regression technical indicator calculated from my_series to my_chart.\r\nmy_chart.add_indicator('linear regression',\r\n  series = 'my_series',\r\n  indicator_kwargs = {\r\n    'dash_style': 'Dash',\r\n    'id': 'my_linear_regression',\r\n    'name': \u2018My Linear Regression Indicator '\r\n  })<\/pre>\n<p>So let\u2019s breakdown what the above method call is doing. First, you\u2019re telling the <code>my_chart<\/code> object that you want to add an indicator, specifically an indicator named <code>\u201clinear regression\u201d<\/code>. This tells Highcharts for Stock to use to create an instance of the <code>LinearRegressionSeries<\/code>. For convenience, you can use human-readable indicator names (as found in the <a href=\"https:\/\/stock-docs.highchartspython.com\/en\/latest\/visualizations.html#technical-indicators\" target=\"_blank\" rel=\"noopener\">list of supported technical indicators<\/a>) or the prefix in the indicator series class name (the part before <code>-Series<\/code>).<\/p>\n<p>Next, we\u2019re telling the <code>my_chart<\/code> object that your new <code>LinearRegressionSeries<\/code> instance should be linked to whatever series exists on the chart that has an <code>.id<\/code> of <code>\u2018my_series\u2019<\/code>. This argument will either accept a string (indicating the <code>.id<\/code> of an existing series) or a <code>-Series<\/code> instance. If the chart does not already have a series with that .id, then it will add the new series. Otherwise, it will overwrite the existing series.<\/p>\n<p>And finally we\u2019re including a handful of keyword arguments which will be passed to the <code>LinearRegressionSeries<\/code> when it is instantiated. In this case, we\u2019re passing the <code>dash_style<\/code>, <code>id<\/code>, and <code>name<\/code> keyword arguments which correspond to identically-named properties on the <code>LinearRegressionSeries<\/code> instance.<\/p>\n<p>And that\u2019s it! Your chart should now feature a linear regression chart similar to the one shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-23458 aligncenter\" src=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2023\/04\/02095217\/A-stock-line-chart-displays-a-linear-regression-char-using-AAPL-data-560x283.jpg\" alt=\"A stock line chart displays a linear regression char using AAPL data\" width=\"560\" height=\"283\" srcset=\"https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2023\/04\/02095217\/A-stock-line-chart-displays-a-linear-regression-char-using-AAPL-data-560x283.jpg 560w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2023\/04\/02095217\/A-stock-line-chart-displays-a-linear-regression-char-using-AAPL-data-760x385.jpg 760w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2023\/04\/02095217\/A-stock-line-chart-displays-a-linear-regression-char-using-AAPL-data-768x389.jpg 768w, https:\/\/wp-assets.highcharts.com\/www-highcharts-com\/blog\/wp-content\/uploads\/2023\/04\/02095217\/A-stock-line-chart-displays-a-linear-regression-char-using-AAPL-data.jpg 830w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<h3>Using Series.add_indicator()<\/h3>\n<p>You can call the <code>.add_indicator()<\/code> method on your <code>-Series<\/code> instance as below:<\/p>\n<pre># Add an indicator to the my_series CandlestickSeries instance.\r\nmy_series.add_indicator(my_chart,\r\n  indicator = 'linear regression',\r\n  indicator_kwargs = {\r\n    'dash_style': 'Dash',\r\n    'id': 'my_linear_regression',\r\n    'name': \u2018My Linear Regression Indicator '\r\n  })<\/pre>\n<p>So let\u2019s breakdown what the above method call is doing. First, you\u2019re telling the <code>my_series<\/code> instance that you want to add an indicator, and that you want this indicator added (along with <code>my_series<\/code> if it isn\u2019t already) to the Chart instance found in the <code>my_chart<\/code> variable.<\/p>\n<p>Next, you\u2019re telling it that you specifically want to add an indicator named <code>\u201clinear regression\u201d<\/code>. This tells Highcharts for Stock to use to create an instance of the <code>LinearRegressionSeries<\/code>. For convenience, you can use human-readable indicator names (as found in the list of supported technical indicators) or the prefix in the indicator series class name (the part before <code>-Series<\/code>).<\/p>\n<p>And finally we\u2019re including a handful of keyword arguments which will be passed to the <code>LinearRegressionSeries<\/code> when it is instantiated. In this case, we\u2019re passing the <code>dash_style<\/code>, <code>id<\/code>, and <code>name<\/code> keyword arguments which correspond to identically-named properties on the <code>LinearRegressionSeries<\/code> instance.<\/p>\n<p>And that\u2019s it! When visualized, your chart should now feature a linear regression series similar to the one above.<\/p>\n<h2>More Resources<\/h2>\n<p>The above tutorial is just a really simple example of how you can create rich visualizations with just a handful of method calls using Highcharts for Python. But the library offers so much more! We recommend you take a look at the following additional resources which you may find useful:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/highcharts-stock-python-basic-tutorial\" target=\"_blank\" rel=\"noopener\"> Using Highcharts Stock for Python &#8211; Basic Tutorial<\/a><\/li>\n<li><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/using-highcharts-for-python-basic-tutorial\" target=\"_blank\" rel=\"noopener\">Highcharts for Python: Tutorials<\/a><\/li>\n<li><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/exporting-static-charts-highcharts-python\" target=\"_blank\" rel=\"noopener\">Exporting Static Charts using Highcharts for Python<\/a><\/li>\n<li><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/templating-and-shared-options-highcharts-python\" target=\"_blank\" rel=\"noopener\">Using Templating and Shared Options in Highcharts for Python <\/a><\/li>\n<li><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/highcharts-python-pandas-pyspark\" target=\"_blank\" rel=\"noopener\">Using Highcharts for Python with Pandas and PySpark <\/a><\/li>\n<li><a href=\"https:\/\/stock-docs.highchartspython.com\/en\/latest\/\" target=\"_blank\" rel=\"noopener\">Highcharts for Python: API Reference Documentation <\/a><\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<h2><strong>Related posts<\/strong><\/h2>\n<ul>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/post\/stock-chart-examples-using-highcharts-stock\/\">Stock chart examples using Highcharts Stock<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/stock-charting-with-highcharts\/\">Stock charting with Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/financial-charts-with-highcharts\/\">Financial charts with Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/post\/intraday-chart-examples-using-highcharts\/\">Intraday chart examples using Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/post\/climate-data-visualization-using-highcharts\/\">Climate data visualization using Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/tutorials\/real-time-data-visualization-using-highcharts\/\">Real-time data visualization using Highcharts<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A step-by-step tutorial to learn how to use technical indicators with python and Highcharts Stocks<\/p>\n","protected":false},"author":273,"featured_media":23577,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","hc_selected_options":[],"footnotes":""},"categories":[1105],"tags":[883,885],"coauthors":[983],"class_list":["post-23454","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-integration","tag-highcharts-stock","tag-python"],"_links":{"self":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/users\/273"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/comments?post=23454"}],"version-history":[{"count":4,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23454\/revisions"}],"predecessor-version":[{"id":26012,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23454\/revisions\/26012"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media\/23577"}],"wp:attachment":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media?parent=23454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/categories?post=23454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/tags?post=23454"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=23454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}