Regime Filter

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Regime Filter

Postby Steve_W » Sun Apr 27, 2025 1:27 pm

Developed from original source here:
https://www.tradingview.com/script/ia5ozyMF-MLExtensions/
by https://www.tradingview.com/u/jdehorty/

This indicator aims to detect trending or ranging markets.
There is no exact explanation of the mechanics, but comments are added in the code below by interpretation.
First, an adaptive smoothing constant is generated based on average price slope and volatility
The constant looks like a solution of a quadratic equation and scaled to be between 0 and 1 for use in EMA KAMA filter or price.
The output KAMA slope is compared to averaged KAMA slope to select regime
Defaults are based on original authors values and code corrected for a minor error and numerical protections added for edge cases.

The indicator is aimed at algorithmic trading, and was specifically used on Lorentzian kNN Classification algorithm as an optional trade filter. ADX indicator could be an alternative.
Options are available to show raw signal, or a threshold toggled indication - see screenshot.

The code has also been optimised and improved using Grok3 - this is worthwhile if new to LUA programming, and generally improves coding standard.

EURUSD D1 (04-27-2025 1855).png
EURUSD D1

regime.lua
regime.lua
(7.21 KiB) Downloaded 158 times
Steve_W
 
Posts: 18
Joined: Fri Jul 28, 2017 4:44 am

Re: Regime Filter

Postby Avignon » Thu May 01, 2025 7:18 am

Steve_W wrote:
The code has also been optimised and improved using Grok3 - this is worthwhile if new to LUA programming, and generally improves coding standard.



You're shooting yourself in the foot by saying that! :lol: ;)
Avignon
FXCodeBase: Graduate
 
Posts: 289
Joined: Mon Nov 17, 2014 3:54 am


Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 8 guests

cron