PineScript16 Supertrend easier

voonology · study · 63 行 · 点赞 16 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Voonology
// PineScript16 — Developed by Voonology
// Version: 1.0.0
//@version=6
indicator("Supertrend easier", overlay = true)
 
atrPeriod = input.int(10, "ATR Length")
factor    = input.float(3.0, "Factor")
 
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
 
buySignal  = ta.change(direction) < 0
sellSignal = ta.change(direction) > 0
 
bodyMiddle = plot((open + close) / 2, display = display.none)
 
upTrend = plot(
     direction < 0 ? supertrend : na,
     "Up Trend",
     color = color.new(color.green, 0),
     style = plot.style_linebr
)
 
downTrend = plot(
     direction < 0 ? na : supertrend,
     "Down Trend",
     color = color.new(color.red, 0),
     style = plot.style_linebr
)
 
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps = false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps = false)
 
plotshape(
     buySignal,
     title = "Buy Signal",
     style = shape.labelup,
     location = location.belowbar,
     color = color.new(#046ff9, 0),
     size = size.small,
     text = "Buy",
     textcolor = color.white
)
 
plotshape(
     sellSignal,
     title = "Sell Signal",
     style = shape.labeldown,
     location = location.abovebar,
     color = color.new(#046ff9, 0),
     size = size.small,
     text = "Sell",
     textcolor = color.white
)
 
ema50 = ta.ema(close, 50)
plot(ema50, "EMA 50", color = color.blue)
 
// TradingView alert conditions
alertcondition(buySignal, title = "Buy Alert", message = "Buy Signal on {{ticker}}")
alertcondition(sellSignal, title = "Sell Alert", message = "Sell Signal on {{ticker}}")
//

← 返回列表