OPEN-SOURCE SCRIPT

[blackcat] L2 Ehlers Hilbert Channel Breakout Trading System

Level: 2

Background

John F. Ehlers introuced Hilbert Channel Breakout Trading System in Nov, 2000.

Function

This indicator will show how the adaptive filter is being applied to a trading strategy. After the Hilbert Channel Breakout Signal is optimized, set the inputs for this indicator to match the corresponding inputs for the signal.

In the March 2000 STOCKS & COMMODITIES, John Ehlers published a algorithm for the Hilbert cycle period, an indicator that plots the length of the current market cycle. The Hilbert transform achieved computational efficiency by using a two-dimensional numbering system. Unfortunately, this introduces amplitude error in calculating the quadrature component. Dr. Ehlers compensated for this error. He have updated the method of compensating for the amplitude error by applying a straight-line compensation term using the frequency calculation from one bar ago. This is possible because the cycle period cannot change drastically from bar to bar. The slowly varying cycle period is adequate to do a good job of amplitude compensation.

In addition, Dr. Ehlers have used a different way to compute the cycle period. He used a homodyne discriminator because it exhibits superior performance in a low signal-to-noise environment. Homodyne means he used the signal multiplied by itself one bar ago to produce a zero-frequency beat note. This beat note carries the phase angle of the one-bar change. Still using the basic definition of a cycle, the one-bar rate of change of phase is exactly the cycle period.

Here is the pine v4 code to generate the signals in the Hilbert channel breakout trading system, as discussed in Dr. Ehlers article in this issue, "Optimizing With Hilbert Indicators." The signal itself is a simple channel breakout system that generates buy and exit signals, that shows whether the system is long or flat; the high of the bar and the value of the entry channel; and the low of the bar and the value of the exit channel. This helps you see on a bar-by-bar basis exactly how the system is behaving.

Key Signal

longcond--> when high breakouts EntryChannel to long
shortcond--> when low breakouts ExitChannel to short

Pros and Cons

100% John F. Ehlers definition translation, even variable names are the same. This help readers who would like to use pine to read his book.

Remarks

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

I tested it and believe it work better in small time frame e.g. 15m than large time frames.

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.
breakouttradingehlershilberttransformjohnehlersTrend Analysis

สคริปต์โอเพนซอร์ซ

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

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


Avoid losing contact!Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq 防止失联,请立即行动,加入本猫聊天群: discord.com/invite/ZTGpQJq
และใน:

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