Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © MirNader
- //@version=5
- indicator(title="Session [Mir Nader]", overlay=true)
- // Options
- asia_text_color = input.color(defval=color.new(#131722, 0), title="Asia Color", group="⌚ Asia Session", inline="a")
- asia_high_color = input.color(defval=color.new(#00bcd4, 0), title="High Line", group="⌚ Asia Session", inline="a")
- asia_low_color = input.color(defval=color.new(#00bcd4, 0), title="Low Line", group="⌚ Asia Session", inline="a")
- london_text_color = input.color(defval=color.new(#131722, 0), title="Lonon Color", group="⏱ London Session", inline="b")
- london_high_color = input.color(defval=color.new(#f2a03a, 0), title="High Line", group="⏱ London Session", inline="b")
- london_low_color = input.color(defval=color.new(#f2a03a, 0), title="Low Line", group="⏱ London Session", inline="b")
- ny_text_color = input.color(defval=color.new(#131722, 0), title="New York Color", group="⏲ New York Session", inline="t")
- ny_high_color = input.color(defval=color.new(#467deb, 0), title="High Line", group="⏲ New York Session", inline="t")
- ny_low_color = input.color(defval=color.new(#467deb, 0), title="Low Line", group="⏲ New York Session", inline="t")
- reurtn_day = input.int(defval=1, minval=1, maxval=80, title="Display Session Day", group="⌛ All Session Options" , inline = "d")
- session_text_size = input.string(defval="Tiny", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge", "Auto"], group="⌛ All Session Options", inline="a")
- session_line_style = input.string(defval="Solid (─)", title="Line Style", options=["Solid (─)", "Dotted (┈)"], group="⌛ All Session Options", inline="b")
- session_line_width = input.int(defval=1, title="Line Size", minval=1, maxval=20, group="⌛ All Session Options", inline="b")
- font_famill_ = input.string("Mono" , "Font" , options = ["Mono" , "Normal"], group="⌛ All Session Options", inline="a")
- //------------------------------------
- FirstDay = dayofmonth(time, "Asia/Shanghai") != dayofmonth(time, "Asia/Shanghai")[1] and timeframe.isintraday
- SecondDay = dayofmonth(time, "Europe/London") != dayofmonth(time, "Europe/London")[1] and timeframe.isintraday
- ThirdDay = dayofmonth(time, "America/New_York") != dayofmonth(time, "America/New_York")[1] and timeframe.isintraday
- c_milliseconds_in_day = 24 * 60 * 60 * 1000
- //Return Day
- lastBarDate = timestamp(year(timenow), month(timenow), dayofmonth(timenow), hour(timenow), minute(timenow), second(timenow))
- thisBarDate = timestamp(year, month, dayofmonth, hour, minute, second)
- daysLeft = math.floor((lastBarDate - thisBarDate) / c_milliseconds_in_day)
- _range = daysLeft < reurtn_day
- // Function
- line_style_function(input_var) =>
- switch input_var
- "Dotted (┈)" => line.style_dotted
- "Solid (─)" => line.style_solid
- text_size_function(string_size) =>
- switch string_size
- "Tiny" => size.tiny
- "Small" => size.small
- "Normal" => size.normal
- "Large" => size.large
- "Huge" => size.huge
- "Auto" => size.auto
- font(font_famill) =>
- switch font_famill
- "Normal" => font.family_default
- "Mono" => font.family_monospace
- //lines
- session_show(HIGH_LINE_TOGGLE, LOW_LINE_TOGGLE, HIGH_LABEL_TOGGLE, LOW_LABEL_TOGGLE, SESSION_TIME, DAYS_BACK, NEW_DAY, LINE_HIGH_COLOR, LINE_HIGH_STYLE, LINE_HIGH_WIDTH, LINE_LOW_COLOR, LINE_LOW_STYLE, LINE_LOW_WIDTH, TEXT_COLOR, TEXT_CHAR, TEXT_SIZE , Text_familly) =>
- session_est_window = time(timeframe.period, SESSION_TIME, "America/New_York")
- session_start_hour = str.substring(SESSION_TIME, 0, 2)
- session_start_minutes = str.substring(SESSION_TIME, 2, 4)
- session_start_time = (hour(time, "America/New_York") == str.tonumber(session_start_hour)) and (minute(time) == str.tonumber(session_start_minutes))
- session_line_high_style = line_style_function(LINE_HIGH_STYLE)
- session_line_low_style = line_style_function(LINE_LOW_STYLE)
- label_text_size = text_size_function(TEXT_SIZE)
- font_famill__ = font(Text_familly)
- // Instantiate variables
- var float session_high = 0.0
- var float session_low = 0.0
- var line session_line_low = na
- var line session_line_high = na
- var label session_label_low = na
- var label session_label_high = na
- var float price_session_line_low = na
- var float price_session_line_high = na
- standardized_calc = ta.stdev(close, 10) / 2
- if DAYS_BACK
- if timeframe.isminutes and timeframe.multiplier < 61
- if NEW_DAY
- if HIGH_LINE_TOGGLE
- session_line_high := line.new(x1=na, y1=na, x2=na, y2=na, color=LINE_HIGH_COLOR, style=session_line_high_style, width=LINE_HIGH_WIDTH )
- if LOW_LINE_TOGGLE
- session_line_low := line.new(x1=na, y1=na, x2=na, y2=na, color=LINE_LOW_COLOR, style=session_line_low_style, width=LINE_LOW_WIDTH)
- ab = 5
- else
- if session_start_time
- session_high := high
- session_low := low
- if HIGH_LINE_TOGGLE
- line.set_x1(session_line_high, bar_index)
- line.set_y1(session_line_high, session_high)
- line.set_x2(session_line_high, bar_index + 1)
- line.set_y2(session_line_high, session_high)
- if LOW_LINE_TOGGLE
- line.set_x1(session_line_low, bar_index)
- line.set_y1(session_line_low, session_low)
- line.set_x2(session_line_low, bar_index + 1)
- line.set_y2(session_line_low, session_low)
- if session_est_window
- session_high := math.max(session_high, high)
- session_low := math.min(session_low, low)
- if HIGH_LINE_TOGGLE
- line.set_y1(session_line_high, session_high)
- line.set_x2(session_line_high, bar_index + 1)
- line.set_y2(session_line_high, session_high)
- if LOW_LINE_TOGGLE
- line.set_y1(session_line_low, session_low)
- line.set_x2(session_line_low, bar_index + 1)
- line.set_y2(session_line_low, session_low)
- x_middle = (line.get_x2(session_line_low) - line.get_x1(session_line_low)) / 2
- if HIGH_LABEL_TOGGLE
- price_session_line_high := line.get_price(session_line_high, bar_index)
- session_label_high := label.new(x=bar_index - x_middle, y=price_session_line_high,text=TEXT_CHAR + " " + "High", style = label.style_label_down, color=color.new(#131722, 100), textcolor=TEXT_COLOR, size = label_text_size )
- label.set_text_font_family(session_label_high , font_famill__)
- label.delete(session_label_high[1])
- if LOW_LABEL_TOGGLE
- price_session_line_low := line.get_price(session_line_low, bar_index)
- session_label_low := label.new(x=bar_index - x_middle, y=price_session_line_low, text=TEXT_CHAR + " " + "Low",style = label.style_label_up , color=color.new(#131722, 100), textcolor=TEXT_COLOR, size = label_text_size)
- label.set_text_font_family(session_label_low , font_famill__)
- label.delete(session_label_low[1])
- ab = 6
- session_show(true, true, true, true, '1700-0300', _range, FirstDay, asia_high_color, session_line_style, session_line_width, asia_low_color, session_line_style, session_line_width, asia_text_color, "Asia" , session_text_size , font_famill_)
- session_show(true, true, true, true, '0300-1100', _range, SecondDay, london_high_color, session_line_style, session_line_width, london_low_color, session_line_style, session_line_width, london_text_color, "London", session_text_size , font_famill_)
- session_show(true, true, true, true, '0800-1600', _range, ThirdDay, ny_high_color, session_line_style, session_line_width, ny_low_color, session_line_style, session_line_width, ny_text_color, "New York", session_text_size , font_famill_)
- /////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment