Breakout ahead? How to detect trendless Market Phases and colour the chart background

Markets do not always trend – very often you can spot a sideways or congestion area on the chart. This short article will show you how you can create a simple visual indicator which highlights such trendless market phases using the famous trend strength indicator called ADX. A breakout out of this zone could be a good opportunity for a trade. When it comes to coding, this is a good example of how to use multiple “if .. then .. else..” statements.

How can we define a trendless market phase?

The rules are pretty simple: When the market is below a specific ADX threshold, then the market is trendless and we want to display Bollinger Bands on the charts or an n-bar high low channel or colour the background of the chart. Here`s an example of the indicator will look like: In the upper subchart you can see the Bollinger Bands when the market is trendless, while the lower subchart draws a 20-bar-high-low channel.

 Using-ADX- indicator-for-detecting-trendless-market-phases

And here`s how to code it in less than 20 lines using built-in functions and if-then statements.

Let`s code it!

  • In line 4, please notice the variable called flags which will be used for colouring the background of the chart
  • The variables for the upper and lower band of the Bollinger indicator are declared in line 7 and 8
  • In line 10, the built-in function for the ADX is used in the if-then-statement
    • If the ADX is lower than the value set in the input section, then either the Bollinger Bands or the high-low-channel or the coloured background is drawn.
    • The input “style” (line 3) acts as a switch here.
  • Line 17 and 18 are responsible for the high-low-channel. For this purpose, we use the highest high value (hhv) and lowest low value (llv) function
    • If you would like to use a flexible value instead of 20 bars, you can add an input and then replace 20 with the input
  • In line 22 you can see the command for colouring the background using the flags variable from line 4



Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited. Data by Thomson Reuters Eikon.

2 thoughts on “Breakout ahead? How to detect trendless Market Phases and colour the chart background

  1. Guten Tag,

    ich habe probiert die Technik anzuwenden, welches mir nicht komplett gelingt. Über eine Unterstützung diesbezüglich würde ich mich sehr freuen.

    Vielen Dank

    Mit freundlichem Gruß

    Ingo Hartmann

  2. Um den Chart wie am Screenshot zu konstruieren gehen Sie wie folgt vor:

    Öffnen Sie einen EUR= Chart (Reuters)
    Fügen Sie zu diesem Chart 2 * den EUR= hinzu. (Symbol hinzufügen)
    Ziehen Sie den Indikator auf alle 3 Charts.
    Ändern Sie die Einstellungen für Style auf “BB” im ersten Chart, auf “HL” im zweiten Chart und auf “Bollingerband” im Dritten.

    Hoffe es funktioniert,

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to this Blog