アップデート済

[blackcat] L2 Ehlers ITrendline Trigger Trend-Following System

7 942
Level: 2

Background

John F. Ehlers introuced the Instantaneous Trendline and the Trigger of the trend-following system in his "Cybernetic Analysis for Stocks and Futures" chapter 3 on 2004.


Function

The process for creating a trendfollowing trading system from the indicators is simple. One unique aspect of the code is that the ITrend is forced to be a finite impulse response (FIR)-smoothed version of price for the first seven bars of the calculation.
This initialization is included to cause the ITrend to converge more rapidly to its correct value from the beginning transient. The strategy enters a long position when the trigger crosses over the Instantaneous Trendline and enters a short position when the trigger crosses under the Instantaneous Trendline. However, an effective trading system is more than following a simple set of indicators.
First, experience has shown that greater profits result from using limit orders rather than market orders or stop orders. Market orders are selfexplanatory. Stop orders mean the market must be going in the direction of the trade before the order is filled. For example, for long-position trades, the stop order must be placed above the current price. Thus, the price must increase from its current level before you get stopped into the long-position trade. This means you necessarily give up some of the profits you would otherwise have gotten if you had entered on a market order at the instant of your signal. You can lose additional profits from stop orders due to slippage.

Key Signal

Trigger ---> trend-following system fast line
ITrend ---> trend-following system slow line

Pros and Cons

100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.

Remarks

The 22th script for Blackcat1402 John F. Ehlers Week publication.

Readme

In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.

The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.

Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.

Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.

Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.

Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.

Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
リリースノート
Correct BS label display bug as found by gerardgervais
thanks for your kind reminding! :D
リリースノート
Make label size adjustable
リリースノート
OVERVIEW

This indicator implements the Ehlers ITrendline and Trigger Trend-Following System, providing visual signals for potential buy and sell opportunities based on trend-following principles.

FEATURES

• Calculates Ehlers ITrend and Trigger lines using customizable parameters
• Displays dynamic fill areas between ITrend and Trigger lines
• Generates BUY/SELL labels at crossover points
• Customizable label sizes for better visibility
• Adjustable source price and alpha value parameters

HOW TO USE

Select the desired price source from the inputs
Adjust the alpha value to control sensitivity
Choose label size preference from available options
Monitor crossover points between ITrend and Trigger lines
Look for BUY labels when Trigger crosses above ITrend
Watch for SELL labels when Trigger crosses below ITrend

INPUT PARAMETERS

• Source: Price data used for calculations (default: HL2)
• Alpha: Sensitivity parameter (default: 0.07)
• Label Size: Controls the visibility of BUY/SELL labels

LIMITATIONS

• Past performance does not guarantee future results
• Indicator should be used in conjunction with other analysis tools
• Results may vary depending on market conditions and parameter settings

NOTES

• The indicator uses Ehlers' proprietary algorithm for trend calculation
• Fill colors change based on the relationship between ITrend and Trigger lines
• Labels are positioned near price action for better visibility
リリースノート
█ OVERVIEW

This open-source indicator turns John Ehlers' low-lag ITrend filter into a complete trend-following system with bidirectional BUY/SELL signals, volatility-adaptive risk levels, and confirmed non-repainting alerts. This V2 release adds signal governance, structured exits, and an on-chart status dashboard on top of the original cross system.

█ CONCEPTS

The script is built around the Ehlers ITrend equation family:

 • ITrend Filter: a zero-lag trend estimate computed from the selected price source with an adjustable smoothing factor (alpha)
 • Trigger Line: a projection of the ITrend value, used as the fast signal line against the slower ITrend
 • Cross System: BUY when the Trigger crosses above the ITrend, SELL when it crosses below - the classic Ehlers pair
 • Signal Governance: a position state machine, same-bar entry/exit exclusivity, and an adjustable cooldown window suppress whipsaw re-firing in choppy markets
 • Volatility-Adaptive Risk: stop-loss and take-profit reference levels derived from ATR multiples of the entry price

█ HOW TO USE

1 - Add the indicator to an overlay chart; the yellow Trigger and fuchsia ITrend lines appear immediately
2 - Tune Alpha (default 0.07) for your timeframe: lower values smooth more, higher values react faster
3 - Read signals from the chart labels and manage trades with the plotted Stop Loss / Take Profit lines

Input Parameters
 • Source: price input for the filter (default hl2)
 • Alpha: ITrend smoothing factor, 0.01-1.00 (default 0.07)
 • Enable Long Signals / Enable Short Signals: turn each direction on or off independently
 • Same-bar Entry/Exit Exclusivity: prevents an exit and an entry from both printing on one bar
 • Cooldown Bars: minimum bars between any two signals (default 3, 0 disables)
 • Show TP/SL Levels: toggle the ATR-based risk lines
 • ATR Length: averaging period for volatility (default 14)
 • Stop Loss (xATR) / Take Profit (xATR): risk multiples from entry price (defaults 2.0 / 3.0)
 • Label Size: chart label text size
 • Show Position Background / Show Dashboard: visual toggles

█ FEATURES

 • Bidirectional signals: BUY (green) and SELL (red) labels at bar crosses
 • Managed exits: orange cross labels show XL / XS with the exit reason (TP hit, SL hit, or Reversal)
 • ATR-based Stop Loss and Take Profit lines drawn from the entry price
 • Position background tint: light green while long, light red while short
 • Status dashboard: trend direction, current position, entry price, and ATR at a glance
 • Four alert conditions plus dynamic alert() messages, all confirmed on bar close - no repainting

█ SIGNALS

Visual Elements
 • BUY label (green, below bar): Trigger crossed above ITrend - potential long entry
 • SELL label (red, above bar): Trigger crossed below ITrend - potential short entry
 • XL cross (orange): long position closed (take-profit, stop-loss, or opposite signal)
 • XS cross (orange): short position closed (take-profit, stop-loss, or opposite signal)
 • Yellow/fuchsia fill: fills yellow while Trigger is above ITrend (up-trend phase), fuchsia otherwise
 • Red / teal step lines: current stop-loss and take-profit reference levels
 • Position State (data window): +1 long, -1 short, 0 flat

█ IMPLEMENTATION NOTES

Open-source implementation using ta.crossover, ta.crossunder, and ta.atr. The Ehlers recursion is warmed up with a simple average for the first bars and history references are protected with nz():

Pine Script®


Signals are edge-triggered crossings evaluated on confirmed bars; the state machine allows at most one position change per bar, and all alert() calls use alert.freq_once_per_bar_close, so alerts never repaint.

█ LIMITATIONS

 • Trend-following by design: expect whipsaw losses in prolonged ranging markets, although the cooldown filter reduces signal churn
 • Stop-loss and take-profit exits are evaluated on bar close, so intra-bar spikes beyond a level are captured on that bar's close rather than tick-by-tick
 • Default parameters (alpha 0.07, ATR 14, 2.0/3.0 multiples) are starting points; re-tune per symbol and timeframe
 • This is an analytical tool, not financial advice

█ NOTES

 • The ITrend and Trigger calculations follow John F. Ehlers' work on instantaneous trend filtering (Cybernetic Analysis for Stocks and Futures)
 • Released under the Mozilla Public License 2.0 - free to use and modify, attribution appreciated
 • V2 hardening versus V1: typed inputs with groups, signal governance, ATR risk management, alert suite, dashboard, and style-guide cleanup

════════════════════════════════════════════════════════════════════════
For questions or feedback, please use the comments section below.
Feel free to use and modify - attribution appreciated.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。