NWOG/NDOG (cryptonnnite)

cryptonnnite · study · 34 行 · 点赞 4,789 · TradingView 原页

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

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © cryptonnnite
 
//@version=5
indicator("Weekly Open Gap (cryptonnnite)", overlay = true)
 
isNewbar(res) =>
    t = time(res)
    not na(t) and (na(t[1]) or t > t[1])
 
type gap
    float high
    float low
    int start
    int end
 
bool showOnHistory = input.bool(false, "Show on history")
color boxBg = input.color(color.rgb(120, 123, 134, 85), "Gap background")
 
getGapData() =>
    gap.new(math.max(close[1], open), math.min(close[1], open), time, time_close)
 
gap weeklyOpenGap = request.security(syminfo.tickerid, "1W", getGapData(), lookahead =  barmerge.lookahead_on)
int currentDayTimeClose = request.security(syminfo.tickerid, "1D", time_close, lookahead =  barmerge.lookahead_on)
var box weeklyOpenGapBox = na
 
if isNewbar("W") and (timeframe.isdaily or timeframe.isintraday)
    weeklyOpenGapBox := box.new(weeklyOpenGap.start, weeklyOpenGap.high, weeklyOpenGap.end, weeklyOpenGap.low, xloc = xloc.bar_time, bgcolor = boxBg, border_width = 0)
 
    if not showOnHistory
        box.delete(weeklyOpenGapBox[1])
 
if isNewbar("D")
    box.set_right(weeklyOpenGapBox, currentDayTimeClose)

← 返回列表