OPEN-SOURCE SCRIPT

Ranging Market Detector [AstrideUnicorn]

Determining if the market is in a trend or a range regime is a very complex problem. And knowing the answer can be, in some situations, the real holy grail. If the trader knows when the market is in a range regime, they can avoid overtrading and make moving average crossover strategies more profitable. A regime switch from a trend to a range can be a signal to close open positions. It can also be helpful when trading such instruments as short-term binary options. When the market is ranging directional moves are not expected, and the trader should be careful as opening a position in such conditions is, by some degree, a random outcome game. Range breakouts trading is one more example when knowing the market regime is critical.

We have created an indicator that predicts the current market regime. It smooths the price using the Kalman filter and analyzes the curve's slope. If the absolute value of the slope is low, then the market is in range mode and vice versa. To distinguish between the two regimes, the algorithm compares the absolute value of the slope with its long-term average.

HOW TO USE
The indicator shows the difference between the absolute slope value and its long-term average as a histogram. When a bar of the histogram is higher than the threshold level presented by the red line, the market is in a trending regime. In this regime, the background of the indicator is blue. When the market is in a range regime, the indicator background turns red.
The threshold level helps to control the lag. The greater it is, the more lagging the indicator will be. By default, this value is set to a negative value. It means that the indicator switches from range to trend a little bit earlier than the slope gets higher than the average slope. You can use the value of zero or low negative values to find the optimal tradeoff between the strength of the signals and their lag.

SETTINGS
The indicator has one input parameter called Threshold. It sets the threshold level described above. Its value should be close to zero. The less the value is, the less is the indicator's lag, but at the same time, the less confirmed the regime-switching signals are.

The use cases can be very different. And as the code is open, you can also use the indicator as a building block for your custom trading strategies.
Let us know your thoughts and suggestions!
Breadth IndicatorsTrend AnalysisVolatility

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


Our premium trading indicators: unicorn.trading

Join our Discord community: dsc.gg/unicom
Aussi sur:

Clause de non-responsabilité