MTF Opening Range │ MarketMindset

marketmindset · study · 71 行 · 点赞 816 · 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/
// © marketmindset
//Copied from v14
AUTO            = "Auto"
DAILY           = "Daily"
WEEKLY          = "Weekly"
MONTHLY         = "Monthly"
QUARTERLY       = "Quarterly"
HALFYEARLY      = "Half Yearly"
YEARLY          = "Yearly"
 
sol     = line.style_solid
dot     = line.style_dotted
dsh     = line.style_dashed
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//@version=5
indicator("The Opening Range / First Bar By Market Mindset", "OR/FB - Z2E", overlay=true, max_lines_count=500)
import TradingView/ta/5
 
res         = input.string( AUTO    , "Resolution"  , options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, HALFYEARLY, YEARLY])
timeframe   = input.timeframe( ""   , "Timeframe")
lookback    = input.int( 10  , "Lookback"    , 1)
midLine     = input.bool( true, "Show Midline")
 
boxStyle    = input.string( dot , 'Range : '    ,  options = [sol,dot,dsh]      , inline = "Box"   , group = "Style")
lineStyle   = input.string( sol , 'Middle : '   ,  options = [sol,dot,dsh]      , inline = "Line"  , group = "Style")
borderWidth = input.int( 1  , ' / '  , 1 , 10   , inline = "Box"   , group = "Style")
lineWidth   = input.int( 1  , ' / '  , 1 , 10   , inline = "Line"   , group = "Style")
_color      = input.color(color.lime, "Color : "    , inline = "Color"   , group = "Style")
_fillcolor  = input.color(color.new(color.lime,85), " / "    , inline = "Color"   , group = "Style")
 
get_auto_resolution() =>
	resolution = '12M'
	if timeframe.isintraday
		resolution := timeframe.multiplier <= 15 ? 'D' : 'W'
	else if timeframe.isdaily
		resolution := 'M'
    resolution
 
resolution = switch res
    AUTO        => get_auto_resolution()
    DAILY       => "D"
    WEEKLY      => "W"
    MONTHLY     => "M"
    QUARTERLY   => "3M"
    HALFYEARLY  => "6M"
    => "12M"
 
if (resolution == "D" or resolution == "W") and timeframe.isdwm 
    runtime.error("Timeframe is higher than the resolution used.")
 
[start, end, isLast]  = request.security(syminfo.tickerid, resolution , [time, time_close, barstate.islast], lookahead=barmerge.lookahead_on)
[BarTime, H, L, M, isConfirmedBar]   = request.security(syminfo.tickerid, timeframe , [time, high , low , hl2 , barstate.isconfirmed])
 
var line _mid   = na
var _mids       = array.new_line()
var box _range  = na
var _ranges     = array.new_box()
    
if ta.change(start) and isConfirmedBar
    if midLine
        _mid := line.new(start, M, end, M, color = _color , style = lineStyle, width=lineWidth, xloc = xloc.bar_time)
        array.push(_mids, _mid)
 
    _range := box.new(start, H, end, L, color.new(_color,50), borderWidth, boxStyle, bgcolor = _fillcolor, xloc = xloc.bar_time)
    array.push(_ranges, _range)
 
    if array.size(_mids) > lookback + 1
        line.delete(array.shift(_mids))
        box.delete(array.shift(_ranges))

← 返回列表