High & Low Of Custom Session - OpeningRange Breakout (Zeiierman)

Zeiierman · study · 71 行 · 点赞 4,804 · TradingView 原页

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

Pine Script

//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type. 
//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns. 
//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
//My scripts/indicators/ideas are only for educational purposes!
//Copyright by Zeiierman
 
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Zeiierman
 
study("High & Low Of Custom Session - OpeningRange Breakout (Expo)", shorttitle="High/Low Of Custom Session (Expo)",overlay=true)
 
// Inputs
my_session = input("1200-1300", type=input.session, title='Custom Session')
Lines = input(false, title="Show High/Low Lines?")
ExtendLine = input(true, title="Extend Session High/Low Lines?")
FILL = input(true, title="Show Session BGcolor?")
 
// Determine if we are in a session
in_session = time(timeframe.period, my_session)
is_new_session(res, sess) =>
    t = time(res, sess)
    na(t[1]) and not na(t) or t[1] < t
 
new_session = is_new_session("1440", my_session)
 
// Start of Session
is_newbar(res,sess) =>
    t = time(res,sess)
    not na(t) and (na(t[1]) or t > t[1])
new = (is_newbar("1440", my_session) ? 1 : 0)
 
// Plot Start Of Session
col_Start_of_Session = new_session and new==1? color.aqua:na
plotshape(high, color=col_Start_of_Session, style=shape.circle, location= location.absolute, size=size.small, title="Start_of_Session")
    
 
// In Session High/Low Calculations
var float _low = close
var float _high = close
 
_low := new_session? low : in_session ? min(low, _low[1]) : na
_high := new_session  ? high : in_session ? max(high, _high[1]) : na
 
col_low = _low == low? na: Lines?color.red:na
col_high = _high== high? na:Lines? color.green:na
 
// Plot High/Low Line
Low=plot(_low, style=plot.style_line, linewidth=1, color=col_low)
High=plot(_high, style=plot.style_line, linewidth=1, color=col_high)
 
// BG Color
Fill_col = FILL ? color.aqua:na
fill(Low,High, color=Fill_col)
//
 
// End of Session
start_of_session_value = valuewhen((new==1),high,0)
end_session_condition = start_of_session_value !=start_of_session_value[1]?0: in_session?1:0 
end_session = (end_session_condition == 0) and (end_session_condition[1]==1)? color.orange:na
plotshape(close, color=end_session, location=location.absolute, style=shape.circle, size=size.small)
 
// Extend High/Low Session Lines
v_extend_low = valuewhen((_low == low),low,0)
col_v_extend_low =  (end_session_condition == 0) and v_extend_low ==v_extend_low[1] and ExtendLine? color.red:na
plot(v_extend_low, color=col_v_extend_low, title="Extend Low")
 
v_extend_high = valuewhen((_high == high),high,0)
col_v_extend_high =  (end_session_condition == 0) and v_extend_high ==v_extend_high[1]  and ExtendLine? color.green:na
plot(v_extend_high, color=col_v_extend_high, title="Extend High")

← 返回列表