Re: TradingView Indicators to MT5 Indicators

781
Eis wrote: Sat Jul 25, 2026 2:45 pm seemed pretty basic hi lo stuff after conversion so added tdfi filter which was great! only until it stopped working on different timeframes if anybody can find the time to fix this that would be cool thx
This version was created entirely using AI.
Check if it still meets your desired outcome.

Below is the changelog (generated by AI) detailing the changes made to the original SSSSSS.mq5 code, followed by the AI-generated version.

Change log:
# RMI Trend Sniper (TDFI Edition) — Changelog

**Version 1.25 — 2026-07-25**

Three bugs fixed related to the TDFI filter and the custom-timeframe ("Calculation Timeframe") feature. If you're only running the indicator on your chart's native timeframe and never touched the TDFI settings, the practical effect is: signals are more consistent, and the trend color no longer glitches when you switch timeframes.

### 1. TDFI filter didn't scale across timeframes or symbols

The TDFI momentum filter used to compare the average price move over a few bars against a fixed number. That worked fine on whatever chart it happened to be tuned on, but broke almost everywhere else — on some timeframes it blocked nearly every signal, on others it let almost everything through, because typical bar-to-bar price movement is a completely different size on M1 than on H4.

It now compares today's "force" against the indicator's own recent average force, so the threshold means the same thing regardless of timeframe or instrument.

### 2. Custom-timeframe mode was quietly mixing timeframes

If you set "Calculation Timeframe" to something other than your chart's own period, part of the indicator (the momentum/RSI-style component and the TDFI filter) was still silently reading price data from your chart's timeframe instead of the one you selected, while the rest of the indicator correctly used your selection. Everything now reads from the same, selected calculation timeframe.

### 3. Trend color could flip incorrectly right after switching chart timeframe

Switching your chart's timeframe forces the indicator to fully recalculate, and it was only looking back about 72 bars to figure out the current trend color. If the trend had been running longer than that without a fresh signal, or a small noisy blip sat in that recent window, the color could briefly show the wrong side right after the switch — even though nothing about the actual trend had changed. It now looks back through the full available history on a fresh load, so the color you see matches what it would have shown all along.

---

### If you customized the TDFI settings

- **TDFI Level default changed from 0.05 to 0.3**, and its meaning changed: it's no longer a raw price threshold, it's now "how many times the recent average force" is required to count as a signal. If you'd tuned this input yourself, you'll want to re-tune it — the old value won't mean the same thing anymore.
- **New setting: TDFI Normalization Window (default 50 bars)** — controls how far back the filter looks to judge what "average force" is. Shorter = more reactive, longer = smoother/slower to adapt.

All other settings are unchanged.
These users thanked the author Pelle for the post:
Eis

Re: TradingView Indicators to MT5 Indicators

782
Pelle wrote: Sun Jul 26, 2026 3:42 am This version was created entirely using AI.
Check if it still meets your desired outcome.

Below is the changelog (generated by AI) detailing the changes made to the original SSSSSS.mq5 code, followed by the AI-generated version.

Change log:
# RMI Trend Sniper (TDFI Edition) — Changelog

**Version 1.25 — 2026-07-25**

Three bugs fixed related to the TDFI filter and the custom-timeframe ("Calculation Timeframe") feature. If you're only running the indicator on your chart's native timeframe and never touched the TDFI settings, the practical effect is: signals are more consistent, and the trend color no longer glitches when you switch timeframes.

### 1. TDFI filter didn't scale across timeframes or symbols

The TDFI momentum filter used to compare the average price move over a few bars against a fixed number. That worked fine on whatever chart it happened to be tuned on, but broke almost everywhere else — on some timeframes it blocked nearly every signal, on others it let almost everything through, because typical bar-to-bar price movement is a completely different size on M1 than on H4.

It now compares today's "force" against the indicator's own recent average force, so the threshold means the same thing regardless of timeframe or instrument.

### 2. Custom-timeframe mode was quietly mixing timeframes

If you set "Calculation Timeframe" to something other than your chart's own period, part of the indicator (the momentum/RSI-style component and the TDFI filter) was still silently reading price data from your chart's timeframe instead of the one you selected, while the rest of the indicator correctly used your selection. Everything now reads from the same, selected calculation timeframe.

