15M High and Low Two Horizontal Lines

lukas_babarcsik · study · 49 行 · 点赞 23 · TradingView 原页

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

Pine Script

//@version=6
indicator("15M High Low - 2 Yellow Lines", overlay=true, max_lines_count=2)
 
// ===== SETTINGS =====
lineColor = input.color(color.yellow, "Line Color")
lineWidth = input.int(2, "Line Width", minval=1, maxval=5)
 
// ===== LAST CLOSED 15M CANDLE =====
prevHigh15 = request.security(
     syminfo.tickerid,
     "15",
     high[1],
     lookahead=barmerge.lookahead_on)
 
prevLow15 = request.security(
     syminfo.tickerid,
     "15",
     low[1],
     lookahead=barmerge.lookahead_on)
 
// ===== DETECT NEW 15M PERIOD =====
new15m = timeframe.change("15")
 
// ===== LINE OBJECTS =====
var line highLine = na
var line lowLine = na
 
// ===== UPDATE LINES =====
if timeframe.isminutes and timeframe.multiplier == 1
    if new15m or na(highLine) or na(lowLine)
        if not na(highLine)
            line.delete(highLine)
        if not na(lowLine)
            line.delete(lowLine)
 
        if not na(prevHigh15) and not na(prevLow15)
            highLine := line.new(
                 bar_index, prevHigh15,
                 bar_index + 1, prevHigh15,
                 extend=extend.right,
                 color=lineColor,
                 width=lineWidth)
 
            lowLine := line.new(
                 bar_index, prevLow15,
                 bar_index + 1, prevLow15,
                 extend=extend.right,
                 color=lineColor,
                 width=lineWidth)

← 返回列表