lonestar108

SMI Bars

Uses SMI (Stochastic Momentum Index) to set bar colors:

When SMI above overbought, bar color is red.
When SMI is between 0 and overbought, bar color is maroon
When SMI is between oversold and 0, bar color is green
When SMI is below oversold, bar color is lime.
When SMI crosses above or below 0, bar color is orange.

开源脚本

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

免责声明

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

想在图表上使用此脚本?
//Stochastic Momentum Index
//SMI Code by UCSgears, adapted to bars by lonestar108
study("SMI Bars", shorttitle = "SMI_Bars", overlay=true)
a = input(5, "Percent K Length")
b = input(3, "Percent D Length")
ob = input(40, "Overbought")
os = input(-40, "Oversold")
// Range Calculation
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
// Nested Moving Average for smoother curves
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
// SMI calculations
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)


barcolor(cross(SMI,0) and SMI > 0 ? orange : na)
barcolor(cross(SMI,0) and SMI < 0 ? orange : na)
barcolor(SMI > ob ? red : na)
barcolor((SMI > 0 and SMI <=ob) ? maroon : na)
barcolor((SMI <= 0 and SMI >=os) ? green : na)
barcolor(SMI < os ? lime : na)


//END