本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MisinkoMaster
//@version=6
indicator("Weighted Extreme", overlay = true, behind_chart = false)
////////////////////////////////////////////////////////////////////////////////////
//Get User Defined Inputs
len = input.int(35, "Lookback", step = 1, minval = 2,
group = "Weighted Extreme")
////////////////////////////////////////////////////////////////////////////////////
//Calculations
upper = (ta.wma(close, len) + ta.highest(high, len))/2
lower = (ta.wma(close, len) + ta.lowest(low, len))/2
////////////////////////////////////////////////////////////////////////////////////
//Trend Logic
long = close > upper
short = close < lower
var trend = 0
if long and not short
trend := 1
if short
trend := -1
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Plotting
uptrend = trend == 1 ? lower : na
downtrend = trend == -1 ? upper : na
a = plot(uptrend, "Lower", color = color.rgb(19, 197, 64), style = plot.style_linebr)
b = plot(downtrend, "Upper", color = color.rgb(184, 21, 21), style = plot.style_linebr)
c = plot(close, display = display.none, editable = false)
fill(a, c, color.rgb(19, 197, 64, 50))
fill(b, c, color.rgb(184, 21, 21, 50))
col = trend == 1 ? color.rgb(19, 197, 64) : trend == -1 ? color.rgb(184, 21, 21) : color.rgb(42, 42, 42)
plotcandle(open, high, low, close, color = col, wickcolor = col, bordercolor = col, display = display.pane)