AstrideUnicorn

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!

Our premium trading indicators: unicorn.trading

Join our Discord community: dsc.gg/unicom
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?