OPEN-SOURCE SCRIPT

MA Difference

업데이트됨
The MA Difference indicator shows 3 histograms representing differences in moving averages between a base MA (10) and 3 MA's: short (20), medium (50), and long (200). It also shows an exponentially weighted trend line which can indicate breakout opportunities, has alerts on all base <-> X crossovers, and shows potential consolidation zones where MA differences are below a user-defined tolerance.

The suggested way to use this indicator is to place a trade when the trend line is above the histogram (and filling the space between them). This indicates that the current MA values are significantly above or below the expected range and that prices are in the midst of breaking out. You may also consult the consolidation zones to eliminate false breakouts and momentary changes in trend. You may also consult the various short, medium, and long crossovers and crossunders to time entries and exits accordingly.

Histograms

The 3 histograms represent the differences between:

  • Base MA (10) and Short MA (20)
  • Base MA (10) and Medium MA (50)
  • Base MA (10) and Long MA (200)


All 4 moving average values can be configured in the indicator's settings. Consistency in direction and color of the histogram indicates a consistent trend across the various moving averages.

Trend Line

The trend line is an exponentially weighted average of the 3 moving averages, scaled by a factor configurable in the settings. When using the trend line, shading will be applied to the difference between the extremes of the histogram and the trend line to indicate that the chart is in a "breakout zone" and is beyond the normal, gradual sway of price action.

Crossovers/Crossunders

You may optionally turn on crossovers and crossunders in the indicator's settings to display when a short, medium, or long crossover occurs against the base moving average. Likewise, alerts are available for each crossover and crossunder for each of the 3 moving average convergences.

Consolidation Zones

Consolidation zones, as well as a line representing the current amount of consolidation, can also be optionally drawn on the chart. These indicate when a security is likely in consolidation, according to the spread of various MA values.
릴리즈 노트
Including or excluding the long MA in the calculation for consolidation.
릴리즈 노트
UPDATE - September 17th, 2024

I've now added an "unweighted trend line", colored according to the long or short direction, which can be used in conjunction with the "weighted trend line" (also just called the "trend line"). This provides the ability to do crossovers between the unweighted and weighted trend lines, in the same way that a MACD crossover trading strategy works.

The idea behind the unweighted trend line is that it's intended to be a true average of the differences between the base and short, base and medium, and base and long moving averages. The weighted trend line, however, is the same calculation, but weighted by a "trend factor" that scales it up or down accordingly.

When the weighted and unweighted trend lines cross over each other, they denote a shift in various moving average beyond what is considered "normal" price movement.
릴리즈 노트
Update - September 17th, 2024 (2nd update)

I have redone the consolidation detection logic to be simpler. Now we simply detect the high and low ranges of the moving average differences and plot accordingly. You might want to consider modifying the consolidation tolerance to fit the volatility of the symbol you're applying this to. Every symbol will have a different concept of what is considered "volatile" and "consolidated" - this is more of an art than a science.
릴리즈 노트
Bug fix:

Applying absolute value to the diff calculation for consolidation zones.
릴리즈 노트
UPDATE - September 24th, 2024

I've added the ability to track the slope of the min/max values between crossovers/unders of the trend line. This considers both previous crossovers/unders, as well as the current trend. By default, I'm going to leave this as "disabled" since it's a somewhat arbitrary metric which you can also just visually see quite clearly, but I think the slope could be useful to put a number to "how quickly and greatly something is changing".

I also added alert conditions for the trend crossovers, which I mistakenly left out in the past. My bad!

Fun note: I had originally intended to calculate the degree of the slope, but this isn't feasible because PineScript doesn't provide the "width" of a bar and so any degree calculation would be inaccurate. Basically the x-axis of "time" (bars) and the y-axis of "trend value" aren't of the same unit, therefore degrees aren't really possible to calculate. So instead, I compromised, going with the intent of this update and just returned the slope scaled by 100.
Moving Averages

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?


또한 다음에서도:

면책사항