### 3. Trend color could flip incorrectly right after switching chart timeframe

Switching your chart's timeframe forces the indicator to fully recalculate, and it was only looking back about 72 bars to figure out the current trend color. If the trend had been running longer than that without a fresh signal, or a small noisy blip sat in that recent window, the color could briefly show the wrong side right after the switch — even though nothing about the actual trend had changed. It now looks back through the full available history on a fresh load, so the color you see matches what it would have shown all along.

---

### If you customized the TDFI settings

- **TDFI Level default changed from 0.05 to 0.3**, and its meaning changed: it's no longer a raw price threshold, it's now "how many times the recent average force" is required to count as a signal. If you'd tuned this input yourself, you'll want to re-tune it — the old value won't mean the same thing anymore.
- **New setting: TDFI Normalization Window (default 50 bars)** — controls how far back the filter looks to judge what "average force" is. Shorter = more reactive, longer = smoother/slower to adapt.

All other settings are unchanged.

EDIT

Added arrows and alerts.

Re: TradingView Indicators to MT4 Indicators

786
Machine Learning Super Trend 2025

Code: Select all

//@version=5
indicator("Machine Learning Supertrend", overlay = true, timeframe = "", timeframe_gaps = true)

// Parameters
atrPeriod = input.int(25, "ATR Length", minval = 1)
factor = input.float(2.2, "Factor", minval = 0.01, step = 0.01)
sigma = 0.03
forecast = input.int(3, "Forecast Period", minval = 0)  // Number of bars to forecast

// Source
src = input.source(close, 'Source')

// Kernel Function (Gaussian Process Regression)
rbf(x1, x2, l) => math.exp(-math.pow(x1 - x2, 2) / (2.0 * math.pow(l, 2)))

kernel_matrix(X1, X2, l) =>
    km = matrix.new<float>(X1.size(), X2.size())
    for i = 0 to X1.size() - 1
        for j = 0 to X2.size() - 1
            km.set(i, j, rbf(X1.get(i), X2.get(j), l))
    km

// Initialize Gaussian Process Regression
var identity = matrix.new<int>(atrPeriod, atrPeriod, 0)
var array<float> K_row = na

if barstate.isfirst
    xtrain = array.new<int>(0)
    xtest = array.new<int>(0)

    // Training data setup
    for i = 0 to atrPeriod-1
        for j = 0 to atrPeriod-1
            identity.set(i, j, i == j ? 1 : 0)
        xtrain.push(i)

    // Test data (future prediction)
    for i = 0 to atrPeriod-1 + forecast
        xtest.push(i)

    // Compute kernel matrices
    s = identity.mult(sigma * sigma)
    Ktrain = kernel_matrix(xtrain, xtrain, atrPeriod).sum(s)
    K_inv = Ktrain.pinv()
    K_star = kernel_matrix(xtrain, xtest, atrPeriod)
    K_row := K_star.transpose().mult(K_inv).row(atrPeriod-1 + forecast)

// Machine Learning Moving Average
var float prev_supertrend = na
mean = ta.sma(src, atrPeriod)

// ML Prediction with Forecast
float out = na
if bar_index > atrPeriod
    dotprod = 0.
    for i = 0 to atrPeriod-1
        dotprod += K_row.get(i) * (src[atrPeriod-1 - i] - mean)
    out := dotprod + mean

// Use forecasted value
predicted_value = out[forecast]

// ML-based ATR estimation
mae = ta.sma(math.abs(src - predicted_value), atrPeriod) * factor
upper = predicted_value + mae
lower = predicted_value - mae

// Supertrend Calculation
float supertrend = na

if prev_supertrend == na
    supertrend := close > lower ? lower : upper
else
    supertrend := close > prev_supertrend ? lower : upper

// Ensure the trend follows the previous one if not broken
supertrend := na(supertrend) ? prev_supertrend : supertrend
prev_supertrend := supertrend

// Detect trend direction (1 = bullish, 0 = bearish)
trend_direction = supertrend == lower ? 1 : 0

