munkeefonix

TRIX MA

Updated vesion of the script including the crossover in the background can be found here:
Trix with a EMA or SMA.

Length: Length of the Trix
Use Ema: True will use an ema, false will use an SMA.
Moving Average: Moving Average used on the TRIX Value.
Histogram Multiplier: Exaggerate the difference between the TRIX and Moving Average.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study("TRIX Moving Average", shorttitle="TRIX MA")
//  Trix with a EMA or SMA. 
//
//  @author munkeefonix
//  https://www.tradingview.com/u/munkeefonix/
//
//  inputs:
//  Length: Length of the Trix
//  Use Ema: Use an ema or sma.
//  Moving Average: Moving Average used on the TRIX Value.
//  Histogram Multiplier: Exaggerate  the difference between the TRIX and Moving Average.

_length=input(15, title="TRIX Length", minval=1)
_useEma=input(true, type=bool, title="Use Ema")
_ma=input(9, title="Moving Average", minval=1)
_mult=input(2.0, type=float, minval=1, title="Histogram Multiplier")

tema(a, b)=>ema(ema(ema(a, b), b), b)
trix(a)=>((a-a[1]) / a[1]) * 10000

_trix=trix(tema(close, _length))
_trixs=_useEma ? ema(_trix, _ma) : sma(_trix, _ma)
_trixh=(_trix-_trixs)

hline(0, color=#000000, title="Zero Line")

plot(_trixh * _mult, color=#000000, style=area, transp=80, title="Histogram")
plot(_trix, color=#FFCC00, title="TRIX")
plot(_trixs, color=#CC0000, title="TRIX Moving Average")
plot(cross(_trix, _trixs) ? _trix : na, color=white, style=cross, linewidth=2, title="TRIX Moving Average")