Ratchet Flip SuperTrend
- Indicateurs
- Version: 1.0
- Activations: 5
Ratchet Flip SuperTrend is a SuperTrend-style trend indicator for MetaTrader 5, written from scratch. It draws an ATR-based trailing line that only moves in the trend direction. The line is blue while the trend is up and orange-red while it is down. Buy and sell arrows mark the bars where the trend flips. Arrows and alerts are created only after a bar has closed. They are never placed on the forming bar and do not move or disappear later.
How it works
- ATR (Wilder smoothing) around the median price, the close or the typical price, with a multiplier (default 10 and 3.0).
- The lower band can only rise while the trend is up, and the upper band can only fall while it is down. The trend flips when a bar closes beyond the opposite band.
- The line on the forming bar is drawn for information (this can be switched off). It can still change until the bar closes, as on any chart.
Optional filters to reduce whipsaws
- Higher-timeframe confirmation: a flip is signalled only when the same calculation on a higher timeframe (H4 by default) points the same way. The indicator uses the last higher-timeframe bar that closed before the chart bar opened, so the filter cannot repaint.
- Volatility filter: skip flips when ATR is below a set fraction of its average (quiet, choppy markets). Optionally require the close to be a minimum distance (in ATR) beyond the old line.
Filtered flips still change the line color but do not get an arrow or an alert.
Alerts
- Popup, sound (standard terminal sounds), push notification and e-mail, each on or off.
- One alert per signal, on the first tick after the signal bar closes. No alerts are sent for old bars when the indicator loads or the timeframe changes.
For Expert Advisors (iCustom)
All 20 inputs are numbers or switches, in a fixed order, so they can be passed directly to iCustom. Buffers: 0 line, 1 color index, 2 buy arrow, 3 sell arrow, 4 trend (+1/-1), 5 signal (+1 buy, -1 sell, 0 none; closed bars only), 6 upper band, 7 lower band, 8 ATR, 9 higher-timeframe trend. Read signals at shift 1 (the last closed bar). Parameter order: ATR period, multiplier, price (0 median, 1 close, 2 typical), use HTF, HTF timeframe, HTF ATR period, HTF multiplier, use volatility filter, ATR average period, minimum ATR ratio, minimum break x ATR, draw forming bar, arrow gap, buy arrow code, sell arrow code, popup, sound, sound choice (0-4), push, e-mail. Fewer parameters may be passed; the rest keep their defaults.
Efficiency
After the first calculation, only the last bar and new bars are recalculated. The higher-timeframe series is recalculated only when a new higher-timeframe bar appears. No DLLs and no external files.
Testing performed (version 1.00)
It compiles with no errors or warnings. In the Strategy Tester it ran without journal errors on EURUSD (M1, H1), GBPUSD (M30), XAUUSD (H1, D1) and USDJPY (H1), in visual and non-visual mode, with and without the filters. A test EA recorded the closed-bar values bar by bar during each test. It compared them with a fresh calculation over the full history: 0 differences in 8 runs (more than 70,000 bars per setting). The number of alerts always equalled the number of signal bars. Push, e-mail and sound alerts cannot be tested in the Strategy Tester.
Notes
This is an analysis tool. It does not open trades, and it does not predict prices. Trend-following signals often give losing or late signals in ranging markets. Past signals do not guarantee future results. Use your own risk management, and try it on a demo account first.
supertrend, trend indicator, ATR trailing line, non repainting, buy sell arrows, multi timeframe filter, volatility filter, alerts, push notification, iCustom buffers, trend following, MT5 indicator
How it works
- ATR (Wilder smoothing) around the median price, the close or the typical price, with a multiplier (default 10 and 3.0).
- The lower band can only rise while the trend is up, and the upper band can only fall while it is down. The trend flips when a bar closes beyond the opposite band.
- The line on the forming bar is drawn for information (this can be switched off). It can still change until the bar closes, as on any chart.
Optional filters to reduce whipsaws
- Higher-timeframe confirmation: a flip is signalled only when the same calculation on a higher timeframe (H4 by default) points the same way. The indicator uses the last higher-timeframe bar that closed before the chart bar opened, so the filter cannot repaint.
- Volatility filter: skip flips when ATR is below a set fraction of its average (quiet, choppy markets). Optionally require the close to be a minimum distance (in ATR) beyond the old line.
Filtered flips still change the line color but do not get an arrow or an alert.
Alerts
- Popup, sound (standard terminal sounds), push notification and e-mail, each on or off.
- One alert per signal, on the first tick after the signal bar closes. No alerts are sent for old bars when the indicator loads or the timeframe changes.
For Expert Advisors (iCustom)
All 20 inputs are numbers or switches, in a fixed order, so they can be passed directly to iCustom. Buffers: 0 line, 1 color index, 2 buy arrow, 3 sell arrow, 4 trend (+1/-1), 5 signal (+1 buy, -1 sell, 0 none; closed bars only), 6 upper band, 7 lower band, 8 ATR, 9 higher-timeframe trend. Read signals at shift 1 (the last closed bar). Parameter order: ATR period, multiplier, price (0 median, 1 close, 2 typical), use HTF, HTF timeframe, HTF ATR period, HTF multiplier, use volatility filter, ATR average period, minimum ATR ratio, minimum break x ATR, draw forming bar, arrow gap, buy arrow code, sell arrow code, popup, sound, sound choice (0-4), push, e-mail. Fewer parameters may be passed; the rest keep their defaults.
Efficiency
After the first calculation, only the last bar and new bars are recalculated. The higher-timeframe series is recalculated only when a new higher-timeframe bar appears. No DLLs and no external files.
Testing performed (version 1.00)
It compiles with no errors or warnings. In the Strategy Tester it ran without journal errors on EURUSD (M1, H1), GBPUSD (M30), XAUUSD (H1, D1) and USDJPY (H1), in visual and non-visual mode, with and without the filters. A test EA recorded the closed-bar values bar by bar during each test. It compared them with a fresh calculation over the full history: 0 differences in 8 runs (more than 70,000 bars per setting). The number of alerts always equalled the number of signal bars. Push, e-mail and sound alerts cannot be tested in the Strategy Tester.
Notes
This is an analysis tool. It does not open trades, and it does not predict prices. Trend-following signals often give losing or late signals in ranging markets. Past signals do not guarantee future results. Use your own risk management, and try it on a demo account first.
supertrend, trend indicator, ATR trailing line, non repainting, buy sell arrows, multi timeframe filter, volatility filter, alerts, push notification, iCustom buffers, trend following, MT5 indicator
