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!
Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.