SMA Directional Matrix

This script was created in collaboration with alexgrover and displays a simple & elegant panel showing the direction of simple moving averages with periods in a user-selected range (Min, Max). The displayed number in the panel is the period of a simple moving average and the symbol situated at the right of it is associated with the direction this moving average is taking.


  • Min: Minimum period of the moving average
  • Max: Maximum period of the moving average
  • Src: Source input of the moving averages
  • Number Of Columns: Number of columns to be displayed in the panel, handy when using a large range of periods.


Looking at the direction of moving averages with different periods is extremely useful when it comes to having information about the short/mid/long term overall market sentiment, and can also tell us if the market is trending or ranging.

Here we use periods ranging from 25 to 50, we can see that shorter moving averages react to the recent upward price variation, longer-term moving averages however are still affected by the overall downward variation you can see on the image. We can as such get information about the presence of potentials divergences, with shorter-term moving averages reacting to the divergence while the longer-term moving averages will still display the direction of the main trend.

As such the indicator can give information about how clean a trend is, with a clean trend being defined as a variation containing no retracements. When our trend contains no retracement, the mid/long term moving averages will all have the same direction, however, when a retracement is present, the midterm moving averages might be affected by it, thus displaying a direction contrary to the main trend.

When the market is ranging we can expect the panel to display an equal number of decreasing/increasing moving averages.

Possible Issues

When using a large range of periods, you might have an error message showing: "String is too long", try lowering the range of periods by increasing Min or decreasing Max.

If the script displays the error message "Loop is too long to execute", try resetting the settings and change them back to the one you wanted to use.
Notes de version: Added a transparent background option for the panel and unscaled it, thus being less intrusive for the user.
Supprimer des scripts favoris Ajouter aux scripts favoris
Our Website to get access to our invite-only scripts:

Resources page + FAQ:


Nice!... any chance of having a similar one but showing the Lux Algo signal on multiple time frames?
+5 Répondre
Great stuff! :)
+5 Répondre
+4 Répondre
LuxAlgo MalikG90
@MalikG90, ❤️
+2 Répondre
great work
+3 Répondre
LuxAlgo sherifmamdouh999
@sherifmamdouh999, Thank you! Glad you enjoy.
+1 Répondre
This publication is now featured in our Editors' Picks. In the name of all TradingView traders, thank you for your valuable contribution to the TradingView community, and congrats!
+2 Répondre
LuxAlgo PineCoders
@PineCoders, <3 Thank you for the feature!
+1 Répondre
longdt LuxAlgo
@LuxAlgo, How to create an alert when all labels are green or red? thanks sir
+1 Répondre
@LuxAlgo well done! btw, how did you input the nice up/down trend icons in to pine script? it looks pretty good.
+1 Répondre
Accueil Screener d'actions Screener Forex Screener Crypto Calendrier économique Comment ça marche Caractéristiques du graphique Prix Parrainer un ami Règles de conduite Centre d'aide Solutions site web & courtier Widgets Solutions de cartographie Bibliothèque de graphiques allégés Blog & News Twitter
Profil Paramètres du Profil Compte et Facturation Amis référés Coins Mes tickets au support Centre d'aide Idées Publiées Followers Suivi(e) Messages privés Chat Se Déconnecter