// Plot Up & Down Trend Lines
upTrend = plot(trend_direction == 1 ? supertrend : na, "Up Trend", color = color.green, style = plot.style_linebr)
downTrend = plot(trend_direction == 0 ? supertrend : na, "Down Trend", color = color.red, style = plot.style_linebr)

// Middle of the candle (used for filling)
bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle", display = display.none)

// Fill areas
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps = false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps = false)

// Alerts for trend change
alertcondition(trend_direction != trend_direction[1], title='Trend Change', message='Supertrend ML changed direction')

“The Money Is Coming”

Re: TradingView Indicators to MT4 Indicators

787
Eis wrote: Thu Aug 06, 2026 7:41 am Machine Learning Super Trend 2025

Code: Select all

//@version=5
indicator("Machine Learning Supertrend", overlay = true, timeframe = "", timeframe_gaps = true)

// Parameters
atrPeriod = input.int(25, "ATR Length", minval = 1)
factor = input.float(2.2, "Factor", minval = 0.01, step = 0.01)
sigma = 0.03
forecast = input.int(3, "Forecast Period", minval = 0)  // Number of bars to forecast

// Source
src = input.source(close, 'Source')

// Kernel Function (Gaussian Process Regression)
rbf(x1, x2, l) => math.exp(-math.pow(x1 - x2, 2) / (2.0 * math.pow(l, 2)))

kernel_matrix(X1, X2, l) =>
    km = matrix.new<float>(X1.size(), X2.size())
    for i = 0 to X1.size() - 1
        for j = 0 to X2.size() - 1
            km.set(i, j, rbf(X1.get(i), X2.get(j), l))
    km

// Initialize Gaussian Process Regression
var identity = matrix.new<int>(atrPeriod, atrPeriod, 0)
var array<float> K_row = na

if barstate.isfirst
    xtrain = array.new<int>(0)
    xtest = array.new<int>(0)

    // Training data setup
    for i = 0 to atrPeriod-1
        for j = 0 to atrPeriod-1
            identity.set(i, j, i == j ? 1 : 0)
        xtrain.push(i)

    // Test data (future prediction)
    for i = 0 to atrPeriod-1 + forecast
        xtest.push(i)

    // Compute kernel matrices
    s = identity.mult(sigma * sigma)
    Ktrain = kernel_matrix(xtrain, xtrain, atrPeriod).sum(s)
    K_inv = Ktrain.pinv()
    K_star = kernel_matrix(xtrain, xtest, atrPeriod)
    K_row := K_star.transpose().mult(K_inv).row(atrPeriod-1 + forecast)

// Machine Learning Moving Average
var float prev_supertrend = na
mean = ta.sma(src, atrPeriod)

// ML Prediction with Forecast
float out = na
if bar_index > atrPeriod
    dotprod = 0.
    for i = 0 to atrPeriod-1
        dotprod += K_row.get(i) * (src[atrPeriod-1 - i] - mean)
    out := dotprod + mean

// Use forecasted value
predicted_value = out[forecast]

// ML-based ATR estimation
mae = ta.sma(math.abs(src - predicted_value), atrPeriod) * factor
upper = predicted_value + mae
lower = predicted_value - mae

// Supertrend Calculation
float supertrend = na

if prev_supertrend == na
    supertrend := close > lower ? lower : upper
else
    supertrend := close > prev_supertrend ? lower : upper

// Ensure the trend follows the previous one if not broken
supertrend := na(supertrend) ? prev_supertrend : supertrend
prev_supertrend := supertrend

// Detect trend direction (1 = bullish, 0 = bearish)
trend_direction = supertrend == lower ? 1 : 0

// Plot Up & Down Trend Lines
upTrend = plot(trend_direction == 1 ? supertrend : na, "Up Trend", color = color.green, style = plot.style_linebr)
downTrend = plot(trend_direction == 0 ? supertrend : na, "Down Trend", color = color.red, style = plot.style_linebr)

// Middle of the candle (used for filling)
bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle", display = display.none)

// Fill areas
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps = false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps = false)

// Alerts for trend change
alertcondition(trend_direction != trend_direction[1], title='Trend Change', message='Supertrend ML changed direction')

MT5 Version enjoy
These users thanked the author cladi53 for the post (total 3):
Eis, ashdays, Wole