本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// © OmegaTools
//@version=6
indicator(title = 'Omega Effort [OmegaTools]', shorttitle = 'Ω Effort', overlay = true, max_boxes_count = 500, max_labels_count = 500)
sens = input.float(3, 'Sentivity', minval = 2, maxval = 5, step = 0.25)
only = input.string('All', 'Filter', ['All', 'Preferred', 'Distal'])
upc = input.color(#2962ff, 'Positive color', group = 'Style')
dnc = input.color(#e91e63, 'Negative color', group = 'Style')
z(src) => (src - ta.sma(src, 21)) / ta.stdev(src, 21)
sma = ta.rma(close * volume, 9) / ta.rma(volume, 9)
efficency = math.abs(close - open) / volume
ze = z(efficency)
zv = z(volume)
effort = ze > sens
block = zv > sens
bull = close > open
opacity = math.min(math.max(math.round(100 - ze * 10), 0), 100)
type Zone
box b
int start
bool bull
var array<Zone> active = array.new<Zone>()
if active.size() > 0
for i = active.size() - 1 to 0
zn = active.get(i)
age = bar_index - zn.start
broken = zn.bull ? close < zn.b.get_bottom() : close > zn.b.get_top()
if broken
zn.b.set_right(zn.start + math.max(age, 7))
active.remove(i)
else if age >= 21
active.remove(i)
if effort and close != open
col = bull ? upc : dnc
if (only == 'All') or ((only == 'Preferred' and bull and hl2 < sma) or (only == 'Preferred' and not bull and hl2 > sma)) or ((only == 'Distal' and not bull and hl2 < sma) or (only == 'Distal' and bull and hl2 > sma))
b = box.new(bar_index, high, bar_index + 21, low, color.new(col, opacity - 10), bgcolor = color.new(col, opacity))
active.push(Zone.new(b, bar_index, bull))
plot(sma, 'Center of Gravity', color.new(chart.fg_color, 50), linestyle = plot.linestyle_dotted)
if block and close != open
label.new(bar_index, 0, yloc = bull ? yloc.abovebar : yloc.belowbar, color = bull ? dnc : upc, style = label.style_xcross, size = 3, tooltip = str.tostring(zv, '#.#') + 'X avg volume')
// End of Script