xmd79

Session [Mir Nader]

Dec 31st, 2022
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.66 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © MirNader
  3.  
  4. //@version=5
  5. indicator(title="Session [Mir Nader]", overlay=true)
  6.  
  7.  
  8. // Options
  9.  
  10.  
  11. asia_text_color = input.color(defval=color.new(#131722, 0), title="Asia Color", group="⌚ Asia Session", inline="a")
  12. asia_high_color = input.color(defval=color.new(#00bcd4, 0), title="High Line", group="⌚ Asia Session", inline="a")
  13. asia_low_color = input.color(defval=color.new(#00bcd4, 0), title="Low Line", group="⌚ Asia Session", inline="a")
  14.  
  15. london_text_color = input.color(defval=color.new(#131722, 0), title="Lonon Color", group="⏱ London Session", inline="b")
  16. london_high_color = input.color(defval=color.new(#f2a03a, 0), title="High Line", group="⏱ London Session", inline="b")
  17. london_low_color = input.color(defval=color.new(#f2a03a, 0), title="Low Line", group="⏱ London Session", inline="b")
  18.  
  19.  
  20. ny_text_color = input.color(defval=color.new(#131722, 0), title="New York Color", group="⏲ New York Session", inline="t")
  21. ny_high_color = input.color(defval=color.new(#467deb, 0), title="High Line", group="⏲ New York Session", inline="t")
  22. ny_low_color = input.color(defval=color.new(#467deb, 0), title="Low Line", group="⏲ New York Session", inline="t")
  23.  
  24. reurtn_day = input.int(defval=1, minval=1, maxval=80, title="Display Session Day", group="⌛ All Session Options" , inline = "d")
  25. session_text_size = input.string(defval="Tiny", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge", "Auto"], group="⌛ All Session Options", inline="a")
  26. session_line_style = input.string(defval="Solid (─)", title="Line Style", options=["Solid (─)", "Dotted (┈)"], group="⌛ All Session Options", inline="b")
  27. session_line_width = input.int(defval=1, title="Line Size", minval=1, maxval=20, group="⌛ All Session Options", inline="b")
  28. font_famill_ = input.string("Mono" , "Font" , options = ["Mono" , "Normal"], group="⌛ All Session Options", inline="a")
  29.  
  30. //------------------------------------
  31. FirstDay = dayofmonth(time, "Asia/Shanghai") != dayofmonth(time, "Asia/Shanghai")[1] and timeframe.isintraday
  32. SecondDay = dayofmonth(time, "Europe/London") != dayofmonth(time, "Europe/London")[1] and timeframe.isintraday
  33. ThirdDay = dayofmonth(time, "America/New_York") != dayofmonth(time, "America/New_York")[1] and timeframe.isintraday
  34. c_milliseconds_in_day = 24 * 60 * 60 * 1000
  35.  
  36. //Return Day
  37. lastBarDate = timestamp(year(timenow), month(timenow), dayofmonth(timenow), hour(timenow), minute(timenow), second(timenow))
  38. thisBarDate = timestamp(year, month, dayofmonth, hour, minute, second)
  39. daysLeft = math.floor((lastBarDate - thisBarDate) / c_milliseconds_in_day)
  40. _range = daysLeft < reurtn_day
  41.  
  42. // Function
  43. line_style_function(input_var) =>
  44. switch input_var
  45. "Dotted (┈)" => line.style_dotted
  46. "Solid (─)" => line.style_solid
  47.  
  48. text_size_function(string_size) =>
  49. switch string_size
  50. "Tiny" => size.tiny
  51. "Small" => size.small
  52. "Normal" => size.normal
  53. "Large" => size.large
  54. "Huge" => size.huge
  55. "Auto" => size.auto
  56.  
  57.  
  58. font(font_famill) =>
  59. switch font_famill
  60. "Normal" => font.family_default
  61. "Mono" => font.family_monospace
  62.  
  63. //lines
  64. 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) =>
  65.  
  66. session_est_window = time(timeframe.period, SESSION_TIME, "America/New_York")
  67. session_start_hour = str.substring(SESSION_TIME, 0, 2)
  68. session_start_minutes = str.substring(SESSION_TIME, 2, 4)
  69. session_start_time = (hour(time, "America/New_York") == str.tonumber(session_start_hour)) and (minute(time) == str.tonumber(session_start_minutes))
  70.  
  71. session_line_high_style = line_style_function(LINE_HIGH_STYLE)
  72. session_line_low_style = line_style_function(LINE_LOW_STYLE)
  73. label_text_size = text_size_function(TEXT_SIZE)
  74. font_famill__ = font(Text_familly)
  75.  
  76. // Instantiate variables
  77. var float session_high = 0.0
  78. var float session_low = 0.0
  79. var line session_line_low = na
  80. var line session_line_high = na
  81. var label session_label_low = na
  82. var label session_label_high = na
  83. var float price_session_line_low = na
  84. var float price_session_line_high = na
  85.  
  86. standardized_calc = ta.stdev(close, 10) / 2
  87.  
  88. if DAYS_BACK
  89.  
  90. if timeframe.isminutes and timeframe.multiplier < 61
  91.  
  92. if NEW_DAY
  93.  
  94. if HIGH_LINE_TOGGLE
  95. 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 )
  96. if LOW_LINE_TOGGLE
  97. 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)
  98.  
  99. ab = 5
  100.  
  101. else
  102.  
  103. if session_start_time
  104. session_high := high
  105. session_low := low
  106.  
  107. if HIGH_LINE_TOGGLE
  108. line.set_x1(session_line_high, bar_index)
  109. line.set_y1(session_line_high, session_high)
  110. line.set_x2(session_line_high, bar_index + 1)
  111. line.set_y2(session_line_high, session_high)
  112.  
  113. if LOW_LINE_TOGGLE
  114. line.set_x1(session_line_low, bar_index)
  115. line.set_y1(session_line_low, session_low)
  116. line.set_x2(session_line_low, bar_index + 1)
  117. line.set_y2(session_line_low, session_low)
  118.  
  119. if session_est_window
  120. session_high := math.max(session_high, high)
  121. session_low := math.min(session_low, low)
  122.  
  123. if HIGH_LINE_TOGGLE
  124. line.set_y1(session_line_high, session_high)
  125. line.set_x2(session_line_high, bar_index + 1)
  126. line.set_y2(session_line_high, session_high)
  127.  
  128. if LOW_LINE_TOGGLE
  129. line.set_y1(session_line_low, session_low)
  130. line.set_x2(session_line_low, bar_index + 1)
  131. line.set_y2(session_line_low, session_low)
  132.  
  133. x_middle = (line.get_x2(session_line_low) - line.get_x1(session_line_low)) / 2
  134.  
  135. if HIGH_LABEL_TOGGLE
  136. price_session_line_high := line.get_price(session_line_high, bar_index)
  137. 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 )
  138. label.set_text_font_family(session_label_high , font_famill__)
  139. label.delete(session_label_high[1])
  140.  
  141. if LOW_LABEL_TOGGLE
  142. price_session_line_low := line.get_price(session_line_low, bar_index)
  143. 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)
  144. label.set_text_font_family(session_label_low , font_famill__)
  145. label.delete(session_label_low[1])
  146.  
  147. ab = 6
  148.  
  149. 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_)
  150. 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_)
  151. 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_)
  152.  
  153.  
  154. /////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment