xmd79

Session Levels

Jan 11th, 2022
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 109.53 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. // © ArdOfCrypto
  3.  
  4. //@version=5
  5. indicator("Session Levels", overlay=true, max_bars_back=1000, max_lines_count=500, max_labels_count=500, max_boxes_count=50)
  6.  
  7. // Sessions and inputs
  8. i_GlobexSession = input.session(title="Globex ", defval="1700-0830", group="Session Settings", inline="GS") // Globex (Overnight) Session, Monday - Friday 17:00 - 0830. Globex opens at 5pm CST and closes when the US session starts 8:30CST.
  9. i_GlobexSessionCol = input.color(title="Color",tooltip="Globex Session Highlight Color", defval=color.silver, group="Session Settings", inline="GS") // Globex (Overnight) Session, color setting for background highlights
  10. i_GlobexLevelCol = input.color(title="Color",tooltip="Globex Levels Color", defval=color.gray, group="Session Settings", inline="GS") // Globex (Overnight) Session, color setting for level lines
  11. i_AsianSession = input.session(title="Asian ", defval="1900-0200", group="Session Settings", inline="AS") // Asian Session, Monday - Friday
  12. i_AsianSessionCol = input.color(title="Color",tooltip="Asian Session Highlight Color", defval=color.white, group="Session Settings", inline="AS") // Asian Session, color setting for background highlights, 1st hr box and High and Low lines
  13. i_AsianLevelCol = input.color(title="Color",tooltip="Asian Levels Color", defval=color.gray, group="Session Settings", inline="AS") // Asian Session, color setting for level lines
  14. i_AsianORoffset = input.int(title="Asian Open Offset", tooltip="Asian Session Opening Range Starts after x minutes", defval=30, minval=0, maxval=59, group="Session Settings") // Asian Opening Range Initial Balance Opening Minute
  15. i_LondonSession = input.session(title="London ", defval="0300-1100", group="Session Settings", inline="LS") // London Session, Monday - Friday
  16. i_LondonSessionCol = input.color(title="Color",tooltip="London Session Highlight Color", defval=color.green, group="Session Settings", inline="LS") // London Session, color setting for background highlights, 1st hr box and High and Low lines
  17. i_LondonLevelCol = input.color(title="Color",tooltip="London Levels Color", defval=color.gray, group="Session Settings", inline="LS") // London Session, color setting for level lines
  18. i_LondonORoffset = input.int(title="London Open Offset", tooltip="London Session Opening Range Starts after x minutes", defval=30, minval=0, maxval=59, group="Session Settings") // London Opening Range Initial Balance Opening Minute
  19. i_NewYorkSession = input.session(title="New York", defval="0800-1600", group="Session Settings", inline="NY") // New York Session
  20. i_NYSessionCol = input.color(title="Color",tooltip="New York Session Highlight Color", defval=color.blue, group="Session Settings", inline="NY") // New York Session, color setting for background highlights, 1st hr box and High and Low lines
  21. i_NYLevelCol = input.color(title="Color",tooltip="New York Level Color", defval=color.gray, group="Session Settings", inline="NY") // New York Session, color setting for level lines
  22. i_NewYorkORoffset = input.int(title="New York Open Offset", tooltip="New York Session Opening Range Starts after x minutes", defval=30, minval=0, maxval=59, group="Session Settings") // New York Opening Range Initial Balance Opening Minute
  23. i_NYSessionEndHour = input.int(title="NY CashSession End Hour", defval=16, minval=0, maxval=23, group="Session Settings", inline="NYE") // New York Session Opening Hour
  24. i_NYSessionEndMin = input.int(title="Min.", defval=59, minval=0, maxval=59, group="Session Settings", inline="NYE", tooltip="This is where all the lines and drawings end. Must be Less than the start of Globex") // New York Session Opening Minute
  25. GlobexSession = time(timeframe.period, i_GlobexSession, "America/Chicago") // Calculate time for the Globex/Overnight session.
  26. AsianSession = time(timeframe.period, i_AsianSession, "America/Chicago") // Calculate time for the Asian Session.
  27. LondonSession = time(timeframe.period, i_LondonSession, "America/Chicago") // Calculate time for the London Session.
  28. NewYorkSession = time(timeframe.period, i_NewYorkSession, "America/Chicago") // Calculate time for the New York Session.
  29. var CashSessionEndTime = timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  30. srcHi = input(high, "Source for Highs", inline="Sources", group="Source") // Set Source for Highs used in calculations
  31. srcLo = input(low, "Source for Lows", inline="Sources", group="Source") // Set Source for Lows used in calculations
  32. showGlobex = input.bool(defval=true, title="Globex Overnight", tooltip="Show Globex Background Highlight", group="Session Highlight")
  33. showAsian = input.bool(defval=false, title="Asian", tooltip="Show Asian Background Highlight", group="Session Highlight")
  34. showLondon = input.bool(defval=false, title="London", tooltip="Show London Background Highlight", group="Session Highlight")
  35. showNewYork = input.bool(defval=true, title="New York", tooltip="Show NY Background Highlight", group="Session Highlight")
  36. showOpenbar = input.bool(defval=true, title="NY IB Opening Bar", tooltip="Show bar before the NY Initial Balance Highlight", group="Session Highlight")
  37. showTodaysDrawings = input.bool(defval=true, title="Show Todays Drawings Only", tooltip="Removes all historic drawings for cleaner charts", group="Drawings")
  38. showGlobexDrawings = input.bool(defval=true, title="Show Globex/Overnight Levels", tooltip="Show Globex/Overnight Drawings", group="Drawings")
  39. showAsianDrawings = input.bool(defval=false, title="Show Asian Levels", tooltip="Show Asian Session Drawings ", group="Drawings")
  40. showAsianOR = input.bool(defval=false, title="Show Asian Opening Range", tooltip="Show Asian Session Initial Balance Box ", group="Drawings")
  41. showAsianORStdev = input.bool(defval=false, title="Show Asian OR STDEV Projections", tooltip="Show Asian Standard Deviation Levels and Labels on Opening Range", group="Drawings")
  42. showLondonDrawings = input.bool(defval=false, title="Show London Levels", tooltip="Show London Session Drawings ", group="Drawings")
  43. showLondonOR = input.bool(defval=false, title="Show London Opening Range", tooltip="Show London Session Initial Balance Box ", group="Drawings")
  44. showLondonORStdev = input.bool(defval=false, title="Show London OR STDEV Projections", tooltip="Show London Standard Deviation Levels and Labels on Opening Range", group="Drawings")
  45. showNewYorkDrawings = input.bool(defval=true, title="Show New York Levels", tooltip="Show New York Session Session Drawings ", group="Drawings")
  46. showNewYorkOR = input.bool(defval=true, title="Show New York Opening Range", tooltip="Show New York Session Initial Balance Box ", group="Drawings")
  47. showNewYorkORStdev = input.bool(defval=false, title="Show New York OR STDEV Projections", tooltip="Show New York Standard Deviation Levels and Labels on Opening Range", group="Drawings")
  48. enableNewYorkalarms = input.bool(defval=false, title="Enable Alarms for the NY Session", tooltip="Alarms when price crosses: Globex Hi and Low; Hi, Lo, 50% OR Levels and 0.5 and 1.0 STDEV Levels", group="Alarms")
  49. showLabels = input.bool(defval=true, title="Show labels on Level Lines ", tooltip="Show Session Labels on every line", group="Drawings")
  50. showPDO = input.bool(defval=false, title="Show Previous Day Open", tooltip="Show Previous Days's Open line", group="HTF Levels")
  51. showPDC = input.bool(defval=true, title="Show Previous Day Close", tooltip="Show Previous Days's Closing line", group="HTF Levels")
  52. showPWO = input.bool(defval=true, title="Show Previous Week Open", tooltip="Show Previous Week's Opening price line", group="HTF Levels")
  53. showPWC = input.bool(defval=false, title="Show Previous Week Close", tooltip="Show Previous Week's Closing line", group="HTF Levels")
  54. showDebug = input.bool(defval=false, title="Show Debug Plot Values", tooltip="View values in the data window", group="DEBUG")
  55.  
  56. // Get HTF Values
  57. PreviousDayClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on) // Get the Previous Day's closing price
  58. PreviousDayOpen = request.security(syminfo.tickerid, "D", open[1], lookahead = barmerge.lookahead_on) // Get the Previous Day's opening price
  59. PreviousWeekClose = request.security(syminfo.tickerid, "W", close[1], lookahead = barmerge.lookahead_on) // Get the Previous Week's closing price
  60. PreviousWeekOpen = request.security(syminfo.tickerid, "W", open[1], lookahead = barmerge.lookahead_on) // Get the Previous Week's opening price
  61.  
  62.  
  63. // Set variables for the sessions
  64. // Globex Overnight session
  65. var float Globex_hi = na // High for the Globex Session
  66. var float Globex_75 = na // 75% level for the Globex Session
  67. var float Globex_50 = na // 50% level for the Globex Session
  68. var float Globex_25 = na // 25% level for the Globex Session
  69. var float Globex_lo = na // Low for the Globex Session
  70. var Globex_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex High line
  71. var Globex_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 75% line
  72. var Globex_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 50% line
  73. var Globex_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 25% line
  74. var Globex_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex Low line
  75. var GlobexHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left)
  76. var Globex75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left)
  77. var Globex50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left)
  78. var Globex25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left)
  79. var GlobexLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left)
  80. var GlobexSessionStart = time // To register the timestap when the Globex Overnight Session begins
  81. // Asian Session
  82. var float Asian_hi = na // High for the Asian Session
  83. var float Asian_75 = na // 75% level for the Asian Session
  84. var float Asian_50 = na // 50% level for the Asian Session
  85. var float Asian_25 = na // 25% level for the Asian Session
  86. var float Asian_lo = na // Low for the Asian Session
  87. var Asian_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian High line
  88. var Asian_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 75% line
  89. var Asian_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 50% line
  90. var Asian_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 25% line
  91. var Asian_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian Low line
  92. var AsianHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  93. var Asian75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  94. var Asian50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  95. var Asian25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  96. var AsianLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  97. var AsianSessionStart = time // To register the timestap when the Asian Session begins
  98. var AsianORStart = AsianSessionStart + (i_AsianORoffset * 60000) // Add the offset in milliseconds
  99. var AsianOREnd = AsianORStart + 3600000 // Add one hour in milliseconds
  100. // Asian Opening Range (1st Hour)
  101. var float AsianHr1hi = 0.0 // High for the 1st Hour Session
  102. var float AsianHr1lo = 0.0 // Low for the 1st Hour Session
  103. var AsianOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range High
  104. var AsianOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Low
  105. var AsianOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  106. var AsianOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  107. var AsianOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  108. var AsianOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  109. var AsianOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  110. var AsianOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  111. var AsianOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  112. var AsianOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  113. var AsianOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  114. var AsianOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  115. var AsianOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  116. var AsianOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  117. var AsianOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  118. var AsianOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  119. var AsianORBox = box.new(left=AsianORStart, top=na, right=AsianOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_AsianSessionCol, 100), bgcolor=color.new(i_AsianSessionCol, 70))
  120. var AsianORLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  121. var AsianORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  122. var AsianORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  123. var AsianORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  124. var AsianORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  125. var AsianORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  126. var AsianORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  127. var AsianORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  128. var AsianORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  129. // ***
  130. // London Session
  131. var float London_hi = na // High for the London Session
  132. var float London_75 = na // 75% level for the London Session
  133. var float London_50 = na // 50% level for the London Session
  134. var float London_25 = na // 25% level for the London Session
  135. var float London_lo = na // Low for the London Session
  136. var London_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // London High line
  137. var London_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // London 75% line
  138. var London_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // London 50% line
  139. var London_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // London 25% line
  140. var London_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // London Low line
  141. var LondonHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  142. var London75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  143. var London50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  144. var London25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  145. var LondonLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  146. var LondonSessionStart = time // To register the timestap when the London Session begins
  147. var LondonORStart = LondonSessionStart + (i_LondonORoffset * 60000) // Add the offset in milliseconds
  148. var LondonOREnd = LondonORStart + 3600000 // Add one hour in milliseconds
  149. // London Opening Range (1st Hour)
  150. var float LondonHr1hi = 0.0 // High for the 1st Hour Session
  151. var float LondonHr1lo = 0.0 // Low for the 1st Hour Session
  152. var LondonOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range High
  153. var LondonOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Low
  154. var LondonOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  155. var LondonOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  156. var LondonOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  157. var LondonOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  158. var LondonOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  159. var LondonOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  160. var LondonOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  161. var LondonOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  162. var LondonOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  163. var LondonOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  164. var LondonOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  165. var LondonOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  166. var LondonOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  167. var LondonOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  168. var LondonORBox = box.new(left=LondonORStart, top=na, right=LondonOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_LondonSessionCol, 100), bgcolor=color.new(i_LondonSessionCol, 70))
  169. var LondonORLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  170. var LondonORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  171. var LondonORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  172. var LondonORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  173. var LondonORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  174. var LondonORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  175. var LondonORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  176. var LondonORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  177. var LondonORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  178. // ***
  179. // New York Session
  180. var float NewYork_hi = na // High for the NewYork Session
  181. var float NewYork_75 = na // 75% level for the NewYork Session
  182. var float NewYork_50 = na // 50% level for the NewYork Session
  183. var float NewYork_25 = na // 25% level for the NewYork Session
  184. var float NewYork_lo = na // Low for the NewYork Session
  185. var NewYork_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork High line
  186. var NewYork_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 75% line
  187. var NewYork_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 50% line
  188. var NewYork_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 25% line
  189. var NewYork_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork Low line
  190. var NewYorkHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  191. var NewYork75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  192. var NewYork50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  193. var NewYork25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  194. var NewYorkLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  195. var NewYorkSessionStart = time // To register the timestap when the NewYork Session begins
  196. var NewYorkORStart = NewYorkSessionStart + (i_NewYorkORoffset * 60000) // Add the offset in milliseconds
  197. var NewYorkOREnd = NewYorkORStart + 3600000 // Add one hour in milliseconds
  198. // NewYork Opening Range (1st Hour)
  199. var float NewYorkHr1hi = 0.0 // High for the 1st Hour Session
  200. var float NewYorkHr1mid = 0.0 // 50% of the 1st Hour Session
  201. var float NewYorkHr1lo = 0.0 // Low for the 1st Hour Session
  202. var NewYorkOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range High
  203. var NewYorkOR_line_mid = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Middle
  204. var NewYorkOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Low
  205. var NewYorkOR_line_hi05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR
  206. var NewYorkOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  207. var NewYorkOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  208. var NewYorkOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  209. var NewYorkOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  210. var NewYorkOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  211. var NewYorkOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  212. var NewYorkOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  213. var NewYorkOR_line_lo05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR
  214. var NewYorkOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  215. var NewYorkOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  216. var NewYorkOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  217. var NewYorkOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  218. var NewYorkOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  219. var NewYorkOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  220. var NewYorkOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  221. var NewYorkORBox = box.new(left=NewYorkORStart, top=na, right=NewYorkOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_NYSessionCol, 100), bgcolor=color.new(i_NYSessionCol, 70))
  222. var NewYorkORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  223. var NewYorkORLabelHigh05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  224. var NewYorkORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  225. var NewYorkORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  226. var NewYorkORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  227. var NewYorkORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  228. var NewYorkORLabelLow05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  229. var NewYorkORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  230. var NewYorkORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  231. var NewYorkORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  232. var NewYorkORLabelMid = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  233. // ***
  234.  
  235. //
  236. // ALERTS Configuration for use during NY Session
  237. //
  238. // Function to trigger alerts when price crosses the Globex / Overnight Low during the NY Session
  239. f_triggerGlobexLow()=>
  240. _co = ta.crossover(close, Globex_lo)
  241. _cu = ta.crossunder(close, Globex_lo)
  242. if _co and NewYorkSession and enableNewYorkalarms
  243. alert("Price (" + str.tostring(close) + ") crossing over Globex Low (" + str.tostring(Globex_lo) + ")", alert.freq_once_per_bar)
  244. else if _cu and NewYorkSession
  245. alert("Price (" + str.tostring(close) + ") crossing under Globex Low (" + str.tostring(Globex_lo) + ")", alert.freq_once_per_bar)
  246. //
  247.  
  248. // Function to trigger alerts when price crosses the Globex / Overnight High during the NY Session
  249. f_triggerGlobexHigh()=>
  250. _co = ta.crossover(close, Globex_hi)
  251. _cu = ta.crossunder(close, Globex_hi)
  252. if _co and NewYorkSession and enableNewYorkalarms
  253. alert("Price (" + str.tostring(close) + ") crossing over Globex High (" + str.tostring(Globex_hi) + ")", alert.freq_once_per_bar)
  254. else if _cu and NewYorkSession
  255. alert("Price (" + str.tostring(close) + ") crossing under Globex High (" + str.tostring(Globex_hi) + ")", alert.freq_once_per_bar)
  256. //
  257.  
  258. // Function to trigger alerts when price crosses the NY Opening Range 50% level during the NY Session
  259. f_triggerNewYorkOR50perc()=>
  260. _NewYorkOR50perc = (NewYorkHr1lo+(NewYorkHr1hi-NewYorkHr1lo)/2)
  261. _co = ta.crossover(close, _NewYorkOR50perc)
  262. _cu = ta.crossunder(close, _NewYorkOR50perc)
  263. if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms
  264. alert("Price (" + str.tostring(close) + ") crossing over NY OR 50% (" + str.tostring(_NewYorkOR50perc) + ")", alert.freq_once_per_bar)
  265. else if _cu and NewYorkSession and time > NewYorkOREnd
  266. alert("Price (" + str.tostring(close) + ") crossing under NY OR 50% (" + str.tostring(_NewYorkOR50perc) + ")", alert.freq_once_per_bar)
  267. //
  268.  
  269. // Function to trigger alerts when price crosses the NY Opening Range STDEV 0.5 level during the NY Session
  270. f_triggerNewYorkSTDEVpos05()=>
  271. _NewYorkSTDEVpos05=(NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)/2)
  272. _co = ta.crossover(close, _NewYorkSTDEVpos05)
  273. _cu = ta.crossunder(close, _NewYorkSTDEVpos05)
  274. if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms
  275. alert("Price (" + str.tostring(close) + ") crossing over NY STDEV 0.5 (" + str.tostring(_NewYorkSTDEVpos05) + ")", alert.freq_once_per_bar)
  276. else if _cu and NewYorkSession and time > NewYorkOREnd
  277. alert("Price (" + str.tostring(close) + ") crossing under NY STDEV 0.5 (" + str.tostring(_NewYorkSTDEVpos05) + ")", alert.freq_once_per_bar)
  278. //
  279. // Function to trigger alerts when price crosses the NY Opening Range STDEV 1.0 level during the NY Session
  280. f_triggerNewYorkSTDEVpos10()=>
  281. _NewYorkSTDEVpos10=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)
  282. _co = ta.crossover(close, _NewYorkSTDEVpos10)
  283. _cu = ta.crossunder(close, _NewYorkSTDEVpos10)
  284. if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms
  285. alert("Price (" + str.tostring(close) + ") crossing over NY STDEV 1.0 (" + str.tostring(_NewYorkSTDEVpos10) + ")", alert.freq_once_per_bar)
  286. else if _cu and NewYorkSession and time > NewYorkOREnd
  287. alert("Price (" + str.tostring(close) + ") crossing under NY STDEV 1.0 (" + str.tostring(_NewYorkSTDEVpos10) + ")", alert.freq_once_per_bar)
  288. //
  289. // Function to trigger alerts when price crosses the NY Opening Range STDEV 0.5 level during the NY Session
  290. f_triggerNewYorkSTDEVneg05()=>
  291. _NewYorkSTDEVneg05=(NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)/2)
  292. _co = ta.crossover(close, _NewYorkSTDEVneg05)
  293. _cu = ta.crossunder(close, _NewYorkSTDEVneg05)
  294. if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms
  295. alert("Price (" + str.tostring(close) + ") crossing over NY STDEV -0.5 (" + str.tostring(_NewYorkSTDEVneg05) + ")", alert.freq_once_per_bar)
  296. else if _cu and NewYorkSession and time > NewYorkOREnd
  297. alert("Price (" + str.tostring(close) + ") crossing under NY STDEV -0.5 (" + str.tostring(_NewYorkSTDEVneg05) + ")", alert.freq_once_per_bar)
  298. //
  299. // Function to trigger alerts when price crosses the NY Opening Range STDEV 1.0 level during the NY Session
  300. f_triggerNewYorkSTDEVneg10()=>
  301. _NewYorkSTDEVneg10=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)
  302. _co = ta.crossover(close, _NewYorkSTDEVneg10)
  303. _cu = ta.crossunder(close, _NewYorkSTDEVneg10)
  304. if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms
  305. alert("Price (" + str.tostring(close) + ") crossing over NY STDEV -1.0 (" + str.tostring(_NewYorkSTDEVneg10) + ")", alert.freq_once_per_bar)
  306. else if _cu and NewYorkSession and time > NewYorkOREnd
  307. alert("Price (" + str.tostring(close) + ") crossing under NY STDEV -1.0 (" + str.tostring(_NewYorkSTDEVneg10) + ")", alert.freq_once_per_bar)
  308. //
  309. // End of Alert functions
  310.  
  311. // Function for determining the Start of a Session (taken from the Pinescript manual: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Sessions.html )
  312. sessionBegins(sess) =>
  313. t = time("", sess , "America/Chicago")
  314. timeframe.isintraday and (not barstate.isfirst) and na(t[1]) and not na(t)
  315. // End function
  316.  
  317.  
  318. // Start Logic
  319. //bool isNewDate = ta.change(time("D")) // Determine if new day has started. This is used to create new lines and labels.
  320.  
  321.  
  322. // *** Here the actual sessions begin:
  323. //
  324. // Begin Globex Session Code
  325. if sessionBegins(i_GlobexSession) // When a new Globex Session is started
  326. GlobexSessionStart := time // Store the Session Starting timestamp
  327. CashSessionEndTime := timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  328. if CashSessionEndTime < GlobexSessionStart // If the CashSessionEndTime is in the past, then add 1 day
  329. CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should
  330. // We are entering Globex Session hours; reset hi/lo.
  331. Globex_hi := srcHi
  332. Globex_lo := srcLo
  333. Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75
  334. Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5
  335. Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25
  336. // Initialize the drawings for today
  337. if showGlobexDrawings
  338. // Keep or Remove all historic levels
  339. if showTodaysDrawings // If true then delete all old objects
  340. line.delete(Globex_line_hi[1])
  341. line.delete(Globex_line_75[1])
  342. line.delete(Globex_line_50[1])
  343. line.delete(Globex_line_25[1])
  344. line.delete(Globex_line_lo[1])
  345. label.delete(GlobexHighLabel[1])
  346. label.delete(Globex75Label[1])
  347. label.delete(Globex50Label[1])
  348. label.delete(Globex25Label[1])
  349. label.delete(GlobexLowLabel[1])
  350. // Create new objects for today
  351. Globex_line_hi := line.new(x1=GlobexSessionStart, y1=Globex_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_hi, color=i_GlobexLevelCol) // Globex High line
  352. Globex_line_75 := line.new(x1=GlobexSessionStart, y1=Globex_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_75, color=i_GlobexLevelCol) // Globex 75% line
  353. Globex_line_50 := line.new(x1=GlobexSessionStart, y1=Globex_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_50, color=i_GlobexLevelCol) // Globex 50% line
  354. Globex_line_25 := line.new(x1=GlobexSessionStart, y1=Globex_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_25, color=i_GlobexLevelCol) // Globex 25% line
  355. Globex_line_lo := line.new(x1=GlobexSessionStart, y1=Globex_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_lo, color=i_GlobexLevelCol) // Globex Low line
  356. GlobexHighLabel := label.new(x=GlobexSessionStart, y=Globex_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  357. Globex75Label := label.new(x=GlobexSessionStart, y=Globex_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  358. Globex50Label := label.new(x=GlobexSessionStart, y=Globex_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  359. Globex25Label := label.new(x=GlobexSessionStart, y=Globex_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  360. GlobexLowLabel := label.new(x=GlobexSessionStart, y=Globex_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  361. label.set_tooltip(GlobexHighLabel, "Globex High")
  362. label.set_tooltip(Globex75Label, "Globex 75%")
  363. label.set_tooltip(Globex50Label, "Globex 50%")
  364. label.set_tooltip(Globex25Label, "Globex 25%")
  365. label.set_tooltip(GlobexLowLabel, "Globex Low")
  366. else if GlobexSession
  367. // We are in allowed GlobexSession hours; track hi/lo.
  368. Globex_hi := math.max(srcHi, Globex_hi)
  369. Globex_lo := math.min(srcLo, Globex_lo)
  370. if (Globex_hi > Globex_hi[1])
  371. Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75
  372. Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5
  373. Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25
  374. if showGlobexDrawings
  375. line.set_xy1(id=Globex_line_hi, x=time, y=Globex_hi)
  376. line.set_xy2(id=Globex_line_hi, x=CashSessionEndTime, y=Globex_hi)
  377. line.set_xy1(id=Globex_line_75, x=GlobexSessionStart, y=Globex_75)
  378. line.set_xy2(id=Globex_line_75, x=CashSessionEndTime, y=Globex_75)
  379. line.set_xy1(id=Globex_line_50, x=GlobexSessionStart, y=Globex_50)
  380. line.set_xy2(id=Globex_line_50, x=CashSessionEndTime, y=Globex_50)
  381. line.set_xy1(id=Globex_line_25, x=GlobexSessionStart, y=Globex_25)
  382. line.set_xy2(id=Globex_line_25, x=CashSessionEndTime, y=Globex_25)
  383. if showLabels
  384. label.set_xy(id=GlobexHighLabel, x=CashSessionEndTime, y=Globex_hi)
  385. label.set_xy(id=Globex75Label, x=CashSessionEndTime, y=Globex_75)
  386. label.set_xy(id=Globex50Label, x=CashSessionEndTime, y=Globex_50)
  387. label.set_xy(id=Globex25Label, x=CashSessionEndTime, y=Globex_25)
  388. label.set_xy(id=GlobexLowLabel, x=CashSessionEndTime, y=Globex_lo)
  389. if (Globex_lo < Globex_lo[1])
  390. Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75
  391. Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5
  392. Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25
  393. if showGlobexDrawings
  394. line.set_xy1(id=Globex_line_lo, x=time, y=Globex_lo)
  395. line.set_xy2(id=Globex_line_lo, x=CashSessionEndTime, y=Globex_lo)
  396. line.set_xy1(id=Globex_line_75, x=GlobexSessionStart, y=Globex_75)
  397. line.set_xy2(id=Globex_line_75, x=CashSessionEndTime, y=Globex_75)
  398. line.set_xy1(id=Globex_line_50, x=GlobexSessionStart, y=Globex_50)
  399. line.set_xy2(id=Globex_line_50, x=CashSessionEndTime, y=Globex_50)
  400. line.set_xy1(id=Globex_line_25, x=GlobexSessionStart, y=Globex_25)
  401. line.set_xy2(id=Globex_line_25, x=CashSessionEndTime, y=Globex_25)
  402. if showLabels
  403. label.set_xy(id=GlobexHighLabel, x=CashSessionEndTime, y=Globex_hi)
  404. label.set_xy(id=Globex75Label, x=CashSessionEndTime, y=Globex_75)
  405. label.set_xy(id=Globex50Label, x=CashSessionEndTime, y=Globex_50)
  406. label.set_xy(id=Globex25Label, x=CashSessionEndTime, y=Globex_25)
  407. label.set_xy(id=GlobexLowLabel, x=CashSessionEndTime, y=Globex_lo)
  408. // END Globex Session Code
  409.  
  410.  
  411. // Begin Asian Session Code
  412. if sessionBegins(i_AsianSession) // When a new Asia Session is started
  413. AsianSessionStart := time // Store the Session Starting timestamp
  414. CashSessionEndTime := timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  415. if CashSessionEndTime < AsianSessionStart // If the CashSessionEndTime is in the past, then add 1 day
  416. CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should
  417. AsianORStart := AsianSessionStart + (i_AsianORoffset * 60000) // Add the offset in milliseconds
  418. AsianOREnd := AsianORStart + 3600000 // Add one hour in milliseconds
  419. Asian_hi := srcHi
  420. Asian_lo := srcLo
  421. Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75
  422. Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5
  423. Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25
  424. if showAsianDrawings
  425. // Keep or Remove all historic levels
  426. if showTodaysDrawings // If true then delete all old objects
  427. line.delete(Asian_line_hi[1])
  428. line.delete(Asian_line_75[1])
  429. line.delete(Asian_line_50[1])
  430. line.delete(Asian_line_25[1])
  431. line.delete(Asian_line_lo[1])
  432. label.delete(AsianHighLabel[1])
  433. label.delete(Asian75Label[1])
  434. label.delete(Asian50Label[1])
  435. label.delete(Asian25Label[1])
  436. label.delete(AsianLowLabel[1])
  437. if showAsianOR // Delete historic Opening Range objects
  438. box.delete(AsianORBox[1])
  439. line.delete(AsianOR_line_hi[1])
  440. line.delete(AsianOR_line_lo[1])
  441. label.delete(AsianORLabelHigh[1])
  442. label.delete(AsianORLabelLow[1])
  443. if showAsianORStdev // Delete historic Opening Range STDEV objects
  444. label.delete(AsianORLabelHigh10[1])
  445. label.delete(AsianORLabelHigh20[1])
  446. label.delete(AsianORLabelHigh30[1])
  447. label.delete(AsianORLabelLow10[1])
  448. label.delete(AsianORLabelLow20[1])
  449. label.delete(AsianORLabelLow30[1])
  450. line.delete(AsianOR_line_hi10[1])
  451. line.delete(AsianOR_line_hi15[1])
  452. line.delete(AsianOR_line_hi175[1])
  453. line.delete(AsianOR_line_hi20[1])
  454. line.delete(AsianOR_line_hi225[1])
  455. line.delete(AsianOR_line_hi25[1])
  456. line.delete(AsianOR_line_hi30[1])
  457. line.delete(AsianOR_line_lo10[1])
  458. line.delete(AsianOR_line_lo15[1])
  459. line.delete(AsianOR_line_lo175[1])
  460. line.delete(AsianOR_line_lo20[1])
  461. line.delete(AsianOR_line_lo225[1])
  462. line.delete(AsianOR_line_lo25[1])
  463. line.delete(AsianOR_line_lo30[1])
  464. // Create new objects for Todays trading
  465. Asian_line_hi := line.new(x1=AsianSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_AsianLevelCol) // Asian High line
  466. Asian_line_75 := line.new(x1=AsianSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_AsianLevelCol) // Asian 75% line
  467. Asian_line_50 := line.new(x1=AsianSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_AsianLevelCol) // Asian 50% line
  468. Asian_line_25 := line.new(x1=AsianSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_AsianLevelCol) // Asian 25% line
  469. Asian_line_lo := line.new(x1=AsianSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_AsianLevelCol) // Asian Low line
  470. AsianHighLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  471. Asian75Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  472. Asian50Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  473. Asian25Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  474. AsianLowLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  475. label.set_tooltip(AsianHighLabel, "Asian High")
  476. label.set_tooltip(Asian75Label, "Asian 75%")
  477. label.set_tooltip(Asian50Label, "Asian 50%")
  478. label.set_tooltip(Asian25Label, "Asian 25%")
  479. label.set_tooltip(AsianLowLabel, "Asian Low")
  480. if showAsianOR
  481. AsianOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range High
  482. AsianOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Low
  483. AsianOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  484. AsianOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  485. AsianOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  486. AsianOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  487. AsianOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  488. AsianOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  489. AsianOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  490. AsianOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  491. AsianOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  492. AsianOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  493. AsianOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  494. AsianOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  495. AsianOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  496. AsianOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  497. AsianORBox := box.new(left=AsianORStart, top=na, right=AsianOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_AsianSessionCol, 100), bgcolor=color.new(i_AsianSessionCol, 70))
  498. AsianORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  499. AsianORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  500. AsianORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  501. AsianORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  502. AsianORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  503. AsianORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  504. AsianORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  505. AsianORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  506. AsianORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  507. else if AsianSession
  508. // We are in allowed AsianSession hours; track hi/lo.
  509. Asian_hi := math.max(srcHi, Asian_hi)
  510. Asian_lo := math.min(srcLo, Asian_lo)
  511. if (Asian_hi > Asian_hi[1])
  512. Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75
  513. Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5
  514. Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25
  515. if showAsianOR and time <= AsianOREnd
  516. // Plot the 1st Hour Box
  517. box.set_lefttop(id=AsianORBox, left=AsianORStart, top=Asian_hi)
  518. box.set_rightbottom(id=AsianORBox, right=AsianOREnd, bottom=Asian_lo)
  519. // Plot the 1st Hour hi/low Levels
  520. line.set_xy1(id=AsianOR_line_hi, x=AsianORStart, y=Asian_hi)
  521. line.set_xy2(id=AsianOR_line_hi, x=CashSessionEndTime, y=Asian_hi)
  522. line.set_xy1(id=AsianOR_line_lo, x=AsianORStart, y=Asian_lo)
  523. line.set_xy2(id=AsianOR_line_lo, x=CashSessionEndTime, y=Asian_lo)
  524. if showLabels
  525. label.set_text(id=AsianORLabelHigh, text="OR High")
  526. label.set_xy(id=AsianORLabelHigh, x=CashSessionEndTime, y=Asian_hi)
  527. label.set_text(id=AsianORLabelLow, text="OR Low")
  528. label.set_xy(id=AsianORLabelLow, x=CashSessionEndTime, y=Asian_lo)
  529. if showAsianDrawings
  530. line.set_xy1(id=Asian_line_hi, x=time, y=Asian_hi)
  531. line.set_xy2(id=Asian_line_hi, x=CashSessionEndTime, y=Asian_hi)
  532. line.set_xy1(id=Asian_line_75, x=AsianSessionStart, y=Asian_75)
  533. line.set_xy2(id=Asian_line_75, x=CashSessionEndTime, y=Asian_75)
  534. line.set_xy1(id=Asian_line_50, x=AsianSessionStart, y=Asian_50)
  535. line.set_xy2(id=Asian_line_50, x=CashSessionEndTime, y=Asian_50)
  536. line.set_xy1(id=Asian_line_25, x=AsianSessionStart, y=Asian_25)
  537. line.set_xy2(id=Asian_line_25, x=CashSessionEndTime, y=Asian_25)
  538. if showLabels
  539. label.set_xy(id=AsianHighLabel, x=CashSessionEndTime, y=Asian_hi)
  540. label.set_xy(id=Asian75Label, x=CashSessionEndTime, y=Asian_75)
  541. label.set_xy(id=Asian50Label, x=CashSessionEndTime, y=Asian_50)
  542. label.set_xy(id=Asian25Label, x=CashSessionEndTime, y=Asian_25)
  543. label.set_xy(id=AsianLowLabel, x=CashSessionEndTime, y=Asian_lo)
  544. if (Asian_lo < Asian_lo[1])
  545. Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75
  546. Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5
  547. Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25
  548. if showAsianOR and time <= AsianOREnd
  549. // Plot the 1st Hour Box
  550. box.set_lefttop(id=AsianORBox, left=AsianORStart, top=Asian_hi)
  551. box.set_rightbottom(id=AsianORBox, right=AsianOREnd, bottom=Asian_lo)
  552. // Plot the 1st Hour hi/low Levels
  553. line.set_xy1(id=AsianOR_line_hi, x=AsianORStart, y=Asian_hi)
  554. line.set_xy2(id=AsianOR_line_hi, x=CashSessionEndTime, y=Asian_hi)
  555. line.set_xy1(id=AsianOR_line_lo, x=AsianORStart, y=Asian_lo)
  556. line.set_xy2(id=AsianOR_line_lo, x=CashSessionEndTime, y=Asian_lo)
  557. if showLabels
  558. label.set_text(id=AsianORLabelHigh, text="OR High")
  559. label.set_xy(id=AsianORLabelHigh, x=CashSessionEndTime, y=Asian_hi)
  560. label.set_text(id=AsianORLabelLow, text="OR Low")
  561. label.set_xy(id=AsianORLabelLow, x=CashSessionEndTime, y=Asian_lo)
  562. if showAsianDrawings
  563. line.set_xy1(id=Asian_line_lo, x=time, y=Asian_lo)
  564. line.set_xy2(id=Asian_line_lo, x=CashSessionEndTime, y=Asian_lo)
  565. line.set_xy1(id=Asian_line_75, x=AsianSessionStart, y=Asian_75)
  566. line.set_xy2(id=Asian_line_75, x=CashSessionEndTime, y=Asian_75)
  567. line.set_xy1(id=Asian_line_50, x=AsianSessionStart, y=Asian_50)
  568. line.set_xy2(id=Asian_line_50, x=CashSessionEndTime, y=Asian_50)
  569. line.set_xy1(id=Asian_line_25, x=AsianSessionStart, y=Asian_25)
  570. line.set_xy2(id=Asian_line_25, x=CashSessionEndTime, y=Asian_25)
  571. if showLabels
  572. label.set_xy(id=AsianHighLabel, x=CashSessionEndTime, y=Asian_hi)
  573. label.set_xy(id=Asian75Label, x=CashSessionEndTime, y=Asian_75)
  574. label.set_xy(id=Asian50Label, x=CashSessionEndTime, y=Asian_50)
  575. label.set_xy(id=Asian25Label, x=CashSessionEndTime, y=Asian_25)
  576. label.set_xy(id=AsianLowLabel, x=CashSessionEndTime, y=Asian_lo)
  577. if showAsianOR and time == AsianOREnd and showAsianORStdev // (At the exact end of Asian OR, calculate and draw the STDev levels )
  578. // Plot the Positive IB STDEVs
  579. line.set_xy1(id=AsianOR_line_hi10, x=AsianOREnd+1800000, y=Asian_hi+(Asian_hi-Asian_lo))
  580. line.set_xy2(id=AsianOR_line_hi10, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo))
  581. line.set_xy1(id=AsianOR_line_hi15, x=AsianOREnd+3600000, y=Asian_hi+(Asian_hi-Asian_lo)*1.5)
  582. line.set_xy2(id=AsianOR_line_hi15, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*1.5)
  583. line.set_xy1(id=AsianOR_line_hi175, x=AsianOREnd+5000000, y=Asian_hi+(Asian_hi-Asian_lo)*1.75)
  584. line.set_xy2(id=AsianOR_line_hi175, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*1.75)
  585. line.set_xy1(id=AsianOR_line_hi20, x=AsianOREnd+7200000, y=Asian_hi+(Asian_hi-Asian_lo)*2)
  586. line.set_xy2(id=AsianOR_line_hi20, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*2)
  587. line.set_xy1(id=AsianOR_line_hi225, x=AsianOREnd+8800000, y=Asian_hi+(Asian_hi-Asian_lo)*2.25)
  588. line.set_xy2(id=AsianOR_line_hi225, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*2.25)
  589. line.set_xy1(id=AsianOR_line_hi25, x=AsianOREnd+10800000, y=Asian_hi+(Asian_hi-Asian_lo)*2.5)
  590. line.set_xy2(id=AsianOR_line_hi25, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*2.5)
  591. line.set_xy1(id=AsianOR_line_hi30, x=AsianOREnd+12800000, y=Asian_hi+(Asian_hi-Asian_lo)*3)
  592. line.set_xy2(id=AsianOR_line_hi30, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*3)
  593. // Plot the Negative IB STDEVs
  594. line.set_xy1(id=AsianOR_line_lo10, x=AsianOREnd+1800000, y=Asian_lo-(Asian_hi-Asian_lo))
  595. line.set_xy2(id=AsianOR_line_lo10, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo))
  596. line.set_xy1(id=AsianOR_line_lo15, x=AsianOREnd+3600000, y=Asian_lo-(Asian_hi-Asian_lo)*1.5)
  597. line.set_xy2(id=AsianOR_line_lo15, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*1.5)
  598. line.set_xy1(id=AsianOR_line_lo175, x=AsianOREnd+5000000, y=Asian_lo-(Asian_hi-Asian_lo)*1.75)
  599. line.set_xy2(id=AsianOR_line_lo175, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*1.75)
  600. line.set_xy1(id=AsianOR_line_lo20, x=AsianOREnd+7200000, y=Asian_lo-(Asian_hi-Asian_lo)*2)
  601. line.set_xy2(id=AsianOR_line_lo20, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*2)
  602. line.set_xy1(id=AsianOR_line_lo225, x=AsianOREnd+8800000, y=Asian_lo-(Asian_hi-Asian_lo)*2.25)
  603. line.set_xy2(id=AsianOR_line_lo225, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*2.25)
  604. line.set_xy1(id=AsianOR_line_lo25, x=AsianOREnd+10800000, y=Asian_lo-(Asian_hi-Asian_lo)*2.5)
  605. line.set_xy2(id=AsianOR_line_lo25, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*2.5)
  606. line.set_xy1(id=AsianOR_line_lo30, x=AsianOREnd+12800000, y=Asian_lo-(Asian_hi-Asian_lo)*3)
  607. line.set_xy2(id=AsianOR_line_lo30, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*3)
  608. // Plot the IB STDEV Labels
  609. if showLabels
  610. label.set_text(id=AsianORLabelHigh10, text="1.0 OR")
  611. label.set_xy(id=AsianORLabelHigh10, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo))
  612. label.set_text(id=AsianORLabelHigh20, text="2.0 OR")
  613. label.set_xy(id=AsianORLabelHigh20, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*2)
  614. label.set_text(id=AsianORLabelHigh30, text="3.0 OR")
  615. label.set_xy(id=AsianORLabelHigh30, x=CashSessionEndTime, y=Asian_hi+(Asian_hi-Asian_lo)*3)
  616. label.set_text(id=AsianORLabelLow10, text="-1.0 OR")
  617. label.set_xy(id=AsianORLabelLow10, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo))
  618. label.set_text(id=AsianORLabelLow20, text="-2.0 OR")
  619. label.set_xy(id=AsianORLabelLow20, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*2)
  620. label.set_text(id=AsianORLabelLow30, text="-3.0 OR")
  621. label.set_xy(id=AsianORLabelLow30, x=CashSessionEndTime, y=Asian_lo-(Asian_hi-Asian_lo)*3)
  622. // END Asian Session Code
  623. // ***
  624.  
  625. // Begin London Session Code
  626. if sessionBegins(i_LondonSession) // When a new London Session is started
  627. LondonSessionStart := time // Store the Session Starting timestamp
  628. CashSessionEndTime := timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  629. if CashSessionEndTime < LondonSessionStart // If the CashSessionEndTime is in the past, then add 1 day
  630. CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should
  631. LondonORStart := LondonSessionStart + (i_LondonORoffset * 60000) // Add the offset in milliseconds
  632. LondonOREnd := LondonORStart + 3600000 // Add one hour in milliseconds
  633. // We are entering London Session hours; reset hi/lo.
  634. London_hi := srcHi
  635. London_lo := srcLo
  636. London_75 := London_lo+(London_hi-London_lo)*0.75
  637. London_50 := London_lo+(London_hi-London_lo)*0.5
  638. London_25 := London_lo+(London_hi-London_lo)*0.25
  639. if showLondonDrawings
  640. // Keep or Remove all historic levels
  641. if showTodaysDrawings // If true then delete all old objects
  642. line.delete(London_line_hi[1])
  643. line.delete(London_line_75[1])
  644. line.delete(London_line_50[1])
  645. line.delete(London_line_25[1])
  646. line.delete(London_line_lo[1])
  647. label.delete(LondonHighLabel[1])
  648. label.delete(London75Label[1])
  649. label.delete(London50Label[1])
  650. label.delete(London25Label[1])
  651. label.delete(LondonLowLabel[1])
  652. if showLondonOR // Delete historic Opening Range objects
  653. box.delete(LondonORBox[1])
  654. line.delete(LondonOR_line_hi[1])
  655. line.delete(LondonOR_line_lo[1])
  656. label.delete(LondonORLabelHigh[1])
  657. label.delete(LondonORLabelLow[1])
  658. if showLondonORStdev // Delete historic Opening Range STDEV objects
  659. label.delete(LondonORLabelHigh10[1])
  660. label.delete(LondonORLabelHigh20[1])
  661. label.delete(LondonORLabelHigh30[1])
  662. label.delete(LondonORLabelLow10[1])
  663. label.delete(LondonORLabelLow20[1])
  664. label.delete(LondonORLabelLow30[1])
  665. line.delete(LondonOR_line_hi10[1])
  666. line.delete(LondonOR_line_hi15[1])
  667. line.delete(LondonOR_line_hi175[1])
  668. line.delete(LondonOR_line_hi20[1])
  669. line.delete(LondonOR_line_hi225[1])
  670. line.delete(LondonOR_line_hi25[1])
  671. line.delete(LondonOR_line_hi30[1])
  672. line.delete(LondonOR_line_lo10[1])
  673. line.delete(LondonOR_line_lo15[1])
  674. line.delete(LondonOR_line_lo175[1])
  675. line.delete(LondonOR_line_lo20[1])
  676. line.delete(LondonOR_line_lo225[1])
  677. line.delete(LondonOR_line_lo25[1])
  678. line.delete(LondonOR_line_lo30[1])
  679. // Create the new objects for Todays session
  680. London_line_hi := line.new(x1=LondonSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_LondonLevelCol) // London High line
  681. London_line_75 := line.new(x1=LondonSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_LondonLevelCol) // London 75% line
  682. London_line_50 := line.new(x1=LondonSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_LondonLevelCol) // London 50% line
  683. London_line_25 := line.new(x1=LondonSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_LondonLevelCol) // London 25% line
  684. London_line_lo := line.new(x1=LondonSessionStart, y1=close[1], x2=CashSessionEndTime, xloc=xloc.bar_time, y2=close[1], color=i_LondonLevelCol) // London Low line
  685. LondonHighLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  686. London75Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  687. London50Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  688. London25Label := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  689. LondonLowLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  690. label.set_tooltip(LondonHighLabel, "London High")
  691. label.set_tooltip(London75Label, "London 75%")
  692. label.set_tooltip(London50Label, "London 50%")
  693. label.set_tooltip(London25Label, "London 25%")
  694. label.set_tooltip(LondonLowLabel, "London Low")
  695. if showLondonOR
  696. // The London 1st hour Opening Range initialization
  697. LondonOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range High
  698. LondonOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Low
  699. LondonOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  700. LondonOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  701. LondonOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  702. LondonOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  703. LondonOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  704. LondonOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  705. LondonOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  706. LondonOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  707. LondonOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  708. LondonOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  709. LondonOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  710. LondonOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  711. LondonOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  712. LondonOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  713. LondonORBox := box.new(left=LondonORStart, top=na, right=LondonOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_LondonSessionCol, 100), bgcolor=color.new(i_LondonSessionCol, 70))
  714. LondonORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  715. LondonORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  716. LondonORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  717. LondonORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  718. LondonORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  719. LondonORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  720. LondonORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  721. LondonORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  722. LondonORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  723. else if LondonSession
  724. // We are in allowed LondonSession hours; track hi/lo.
  725. London_hi := math.max(srcHi, London_hi)
  726. London_lo := math.min(srcLo, London_lo)
  727. if (London_hi > London_hi[1])
  728. London_75 := London_lo+(London_hi-London_lo)*0.75
  729. London_50 := London_lo+(London_hi-London_lo)*0.5
  730. London_25 := London_lo+(London_hi-London_lo)*0.25
  731. if showLondonOR and time <= LondonOREnd
  732. // Plot the 1st Hour Box
  733. box.set_lefttop(id=LondonORBox, left=LondonORStart, top=London_hi)
  734. box.set_rightbottom(id=LondonORBox, right=LondonOREnd, bottom=London_lo)
  735. // Plot the 1st Hour hi/low Levels
  736. line.set_xy1(id=LondonOR_line_hi, x=LondonORStart, y=London_hi)
  737. line.set_xy2(id=LondonOR_line_hi, x=CashSessionEndTime, y=London_hi)
  738. line.set_xy1(id=LondonOR_line_lo, x=LondonORStart, y=London_lo)
  739. line.set_xy2(id=LondonOR_line_lo, x=CashSessionEndTime, y=London_lo)
  740. if showLabels
  741. label.set_text(id=LondonORLabelHigh, text="OR High")
  742. label.set_xy(id=LondonORLabelHigh, x=CashSessionEndTime, y=London_hi)
  743. label.set_text(id=LondonORLabelLow, text="OR Low")
  744. label.set_xy(id=LondonORLabelLow, x=CashSessionEndTime, y=London_lo)
  745. if showLondonDrawings
  746. line.set_xy1(id=London_line_hi, x=time, y=London_hi)
  747. line.set_xy2(id=London_line_hi, x=CashSessionEndTime, y=London_hi)
  748. line.set_xy1(id=London_line_75, x=LondonSessionStart, y=London_75)
  749. line.set_xy2(id=London_line_75, x=CashSessionEndTime, y=London_75)
  750. line.set_xy1(id=London_line_50, x=LondonSessionStart, y=London_50)
  751. line.set_xy2(id=London_line_50, x=CashSessionEndTime, y=London_50)
  752. line.set_xy1(id=London_line_25, x=LondonSessionStart, y=London_25)
  753. line.set_xy2(id=London_line_25, x=CashSessionEndTime, y=London_25)
  754. if showLabels
  755. label.set_xy(id=LondonHighLabel, x=CashSessionEndTime, y=London_hi)
  756. label.set_xy(id=London75Label, x=CashSessionEndTime, y=London_75)
  757. label.set_xy(id=London50Label, x=CashSessionEndTime, y=London_50)
  758. label.set_xy(id=London25Label, x=CashSessionEndTime, y=London_25)
  759. label.set_xy(id=LondonLowLabel, x=CashSessionEndTime, y=London_lo)
  760. if (London_lo < London_lo[1])
  761. London_75 := London_lo+(London_hi-London_lo)*0.75
  762. London_50 := London_lo+(London_hi-London_lo)*0.5
  763. London_25 := London_lo+(London_hi-London_lo)*0.25
  764. if showLondonOR and time <= LondonOREnd
  765. // Plot the 1st Hour Box
  766. box.set_lefttop(id=LondonORBox, left=LondonORStart, top=London_hi)
  767. box.set_rightbottom(id=LondonORBox, right=LondonOREnd, bottom=London_lo)
  768. // Plot the 1st Hour hi/low Levels
  769. line.set_xy1(id=LondonOR_line_hi, x=LondonORStart, y=London_hi)
  770. line.set_xy2(id=LondonOR_line_hi, x=CashSessionEndTime, y=London_hi)
  771. line.set_xy1(id=LondonOR_line_lo, x=LondonORStart, y=London_lo)
  772. line.set_xy2(id=LondonOR_line_lo, x=CashSessionEndTime, y=London_lo)
  773. if showLabels
  774. label.set_text(id=LondonORLabelHigh, text="OR High")
  775. label.set_xy(id=LondonORLabelHigh, x=CashSessionEndTime, y=London_hi)
  776. label.set_text(id=LondonORLabelLow, text="OR Low")
  777. label.set_xy(id=LondonORLabelLow, x=CashSessionEndTime, y=London_lo)
  778. if showLondonDrawings
  779. line.set_xy1(id=London_line_lo, x=time, y=London_lo)
  780. line.set_xy2(id=London_line_lo, x=CashSessionEndTime, y=London_lo)
  781. line.set_xy1(id=London_line_75, x=LondonSessionStart, y=London_75)
  782. line.set_xy2(id=London_line_75, x=CashSessionEndTime, y=London_75)
  783. line.set_xy1(id=London_line_50, x=LondonSessionStart, y=London_50)
  784. line.set_xy2(id=London_line_50, x=CashSessionEndTime, y=London_50)
  785. line.set_xy1(id=London_line_25, x=LondonSessionStart, y=London_25)
  786. line.set_xy2(id=London_line_25, x=CashSessionEndTime, y=London_25)
  787. if showLabels
  788. label.set_xy(id=LondonHighLabel, x=CashSessionEndTime, y=London_hi)
  789. label.set_xy(id=London75Label, x=CashSessionEndTime, y=London_75)
  790. label.set_xy(id=London50Label, x=CashSessionEndTime, y=London_50)
  791. label.set_xy(id=London25Label, x=CashSessionEndTime, y=London_25)
  792. label.set_xy(id=LondonLowLabel, x=CashSessionEndTime, y=London_lo)
  793. if showLondonOR and time == LondonOREnd and showLondonORStdev // (At the exact end of London OR, calculate and draw the STDev levels )
  794. // Plot the Positive IB STDEVs
  795. line.set_xy1(id=LondonOR_line_hi10, x=LondonOREnd+1800000, y=London_hi+(London_hi-London_lo))
  796. line.set_xy2(id=LondonOR_line_hi10, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo))
  797. line.set_xy1(id=LondonOR_line_hi15, x=LondonOREnd+3600000, y=London_hi+(London_hi-London_lo)*1.5)
  798. line.set_xy2(id=LondonOR_line_hi15, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*1.5)
  799. line.set_xy1(id=LondonOR_line_hi175, x=LondonOREnd+5000000, y=London_hi+(London_hi-London_lo)*1.75)
  800. line.set_xy2(id=LondonOR_line_hi175, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*1.75)
  801. line.set_xy1(id=LondonOR_line_hi20, x=LondonOREnd+7200000, y=London_hi+(London_hi-London_lo)*2)
  802. line.set_xy2(id=LondonOR_line_hi20, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*2)
  803. line.set_xy1(id=LondonOR_line_hi225, x=LondonOREnd+8800000, y=London_hi+(London_hi-London_lo)*2.25)
  804. line.set_xy2(id=LondonOR_line_hi225, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*2.25)
  805. line.set_xy1(id=LondonOR_line_hi25, x=LondonOREnd+10800000, y=London_hi+(London_hi-London_lo)*2.5)
  806. line.set_xy2(id=LondonOR_line_hi25, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*2.5)
  807. line.set_xy1(id=LondonOR_line_hi30, x=LondonOREnd+12800000, y=London_hi+(London_hi-London_lo)*3)
  808. line.set_xy2(id=LondonOR_line_hi30, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*3)
  809. // Plot the Negative IB STDEVs
  810. line.set_xy1(id=LondonOR_line_lo10, x=LondonOREnd+1800000, y=London_lo-(London_hi-London_lo))
  811. line.set_xy2(id=LondonOR_line_lo10, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo))
  812. line.set_xy1(id=LondonOR_line_lo15, x=LondonOREnd+3600000, y=London_lo-(London_hi-London_lo)*1.5)
  813. line.set_xy2(id=LondonOR_line_lo15, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*1.5)
  814. line.set_xy1(id=LondonOR_line_lo175, x=LondonOREnd+5000000, y=London_lo-(London_hi-London_lo)*1.75)
  815. line.set_xy2(id=LondonOR_line_lo175, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*1.75)
  816. line.set_xy1(id=LondonOR_line_lo20, x=LondonOREnd+7200000, y=London_lo-(London_hi-London_lo)*2)
  817. line.set_xy2(id=LondonOR_line_lo20, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*2)
  818. line.set_xy1(id=LondonOR_line_lo225, x=LondonOREnd+8800000, y=London_lo-(London_hi-London_lo)*2.25)
  819. line.set_xy2(id=LondonOR_line_lo225, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*2.25)
  820. line.set_xy1(id=LondonOR_line_lo25, x=LondonOREnd+10800000, y=London_lo-(London_hi-London_lo)*2.5)
  821. line.set_xy2(id=LondonOR_line_lo25, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*2.5)
  822. line.set_xy1(id=LondonOR_line_lo30, x=LondonOREnd+12800000, y=London_lo-(London_hi-London_lo)*3)
  823. line.set_xy2(id=LondonOR_line_lo30, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*3)
  824. // Plot the IB STDEV Labels
  825. if showLabels
  826. label.set_text(id=LondonORLabelHigh10, text="1.0 OR")
  827. label.set_xy(id=LondonORLabelHigh10, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo))
  828. label.set_text(id=LondonORLabelHigh20, text="2.0 OR")
  829. label.set_xy(id=LondonORLabelHigh20, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*2)
  830. label.set_text(id=LondonORLabelHigh30, text="3.0 OR")
  831. label.set_xy(id=LondonORLabelHigh30, x=CashSessionEndTime, y=London_hi+(London_hi-London_lo)*3)
  832. label.set_text(id=LondonORLabelLow10, text="-1.0 OR")
  833. label.set_xy(id=LondonORLabelLow10, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo))
  834. label.set_text(id=LondonORLabelLow20, text="-2.0 OR")
  835. label.set_xy(id=LondonORLabelLow20, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*2)
  836. label.set_text(id=LondonORLabelLow30, text="-3.0 OR")
  837. label.set_xy(id=LondonORLabelLow30, x=CashSessionEndTime, y=London_lo-(London_hi-London_lo)*3)
  838. // END London Session Code
  839. // ***
  840.  
  841. // Begin NewYork Session Code
  842. if sessionBegins(i_NewYorkSession) // When a new NewYork Session is started
  843. NewYorkSessionStart := time // Store the Session Starting timestamp
  844. CashSessionEndTime := timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  845. if CashSessionEndTime < NewYorkSessionStart // If the CashSessionEndTime is in the past, then add 1 day
  846. CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should
  847. NewYorkORStart := NewYorkSessionStart + (i_NewYorkORoffset * 60000) // Add the offset in milliseconds
  848. NewYorkOREnd := NewYorkORStart + 3600000 // Add one hour in milliseconds
  849. // We are entering NewYork Session hours; reset hi/lo.
  850. NewYork_hi := srcHi
  851. NewYork_lo := srcLo
  852. NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75
  853. NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5
  854. NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25
  855. // Initialize the drawings for today
  856. if showNewYorkDrawings
  857. // Keep or Remove all historic levels
  858. if showTodaysDrawings // If true then delete all old objects
  859. line.delete(NewYork_line_hi[1])
  860. line.delete(NewYork_line_75[1])
  861. line.delete(NewYork_line_50[1])
  862. line.delete(NewYork_line_25[1])
  863. line.delete(NewYork_line_lo[1])
  864. label.delete(NewYorkHighLabel[1])
  865. label.delete(NewYork75Label[1])
  866. label.delete(NewYork50Label[1])
  867. label.delete(NewYork25Label[1])
  868. label.delete(NewYorkLowLabel[1])
  869. if showNewYorkOR // Delete historic Opening Range objects
  870. box.delete(NewYorkORBox[1])
  871. line.delete(NewYorkOR_line_hi[1])
  872. line.delete(NewYorkOR_line_mid[1])
  873. line.delete(NewYorkOR_line_lo[1])
  874. label.delete(NewYorkORLabelHigh[1])
  875. label.delete(NewYorkORLabelLow[1])
  876. label.delete(NewYorkORLabelMid[1])
  877. if showNewYorkORStdev // Delete historic Opening Range STDEV objects
  878. label.delete(NewYorkORLabelHigh05[1])
  879. label.delete(NewYorkORLabelHigh10[1])
  880. label.delete(NewYorkORLabelHigh20[1])
  881. label.delete(NewYorkORLabelHigh30[1])
  882. label.delete(NewYorkORLabelLow05[1])
  883. label.delete(NewYorkORLabelLow10[1])
  884. label.delete(NewYorkORLabelLow20[1])
  885. label.delete(NewYorkORLabelLow30[1])
  886. line.delete(NewYorkOR_line_hi05[1])
  887. line.delete(NewYorkOR_line_hi10[1])
  888. line.delete(NewYorkOR_line_hi15[1])
  889. line.delete(NewYorkOR_line_hi175[1])
  890. line.delete(NewYorkOR_line_hi20[1])
  891. line.delete(NewYorkOR_line_hi225[1])
  892. line.delete(NewYorkOR_line_hi25[1])
  893. line.delete(NewYorkOR_line_hi30[1])
  894. line.delete(NewYorkOR_line_lo05[1])
  895. line.delete(NewYorkOR_line_lo10[1])
  896. line.delete(NewYorkOR_line_lo15[1])
  897. line.delete(NewYorkOR_line_lo175[1])
  898. line.delete(NewYorkOR_line_lo20[1])
  899. line.delete(NewYorkOR_line_lo225[1])
  900. line.delete(NewYorkOR_line_lo25[1])
  901. line.delete(NewYorkOR_line_lo30[1])
  902. // Create new objects for today
  903. NewYork_line_hi := line.new(x1=NewYorkSessionStart, y1=NewYork_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_hi, color=i_NYLevelCol) // NewYork High line
  904. NewYork_line_75 := line.new(x1=NewYorkSessionStart, y1=NewYork_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_75, color=i_NYLevelCol) // NewYork 75% line
  905. NewYork_line_50 := line.new(x1=NewYorkSessionStart, y1=NewYork_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_50, color=i_NYLevelCol) // NewYork 50% line
  906. NewYork_line_25 := line.new(x1=NewYorkSessionStart, y1=NewYork_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_25, color=i_NYLevelCol) // NewYork 25% line
  907. NewYork_line_lo := line.new(x1=NewYorkSessionStart, y1=NewYork_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_lo, color=i_NYLevelCol) // NewYork Low line
  908. NewYorkHighLabel := label.new(x=NewYorkSessionStart, y=NewYork_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  909. NewYork75Label := label.new(x=NewYorkSessionStart, y=NewYork_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  910. NewYork50Label := label.new(x=NewYorkSessionStart, y=NewYork_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  911. NewYork25Label := label.new(x=NewYorkSessionStart, y=NewYork_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  912. NewYorkLowLabel := label.new(x=NewYorkSessionStart, y=NewYork_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  913. label.set_tooltip(NewYorkHighLabel, "New York High")
  914. label.set_tooltip(NewYork75Label, "New York 75%")
  915. label.set_tooltip(NewYork50Label, "New York 50%")
  916. label.set_tooltip(NewYork25Label, "New York 25%")
  917. label.set_tooltip(NewYorkLowLabel,"New York Low")
  918. if showNewYorkOR
  919. // The NewYork 1st hour Opening Range initialization
  920. NewYorkOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range High
  921. NewYorkOR_line_mid := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Middle
  922. NewYorkOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Low
  923. NewYorkORBox := box.new(left=NewYorkORStart, top=na, right=NewYorkOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_NYSessionCol, 100), bgcolor=color.new(i_NYSessionCol, 70))
  924. //NewYorkORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  925. NewYorkORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  926. NewYorkORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  927. NewYorkORLabelMid := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  928. if showNewYorkORStdev
  929. NewYorkOR_line_hi05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR
  930. NewYorkOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR
  931. NewYorkOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR
  932. NewYorkOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR
  933. NewYorkOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR
  934. NewYorkOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR
  935. NewYorkOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR
  936. NewYorkOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR
  937. NewYorkOR_line_lo05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR
  938. NewYorkOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR
  939. NewYorkOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR
  940. NewYorkOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR
  941. NewYorkOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR
  942. NewYorkOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR
  943. NewYorkOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR
  944. NewYorkOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR
  945. NewYorkORLabelHigh05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  946. NewYorkORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  947. NewYorkORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  948. NewYorkORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  949. NewYorkORLabelLow05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  950. NewYorkORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  951. NewYorkORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  952. NewYorkORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  953. else if NewYorkSession
  954. // We are in allowed NewYorkSession hours; track hi/lo.
  955. NewYork_hi := math.max(srcHi, NewYork_hi)
  956. NewYork_lo := math.min(srcLo, NewYork_lo)
  957. if (NewYork_hi > NewYork_hi[1])
  958. NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75
  959. NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5
  960. NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25
  961. if showNewYorkOR and time <= NewYorkOREnd
  962. // Store the OR High and 50% - Needed for Alerts
  963. NewYorkHr1hi := NewYork_hi
  964. NewYorkHr1mid := NewYork_50
  965. // Plot the 1st Hour Box
  966. box.set_lefttop(id=NewYorkORBox, left=NewYorkORStart, top=NewYork_hi)
  967. box.set_rightbottom(id=NewYorkORBox, right=NewYorkOREnd, bottom=NewYork_lo)
  968. // Plot the 1st Hour hi/low Levels
  969. line.set_xy1(id=NewYorkOR_line_hi, x=NewYorkORStart, y=NewYork_hi)
  970. line.set_xy2(id=NewYorkOR_line_hi, x=CashSessionEndTime, y=NewYork_hi)
  971. line.set_xy1(id=NewYorkOR_line_mid, x=NewYorkORStart+(time-NewYorkORStart), y=NewYork_50)
  972. line.set_xy2(id=NewYorkOR_line_mid, x=CashSessionEndTime, y=NewYork_50)
  973. line.set_xy1(id=NewYorkOR_line_lo, x=NewYorkORStart, y=NewYork_lo)
  974. line.set_xy2(id=NewYorkOR_line_lo, x=CashSessionEndTime, y=NewYork_lo)
  975. if showLabels
  976. label.set_text(id=NewYorkORLabelHigh, text="OR High")
  977. label.set_xy(id=NewYorkORLabelHigh, x=CashSessionEndTime, y=NewYork_hi)
  978. label.set_text(id=NewYorkORLabelMid, text="OR 50%")
  979. label.set_xy(id=NewYorkORLabelMid, x=CashSessionEndTime, y=NewYork_50)
  980. label.set_text(id=NewYorkORLabelLow, text="OR Low")
  981. label.set_xy(id=NewYorkORLabelLow, x=CashSessionEndTime, y=NewYork_lo)
  982. if showNewYorkDrawings
  983. line.set_xy1(id=NewYork_line_hi, x=time, y=NewYork_hi)
  984. line.set_xy2(id=NewYork_line_hi, x=CashSessionEndTime, y=NewYork_hi)
  985. line.set_xy1(id=NewYork_line_75, x=NewYorkSessionStart, y=NewYork_75)
  986. line.set_xy2(id=NewYork_line_75, x=CashSessionEndTime, y=NewYork_75)
  987. line.set_xy1(id=NewYork_line_50, x=NewYorkSessionStart, y=NewYork_50)
  988. line.set_xy2(id=NewYork_line_50, x=CashSessionEndTime, y=NewYork_50)
  989. line.set_xy1(id=NewYork_line_25, x=NewYorkSessionStart, y=NewYork_25)
  990. line.set_xy2(id=NewYork_line_25, x=CashSessionEndTime, y=NewYork_25)
  991. if showLabels
  992. label.set_xy(id=NewYorkHighLabel, x=CashSessionEndTime, y=NewYork_hi)
  993. label.set_xy(id=NewYork75Label, x=CashSessionEndTime, y=NewYork_75)
  994. label.set_xy(id=NewYork50Label, x=CashSessionEndTime, y=NewYork_50)
  995. label.set_xy(id=NewYork25Label, x=CashSessionEndTime, y=NewYork_25)
  996. label.set_xy(id=NewYorkLowLabel,x=CashSessionEndTime, y=NewYork_lo)
  997. if (NewYork_lo < NewYork_lo[1])
  998. NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75
  999. NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5
  1000. NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25
  1001. if showNewYorkOR and time <= NewYorkOREnd
  1002. // Store the OR Low and 50% - needed for Alerts
  1003. NewYorkHr1lo := NewYork_lo
  1004. NewYorkHr1mid := NewYork_50
  1005. // Plot the 1st Hour Box
  1006. box.set_lefttop(id=NewYorkORBox, left=NewYorkORStart, top=NewYork_hi)
  1007. box.set_rightbottom(id=NewYorkORBox, right=NewYorkOREnd, bottom=NewYork_lo)
  1008. // Plot the 1st Hour hi/low Levels
  1009. line.set_xy1(id=NewYorkOR_line_hi, x=NewYorkORStart, y=NewYork_hi)
  1010. line.set_xy2(id=NewYorkOR_line_hi, x=CashSessionEndTime, y=NewYork_hi)
  1011. line.set_xy1(id=NewYorkOR_line_mid, x=NewYorkORStart+(time-NewYorkORStart), y=NewYork_50)
  1012. line.set_xy2(id=NewYorkOR_line_mid, x=CashSessionEndTime, y=NewYork_50)
  1013. line.set_xy1(id=NewYorkOR_line_lo, x=NewYorkORStart, y=NewYork_lo)
  1014. line.set_xy2(id=NewYorkOR_line_lo, x=CashSessionEndTime, y=NewYork_lo)
  1015. if showLabels
  1016. label.set_text(id=NewYorkORLabelHigh, text="OR High")
  1017. label.set_xy(id=NewYorkORLabelHigh, x=CashSessionEndTime, y=NewYork_hi)
  1018. label.set_text(id=NewYorkORLabelMid, text="OR 50%")
  1019. label.set_xy(id=NewYorkORLabelMid, x=CashSessionEndTime, y=NewYork_50)
  1020. label.set_text(id=NewYorkORLabelLow, text="OR Low")
  1021. label.set_xy(id=NewYorkORLabelLow, x=CashSessionEndTime, y=NewYork_lo)
  1022. if showNewYorkDrawings
  1023. line.set_xy1(id=NewYork_line_lo, x=time, y=NewYork_lo)
  1024. line.set_xy2(id=NewYork_line_lo, x=CashSessionEndTime, y=NewYork_lo)
  1025. line.set_xy1(id=NewYork_line_75, x=NewYorkSessionStart, y=NewYork_75)
  1026. line.set_xy2(id=NewYork_line_75, x=CashSessionEndTime, y=NewYork_75)
  1027. line.set_xy1(id=NewYork_line_50, x=NewYorkSessionStart, y=NewYork_50)
  1028. line.set_xy2(id=NewYork_line_50, x=CashSessionEndTime, y=NewYork_50)
  1029. line.set_xy1(id=NewYork_line_25, x=NewYorkSessionStart, y=NewYork_25)
  1030. line.set_xy2(id=NewYork_line_25, x=CashSessionEndTime, y=NewYork_25)
  1031. if showLabels
  1032. label.set_xy(id=NewYorkHighLabel, x=CashSessionEndTime, y=NewYork_hi)
  1033. label.set_xy(id=NewYork75Label, x=CashSessionEndTime, y=NewYork_75)
  1034. label.set_xy(id=NewYork50Label, x=CashSessionEndTime, y=NewYork_50)
  1035. label.set_xy(id=NewYork25Label, x=CashSessionEndTime, y=NewYork_25)
  1036. label.set_xy(id=NewYorkLowLabel, x=CashSessionEndTime, y=NewYork_lo)
  1037. if showNewYorkOR and time == NewYorkOREnd and showNewYorkORStdev // (At the exact end of NewYork OR, calculate and draw the STDev levels )
  1038. // Plot the Positive IB STDEVs
  1039. line.set_xy1(id=NewYorkOR_line_hi05, x=NewYorkOREnd+1000000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*0.5)
  1040. line.set_xy2(id=NewYorkOR_line_hi05, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*0.5)
  1041. line.set_xy1(id=NewYorkOR_line_hi10, x=NewYorkOREnd+1800000, y=NewYork_hi+(NewYork_hi-NewYork_lo))
  1042. line.set_xy2(id=NewYorkOR_line_hi10, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo))
  1043. line.set_xy1(id=NewYorkOR_line_hi15, x=NewYorkOREnd+3600000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*1.5)
  1044. line.set_xy2(id=NewYorkOR_line_hi15, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*1.5)
  1045. line.set_xy1(id=NewYorkOR_line_hi175, x=NewYorkOREnd+5000000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*1.75)
  1046. line.set_xy2(id=NewYorkOR_line_hi175, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*1.75)
  1047. line.set_xy1(id=NewYorkOR_line_hi20, x=NewYorkOREnd+7200000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2)
  1048. line.set_xy2(id=NewYorkOR_line_hi20, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2)
  1049. line.set_xy1(id=NewYorkOR_line_hi225, x=NewYorkOREnd+8800000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2.25)
  1050. line.set_xy2(id=NewYorkOR_line_hi225, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2.25)
  1051. line.set_xy1(id=NewYorkOR_line_hi25, x=NewYorkOREnd+10800000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2.5)
  1052. line.set_xy2(id=NewYorkOR_line_hi25, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2.5)
  1053. line.set_xy1(id=NewYorkOR_line_hi30, x=NewYorkOREnd+12800000, y=NewYork_hi+(NewYork_hi-NewYork_lo)*3)
  1054. line.set_xy2(id=NewYorkOR_line_hi30, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*3)
  1055. // Plot the Negative IB STDEVs
  1056. line.set_xy1(id=NewYorkOR_line_lo05, x=NewYorkOREnd+1000000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*0.5)
  1057. line.set_xy2(id=NewYorkOR_line_lo05, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*0.5)
  1058. line.set_xy1(id=NewYorkOR_line_lo10, x=NewYorkOREnd+1800000, y=NewYork_lo-(NewYork_hi-NewYork_lo))
  1059. line.set_xy2(id=NewYorkOR_line_lo10, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo))
  1060. line.set_xy1(id=NewYorkOR_line_lo15, x=NewYorkOREnd+3600000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*1.5)
  1061. line.set_xy2(id=NewYorkOR_line_lo15, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*1.5)
  1062. line.set_xy1(id=NewYorkOR_line_lo175, x=NewYorkOREnd+5000000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*1.75)
  1063. line.set_xy2(id=NewYorkOR_line_lo175, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*1.75)
  1064. line.set_xy1(id=NewYorkOR_line_lo20, x=NewYorkOREnd+7200000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2)
  1065. line.set_xy2(id=NewYorkOR_line_lo20, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2)
  1066. line.set_xy1(id=NewYorkOR_line_lo225, x=NewYorkOREnd+8800000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2.25)
  1067. line.set_xy2(id=NewYorkOR_line_lo225, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2.25)
  1068. line.set_xy1(id=NewYorkOR_line_lo25, x=NewYorkOREnd+10800000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2.5)
  1069. line.set_xy2(id=NewYorkOR_line_lo25, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2.5)
  1070. line.set_xy1(id=NewYorkOR_line_lo30, x=NewYorkOREnd+12800000, y=NewYork_lo-(NewYork_hi-NewYork_lo)*3)
  1071. line.set_xy2(id=NewYorkOR_line_lo30, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*3)
  1072. // Plot the IB STDEV Labels
  1073. if showLabels
  1074. label.set_text(id=NewYorkORLabelHigh05, text="0.5 OR")
  1075. label.set_xy(id=NewYorkORLabelHigh05, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)/2)
  1076. label.set_text(id=NewYorkORLabelHigh10, text="1.0 OR")
  1077. label.set_xy(id=NewYorkORLabelHigh10, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo))
  1078. label.set_text(id=NewYorkORLabelHigh20, text="2.0 OR")
  1079. label.set_xy(id=NewYorkORLabelHigh20, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*2)
  1080. label.set_text(id=NewYorkORLabelHigh30, text="3.0 OR")
  1081. label.set_xy(id=NewYorkORLabelHigh30, x=CashSessionEndTime, y=NewYork_hi+(NewYork_hi-NewYork_lo)*3)
  1082. label.set_text(id=NewYorkORLabelLow05, text="-0.5 OR")
  1083. label.set_xy(id=NewYorkORLabelLow05, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)/2)
  1084. label.set_text(id=NewYorkORLabelLow10, text="-1.0 OR")
  1085. label.set_xy(id=NewYorkORLabelLow10, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo))
  1086. label.set_text(id=NewYorkORLabelLow20, text="-2.0 OR")
  1087. label.set_xy(id=NewYorkORLabelLow20, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*2)
  1088. label.set_text(id=NewYorkORLabelLow30, text="-3.0 OR")
  1089. label.set_xy(id=NewYorkORLabelLow30, x=CashSessionEndTime, y=NewYork_lo-(NewYork_hi-NewYork_lo)*3)
  1090. // END NewYork Session Code
  1091. // ***
  1092.  
  1093. // New York Initial Balance Logic
  1094. // Determine the opening Bar - depending of Resolution
  1095. open_bar = switch timeframe.period
  1096. "5" => time_close(timeframe.period, "0825-0830", "America/Chicago")
  1097. "15" => time_close(timeframe.period, "0815-0830", "America/Chicago")
  1098. "30" => time_close(timeframe.period, "0800-0830", "America/Chicago")
  1099. // End Opening bar code
  1100. // ******
  1101. // End of session code
  1102. // -------------------------------------------------------------------------------
  1103.  
  1104.  
  1105. // Previous Day's Open
  1106. if showPDO and timeframe.isintraday // Plot the Previous Day's Open line and label
  1107. _CashSessionEndTime = timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  1108. var PDOpen_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousDayOpen, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousDayOpen, color=color.orange) // Create the price line of the Previous Days Open
  1109. var PDOLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Create the label for the Previous Days Open line
  1110. line.set_xy1(id=PDOpen_line, x=_CashSessionEndTime-86400000, y=PreviousDayOpen) // Draw the PDO Line from the Previous Day's open to the end of the current session
  1111. line.set_xy2(id=PDOpen_line, x=_CashSessionEndTime, y=PreviousDayOpen) // Draw the PDO Line from the Previous Day's open to the end of the current session
  1112. if showLabels
  1113. label.set_xy(id=PDOLabel, x=_CashSessionEndTime, y=PreviousDayOpen) // PDO Label placement
  1114. label.set_tooltip(PDOLabel, "Previous Day Open: " + str.tostring(PreviousDayOpen)) // PDO Label tooltip with PD Open value
  1115. // END Previous Day's Open
  1116.  
  1117. // Previous Day's Close
  1118. if showPDC and timeframe.isintraday // Plot the Previous Day's Close line and label
  1119. _CashSessionEndTime = timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  1120. var PDClose_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousDayClose, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousDayClose, color=color.orange) // Create the price line of the Previous Days Close
  1121. var PDCLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  1122. line.set_xy1(id=PDClose_line, x=_CashSessionEndTime-86400000, y=PreviousDayClose) // Draw the PDC Line from the Previous Day's close to the end of the current session
  1123. line.set_xy2(id=PDClose_line, x=_CashSessionEndTime, y=PreviousDayClose) // Draw the PDC Line from the Previous Day's close to the end of the current session
  1124. if showLabels
  1125. label.set_xy(id=PDCLabel, x=_CashSessionEndTime, y=PreviousDayClose) // PDC Label placement
  1126. label.set_tooltip(PDCLabel, "Previous Day Close: " + str.tostring(PreviousDayClose)) // PDC Label tooltip with PDC value
  1127. // END Previous Day's Close
  1128.  
  1129. // Previous Week's Open
  1130. if showPWO and timeframe.isintraday // Plot the Previous Week's Open line and label
  1131. _CashSessionEndTime = timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  1132. var PWOpen_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousWeekOpen, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousWeekOpen, color=color.orange) // Create the price line of the Previous Week Open
  1133. var PWOLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Create the label for the Previous Week Open line
  1134. line.set_xy1(id=PWOpen_line, x=_CashSessionEndTime-86400000, y=PreviousWeekOpen) // Draw the PWO Line from the Previous Week's open to the end of the current session
  1135. line.set_xy2(id=PWOpen_line, x=_CashSessionEndTime, y=PreviousWeekOpen) // Draw the PWO Line from the Previous Week's open to the end of the current session
  1136. if showLabels
  1137. label.set_xy(id=PWOLabel, x=_CashSessionEndTime, y=PreviousWeekOpen) // PWO Label placement
  1138. label.set_tooltip(PWOLabel, "Previous Week Open: " + str.tostring(PreviousWeekOpen)) // PWO Label tooltip with CW Open value
  1139. // END Current Week's Open
  1140.  
  1141. // Previous Week's Close
  1142. if showPWC and timeframe.isintraday // Plot the Previous Week's Close line and label
  1143. _CashSessionEndTime = timestamp("America/Chicago", year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines)
  1144. var PWClose_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousWeekClose, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousWeekClose, color=color.orange) // Create the price line of the Previous Weeks Close
  1145. var PWCLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small)
  1146. line.set_xy1(id=PWClose_line, x=_CashSessionEndTime-86400000, y=PreviousWeekClose) // Draw the PWC Line from the Previous Week's close to the end of the current session
  1147. line.set_xy2(id=PWClose_line, x=_CashSessionEndTime, y=PreviousWeekClose) // Draw the PWC Line from the Previous Week's close to the end of the current session
  1148. if showLabels
  1149. label.set_xy(id=PWCLabel, x=_CashSessionEndTime, y=PreviousWeekClose) // PWC Label placement
  1150. label.set_tooltip(PWCLabel, "Previous Week Close: " + str.tostring(PreviousWeekClose)) // PWC Label tooltip with PWC value
  1151. // END Previous Week's Close
  1152.  
  1153.  
  1154. // ALERTS!
  1155. // Check if price crosses key levels and generate alerts
  1156. f_triggerGlobexLow() // Price crosses the Globex Overnight Low level?
  1157. f_triggerGlobexHigh() // Price crosses the Globex Overnight High level?
  1158. f_triggerNewYorkOR50perc() // When the New York Opening Range has ended... check to see if the 50% level is crossed
  1159. f_triggerNewYorkSTDEVpos05() // When the New York Opening Range has ended... check to see if the STDEV 0.5 level is crossed
  1160. f_triggerNewYorkSTDEVpos10() // When the New York Opening Range has ended... check to see if the STDEV 1.0 level is crossed
  1161. f_triggerNewYorkSTDEVneg05() // When the New York Opening Range has ended... check to see if the STDEV -0.5 level is crossed
  1162. f_triggerNewYorkSTDEVneg10() // When the New York Opening Range has ended... check to see if the STDEV -1.0 level is crossed
  1163. // End of Alert section
  1164.  
  1165. // Start Plotting
  1166. bgcolor(showGlobex == true and time == GlobexSession ? color.new(i_GlobexSessionCol,90) : na) // Highlight the Globex (Overnight) Range
  1167. bgcolor(showOpenbar == true and open_bar ? color.new(i_NYSessionCol, 75) : na) // Highlight the Bar before the New York Cash Open
  1168. bgcolor(showAsian == true and time == AsianSession ? color.new(i_AsianSessionCol,90) : na) // Highlight the Asian Range
  1169. bgcolor(showLondon == true and time == LondonSession ? color.new(i_LondonSessionCol,90) : na) // Highlight the London Range
  1170. bgcolor(showNewYork == true and time == NewYorkSession ? color.new(i_NYSessionCol,90) : na) // Highlight the NewYork Range
  1171.  
  1172.  
  1173. // Debug plots
  1174. plot(showDebug ? NewYorkHr1lo : na, title='NewYorkHr1lo', color=color.new(#00ffaa, 70))
  1175. plot(showDebug ? NewYorkHr1mid : na, title='NewYorkHr1mid', color=color.new(#00ffaa, 70))
  1176. plot(showDebug ? NewYorkHr1hi : na, title='NewYorkHr1hi', color=color.new(#00ffaa, 70))
  1177. plot(showDebug ? NewYork_hi : na, title='NewYork_hi', color=color.new(#00ffaa, 70))
  1178. plot(showDebug ? NewYork_lo : na, title='NewYork_lo', color=color.new(#00ffaa, 70))
  1179. plot(showDebug ? (NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)/2) : na, title='NewYorkSTDEVpos05', color=color.new(#00ffaa, 70))
  1180. plot(showDebug ? NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo) : na, title='NewYorkSTDEVpos10', color=color.new(#00ffaa, 70))
  1181. plot(showDebug ? (NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)/2) : na, title='NewYorkSTDEVneg05', color=color.new(#00ffaa, 70))
  1182. plot(showDebug ? NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo) : na, title='NewYorkSTDEVneg10', color=color.new(#00ffaa, 70))
Advertisement
Add Comment
Please, Sign In to add comment