Determining the Market Regime With Indicators

A Visual Way of Using Technical Indicators to Understand the Current Regime.

Sofien Kaabar, CFA
11 min readMay 20, 2022


Color-coding charts can be helpful to determine the market’s state when we want to take a quick glance at the charts. True we might be able to determine the trend visually or by using moving averages, but we can also use other indicators and transform the chart so that it reflects the indicator’s values. This article will discuss how to do that. The aim is to be able to produce multiple charts at the same time with a color code that shows our conditions.

I have released a new book after the success of my previous one “Trend Following Strategies in Python”. It features a lot of advanced contrarian indicators and strategies with a GitHub page dedicated to the continuously updated code. If you are interested, you could buy the PDF version directly through a PayPal payment of 9.99 EUR.

Please include your email in the note before paying so that you receive it on the right address. Also, once you receive it, make sure to download it through google drive.

Fetching Historical OHLC Data

One of the most famous trading platforms in the retail community is the MetaTrader5 software. It is a powerful tool that comes with its own programming language and its huge online community support. It also offers the possibility to export its historical short-term and long-term FX data.

The first thing we need to do is to simply download the platform from the official website. Then, after creating the demo account, we are ready to import the library in Python that allows to import the OHLC data from MetaTrader5.

A library is a group of structured functions that can be imported into our Python interpreter from where we can call and use the ones we want.

The easiest way to install the MetaTrader5 library is to go to the Python prompt on our computer and type:



Sofien Kaabar, CFA

Top writer in Finance, Investing, Business | Trader & Author