xmd79

ADAM fx-Asian Session Range

Sep 24th, 2022
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 63.58 KB | None | 0 0
  1. //@version=4
  2. study("ADAM fx-Asian Session Range", shorttitle= "ADAMFX asian session range", overlay=true)
  3.  
  4. // Get User Inputs
  5. user_ssth = input(title="Start Session Hour (EST)", defval="20", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  6. user_sstm = input(title="Start Session Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  7.  
  8. user_esth = input(title="End Session Hour (EST)", defval="02", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  9. user_estm = input(title="End Session Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  10.  
  11. user_elth = input(title="Extend Session Lines Until Hour (EST)", defval="11", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  12. user_eltm = input(title="Extend Session Lines Until Minute (EST)", defval="30", options=["00", "15", "30", "45"])
  13.  
  14.  
  15.  
  16. user_box_line_color = input(title="Asian Range Border Color", defval="blue", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  17. boxLineWidth = input(title="Asian Box Line Width", defval=1, minval=0, maxval=10)
  18. user_box_line_style = input(title="Asian Box Line Style", defval="solid", options=["solid", "dashed", "dotted"])
  19.  
  20. sessionLineWidth = input(title="Session High / Low / Mid Line Width", defval=2, minval=0, maxval=20)
  21. user_upperlower_line_style = input(title="Session High / Low Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  22.  
  23. user_midline_color = input(title="Middle Range Line Color", defval="orange", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  24. user_middle_line_style = input(title="Middle Range Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  25.  
  26. user_text_color = input(title="Text Color", defval="blue", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  27. user_label_size = input(title="Text Size", defval="normal", options=["tiny", "small", "normal", "large"])
  28.  
  29.  
  30. // London Session Inputs
  31. show_london_session = input(defval=true, type=input.bool, title="Show London Session Box")
  32. show_london_session_rng = input(defval=true, type=input.bool, title="Show London Session Range Pips")
  33.  
  34.  
  35. london_ssth = input(title="London Start Hour (EST)", defval="03", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  36. london_sstm = input(title="London Start Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  37.  
  38. london_esth = input(title="London End Hour (EST)", defval="07", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  39. london_estm = input(title="London End Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  40.  
  41.  
  42. luser_box_line_color = input(title="London Range Border Color", defval="teal", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  43. lboxLineWidth = input(title="London Box Line Width", defval=1, minval=0, maxval=10)
  44. luser_box_line_style = input(title="London Box Line Style", defval="solid", options=["solid", "dashed", "dotted"])
  45.  
  46. lsessionLineWidth = input(title="Session High / Low / Mid Line Width", defval=2, minval=0, maxval=20)
  47. luser_upperlower_line_style = input(title="Session High / Low Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  48.  
  49. luser_midline_color = input(title="Middle Range Line Color", defval="teal", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  50. luser_middle_line_style = input(title="Middle Range Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  51.  
  52. luser_text_color = input(title="Text Color", defval="teal", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  53. luser_label_size = input(title="Text Size", defval="normal", options=["tiny", "small", "normal", "large"])
  54.  
  55. // End London
  56.  
  57.  
  58. // New York Session Inputs
  59. show_ny_session = input(defval=true, type=input.bool, title="Show New York Session Box")
  60. show_ny_session_rng = input(defval=true, type=input.bool, title="Show New York Session Range Pips")
  61.  
  62. ny_ssth = input(title="New York Start Hour (EST)", defval="08", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  63. ny_sstm = input(title="New York Start Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  64.  
  65. ny_esth = input(title="New York End Hour (EST)", defval="12", options=["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"])
  66. ny_estm = input(title="New York End Minute (EST)", defval="00", options=["00", "15", "30", "45"])
  67.  
  68.  
  69. nuser_box_line_color = input(title="New York Range Border Color", defval="silver", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  70. nboxLineWidth = input(title="New York Box Line Width", defval=1, minval=0, maxval=10)
  71. nuser_box_line_style = input(title="New York Box Line Style", defval="solid", options=["solid", "dashed", "dotted"])
  72.  
  73. nsessionLineWidth = input(title="Session High / Low / Mid Line Width", defval=2, minval=0, maxval=20)
  74. nuser_upperlower_line_style = input(title="Session High / Low Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  75.  
  76. nuser_midline_color = input(title="Middle Range Line Color", defval="silver", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  77. nuser_middle_line_style = input(title="Middle Range Line Style", defval="dotted", options=["solid", "dashed", "dotted"])
  78.  
  79. nuser_text_color = input(title="Text Color", defval="silver", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  80. nuser_label_size = input(title="Text Size", defval="normal", options=["tiny", "small", "normal", "large"])
  81.  
  82. showADR = input(defval=true, type=input.bool, title="Show Average Daily Range")
  83. is_forex_pips = input(title="Display average range as forex pips?", type=input.bool, defval=true)
  84. daily_adr_user = input(title="Show ADR for x days", type=input.integer, defval=1, minval=0)
  85. daily_adr_length = input(title="ADR Length parameter (Days - default 3 weeks, 21 days)", type=input.integer, defval=21, minval=0)
  86.  
  87. showPreviousDayHiLo = input(defval=true, type=input.bool, title="Show Previous Days High / Low")
  88. previousDayHiLoColor = input(title="Previous Days Line Color", defval="yellow", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  89. supportLineWidth = input(title="Previous Days Line Width", defval=1, minval=0, maxval=10)
  90. previousDayHiLoLineStyle = input(title="Previous Days Line Style", defval="dashed", options=["solid", "dashed", "dotted"])
  91. showHiLoPriceRange = input(defval=false, type=input.bool, title="Show Previous Days Range")
  92. showHiLoPriceLabel = input(defval=false, type=input.bool, title="Show Line Label (YH / YL)")
  93.  
  94.  
  95. showLastWeeklyHiLo = input(defval=true, type=input.bool, title="Show Last Weeks High / Low")
  96. lastWeeklyHiLoColor = input(title="Last Week Line Color", defval="orange", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  97. supportLastWeekLineWidth = input(title="Last Week Line Width", defval=1, minval=0, maxval=10)
  98. lastWeeklyHiLoStyle = input(title="Last Week Line Style", defval="dashed", options=["solid", "dashed", "dotted"])
  99. lastWeeklyHiLoShowLabel = input(defval=true, type=input.bool, title="Show Line Label (PWH / PWL)")
  100.  
  101.  
  102. showWeeklyHiLo = input(defval=false, type=input.bool, title="Show This Weeks High / Low")
  103. weeklyHiLoColor = input(title="This Weeks Line Color", defval="olive", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  104. supportWeekLineWidth = input(title="This Weeks Line Width", defval=1, minval=0, maxval=10)
  105. weeklyHiLoStyle = input(title="This Weeks Line Style", defval="dashed", options=["solid", "dashed", "dotted"])
  106. weeklyHiLoShowLabel = input(defval=false, type=input.bool, title="Show Line Label (WH / WL)")
  107.  
  108. showHiLoTime = input(defval=false, type=input.bool, title="Show Hi / Low Time of Day (Always Displays Eastern Standard Time)")
  109.  
  110.  
  111. // End User Inputs
  112.  
  113. // Asian Input Convertions
  114. line_color = user_box_line_color == "aqua" ? color.aqua : user_box_line_color == "black" ? color.black : user_box_line_color == "blue" ? color.blue : user_box_line_color == "fuchsia" ? color.fuchsia : user_box_line_color == "gray" ? color.gray : user_box_line_color == "green" ? color.green : user_box_line_color == "lime" ? color.lime : user_box_line_color == "maroon" ? color.maroon : user_box_line_color == "navy" ? color.navy : user_box_line_color == "olive" ? color.olive : user_box_line_color == "orange" ? color.orange : user_box_line_color == "purple" ? color.purple : user_box_line_color == "red" ? color.red : user_box_line_color == "silver" ? color.silver : user_box_line_color == "teal" ? color.teal : user_box_line_color == "white" ? color.white : user_box_line_color == "yellow" ? color.yellow : color.black
  115. midline_color = user_midline_color == "aqua" ? color.aqua : user_midline_color == "black" ? color.black : user_midline_color == "blue" ? color.blue : user_midline_color == "fuchsia" ? color.fuchsia : user_midline_color == "gray" ? color.gray : user_midline_color == "green" ? color.green : user_midline_color == "lime" ? color.lime : user_midline_color == "maroon" ? color.maroon : user_midline_color == "navy" ? color.navy : user_midline_color == "olive" ? color.olive : user_midline_color == "orange" ? color.orange : user_midline_color == "purple" ? color.purple : user_midline_color == "red" ? color.red : user_midline_color == "silver" ? color.silver : user_midline_color == "teal" ? color.teal : user_midline_color == "white" ? color.white : user_midline_color == "yellow" ? color.yellow : color.black
  116. text_color = user_text_color == "aqua" ? color.aqua : user_text_color == "black" ? color.black : user_text_color == "blue" ? color.blue : user_text_color == "fuchsia" ? color.fuchsia : user_text_color == "gray" ? color.gray : user_text_color == "green" ? color.green : user_text_color == "lime" ? color.lime : user_text_color == "maroon" ? color.maroon : user_text_color == "navy" ? color.navy : user_text_color == "olive" ? color.olive : user_text_color == "orange" ? color.orange : user_text_color == "purple" ? color.purple : user_text_color == "red" ? color.red : user_text_color == "silver" ? color.silver : user_text_color == "teal" ? color.teal : user_text_color == "white" ? color.white : user_text_color == "yellow" ? color.yellow : color.black
  117.  
  118. box_line_style = user_box_line_style == "solid" ? line.style_solid : user_box_line_style == "dashed" ? line.style_dashed : user_box_line_style == "dotted" ? line.style_dotted : line.style_solid
  119. upperlower_line_style = user_upperlower_line_style == "solid" ? line.style_solid : user_upperlower_line_style == "dashed" ? line.style_dashed : user_upperlower_line_style == "dotted" ? line.style_dotted : line.style_solid
  120. middle_line_style = user_middle_line_style == "solid" ? line.style_solid : user_middle_line_style == "dashed" ? line.style_dashed : user_middle_line_style == "dotted" ? line.style_dotted : line.style_solid
  121.  
  122. labelsize = user_label_size == "tiny" ? size.tiny : user_label_size == "small" ? size.small : user_label_size == "normal" ? size.normal : user_label_size == "large" ? size.large : size.normal
  123. //
  124.  
  125. // London Input Convertions
  126. lline_color = luser_box_line_color == "aqua" ? color.aqua : luser_box_line_color == "black" ? color.black : luser_box_line_color == "blue" ? color.blue : luser_box_line_color == "fuchsia" ? color.fuchsia : luser_box_line_color == "gray" ? color.gray : luser_box_line_color == "green" ? color.green : luser_box_line_color == "lime" ? color.lime : luser_box_line_color == "maroon" ? color.maroon : luser_box_line_color == "navy" ? color.navy : luser_box_line_color == "olive" ? color.olive : luser_box_line_color == "orange" ? color.orange : luser_box_line_color == "purple" ? color.purple : luser_box_line_color == "red" ? color.red : luser_box_line_color == "silver" ? color.silver : luser_box_line_color == "teal" ? color.teal : luser_box_line_color == "white" ? color.white : luser_box_line_color == "yellow" ? color.yellow : color.black
  127. lmidline_color = luser_midline_color == "aqua" ? color.aqua : luser_midline_color == "black" ? color.black : luser_midline_color == "blue" ? color.blue : luser_midline_color == "fuchsia" ? color.fuchsia : luser_midline_color == "gray" ? color.gray : luser_midline_color == "green" ? color.green : luser_midline_color == "lime" ? color.lime : luser_midline_color == "maroon" ? color.maroon : luser_midline_color == "navy" ? color.navy : luser_midline_color == "olive" ? color.olive : luser_midline_color == "orange" ? color.orange : luser_midline_color == "purple" ? color.purple : luser_midline_color == "red" ? color.red : luser_midline_color == "silver" ? color.silver : luser_midline_color == "teal" ? color.teal : luser_midline_color == "white" ? color.white : luser_midline_color == "yellow" ? color.yellow : color.black
  128. ltext_color = luser_text_color == "aqua" ? color.aqua : luser_text_color == "black" ? color.black : luser_text_color == "blue" ? color.blue : luser_text_color == "fuchsia" ? color.fuchsia : luser_text_color == "gray" ? color.gray : luser_text_color == "green" ? color.green : luser_text_color == "lime" ? color.lime : luser_text_color == "maroon" ? color.maroon : luser_text_color == "navy" ? color.navy : luser_text_color == "olive" ? color.olive : luser_text_color == "orange" ? color.orange : luser_text_color == "purple" ? color.purple : luser_text_color == "red" ? color.red : luser_text_color == "silver" ? color.silver : luser_text_color == "teal" ? color.teal : luser_text_color == "white" ? color.white : luser_text_color == "yellow" ? color.yellow : color.black
  129.  
  130. lbox_line_style = luser_box_line_style == "solid" ? line.style_solid : luser_box_line_style == "dashed" ? line.style_dashed : luser_box_line_style == "dotted" ? line.style_dotted : line.style_solid
  131. lupperlower_line_style = luser_upperlower_line_style == "solid" ? line.style_solid : luser_upperlower_line_style == "dashed" ? line.style_dashed : luser_upperlower_line_style == "dotted" ? line.style_dotted : line.style_solid
  132. lmiddle_line_style = luser_middle_line_style == "solid" ? line.style_solid : luser_middle_line_style == "dashed" ? line.style_dashed : luser_middle_line_style == "dotted" ? line.style_dotted : line.style_solid
  133.  
  134. llabelsize = luser_label_size == "tiny" ? size.tiny : luser_label_size == "small" ? size.small : luser_label_size == "normal" ? size.normal : luser_label_size == "large" ? size.large : size.normal
  135. //
  136.  
  137. // New York Input Convertions
  138. nline_color = nuser_box_line_color == "aqua" ? color.aqua : nuser_box_line_color == "black" ? color.black : nuser_box_line_color == "blue" ? color.blue : nuser_box_line_color == "fuchsia" ? color.fuchsia : nuser_box_line_color == "gray" ? color.gray : nuser_box_line_color == "green" ? color.green : nuser_box_line_color == "lime" ? color.lime : nuser_box_line_color == "maroon" ? color.maroon : nuser_box_line_color == "navy" ? color.navy : nuser_box_line_color == "olive" ? color.olive : nuser_box_line_color == "orange" ? color.orange : nuser_box_line_color == "purple" ? color.purple : nuser_box_line_color == "red" ? color.red : nuser_box_line_color == "silver" ? color.silver : nuser_box_line_color == "teal" ? color.teal : nuser_box_line_color == "white" ? color.white : nuser_box_line_color == "yellow" ? color.yellow : color.black
  139. nmidline_color = nuser_midline_color == "aqua" ? color.aqua : nuser_midline_color == "black" ? color.black : nuser_midline_color == "blue" ? color.blue : nuser_midline_color == "fuchsia" ? color.fuchsia : nuser_midline_color == "gray" ? color.gray : nuser_midline_color == "green" ? color.green : nuser_midline_color == "lime" ? color.lime : nuser_midline_color == "maroon" ? color.maroon : nuser_midline_color == "navy" ? color.navy : nuser_midline_color == "olive" ? color.olive : nuser_midline_color == "orange" ? color.orange : nuser_midline_color == "purple" ? color.purple : nuser_midline_color == "red" ? color.red : nuser_midline_color == "silver" ? color.silver : nuser_midline_color == "teal" ? color.teal : nuser_midline_color == "white" ? color.white : nuser_midline_color == "yellow" ? color.yellow : color.black
  140. ntext_color = nuser_text_color == "aqua" ? color.aqua : nuser_text_color == "black" ? color.black : nuser_text_color == "blue" ? color.blue : nuser_text_color == "fuchsia" ? color.fuchsia : nuser_text_color == "gray" ? color.gray : nuser_text_color == "green" ? color.green : nuser_text_color == "lime" ? color.lime : nuser_text_color == "maroon" ? color.maroon : nuser_text_color == "navy" ? color.navy : nuser_text_color == "olive" ? color.olive : nuser_text_color == "orange" ? color.orange : nuser_text_color == "purple" ? color.purple : nuser_text_color == "red" ? color.red : nuser_text_color == "silver" ? color.silver : nuser_text_color == "teal" ? color.teal : nuser_text_color == "white" ? color.white : nuser_text_color == "yellow" ? color.yellow : color.black
  141.  
  142. nbox_line_style = nuser_box_line_style == "solid" ? line.style_solid : nuser_box_line_style == "dashed" ? line.style_dashed : nuser_box_line_style == "dotted" ? line.style_dotted : line.style_solid
  143. nupperlower_line_style = nuser_upperlower_line_style == "solid" ? line.style_solid : nuser_upperlower_line_style == "dashed" ? line.style_dashed : nuser_upperlower_line_style == "dotted" ? line.style_dotted : line.style_solid
  144. nmiddle_line_style = nuser_middle_line_style == "solid" ? line.style_solid : nuser_middle_line_style == "dashed" ? line.style_dashed : nuser_middle_line_style == "dotted" ? line.style_dotted : line.style_solid
  145.  
  146. nlabelsize = nuser_label_size == "tiny" ? size.tiny : nuser_label_size == "small" ? size.small : nuser_label_size == "normal" ? size.normal : nuser_label_size == "large" ? size.large : size.normal
  147.  
  148. // ADR Reset Period for Weekend
  149. // If weekend then need to adjust
  150. // the user input period for how long
  151. // back they want to see the ADR
  152. daily_adr = daily_adr_user
  153. if (dayofweek.sunday)
  154. daily_adr := daily_adr + 1
  155. if (dayofweek.saturday)
  156. daily_adr := daily_adr + 1
  157. //
  158.  
  159. // High Low Support / resistance
  160. lblTP = 70
  161.  
  162. support_line_color = previousDayHiLoColor == "aqua" ? color.aqua : previousDayHiLoColor == "black" ? color.black : previousDayHiLoColor == "blue" ? color.blue : previousDayHiLoColor == "fuchsia" ? color.fuchsia : previousDayHiLoColor == "gray" ? color.gray : previousDayHiLoColor == "green" ? color.green : previousDayHiLoColor == "lime" ? color.lime : previousDayHiLoColor == "maroon" ? color.maroon : previousDayHiLoColor == "navy" ? color.navy : previousDayHiLoColor == "olive" ? color.olive : previousDayHiLoColor == "orange" ? color.orange : previousDayHiLoColor == "purple" ? color.purple : previousDayHiLoColor == "red" ? color.red : previousDayHiLoColor == "silver" ? color.silver : previousDayHiLoColor == "teal" ? color.teal : previousDayHiLoColor == "white" ? color.white : previousDayHiLoColor == "yellow" ? color.yellow : color.black
  163. support_line_label_color = previousDayHiLoColor == "aqua" ? color.new(color.aqua,lblTP) : previousDayHiLoColor == "black" ? color.new(color.black,lblTP) : previousDayHiLoColor == "blue" ? color.new(color.blue,lblTP) : previousDayHiLoColor == "fuchsia" ? color.new(color.fuchsia,lblTP) : previousDayHiLoColor == "gray" ? color.new(color.gray,lblTP) : previousDayHiLoColor == "green" ? color.new(color.green,lblTP) : previousDayHiLoColor == "lime" ? color.new(color.lime,lblTP) : previousDayHiLoColor == "maroon" ? color.new(color.maroon,lblTP) : previousDayHiLoColor == "navy" ? color.new(color.navy,lblTP) : previousDayHiLoColor == "olive" ? color.new(color.olive,lblTP) : previousDayHiLoColor == "orange" ? color.new(color.orange,lblTP) : previousDayHiLoColor == "purple" ? color.new(color.purple,lblTP) : previousDayHiLoColor == "red" ? color.new(color.red,lblTP) : previousDayHiLoColor == "silver" ? color.new(color.silver,lblTP) : previousDayHiLoColor == "teal" ? color.new(color.teal,lblTP) : previousDayHiLoColor == "white" ? color.new(color.white,lblTP) : previousDayHiLoColor == "yellow" ? color.new(color.yellow,lblTP) : color.new(color.black,lblTP)
  164.  
  165. support_line_style = previousDayHiLoLineStyle == "solid" ? line.style_solid : previousDayHiLoLineStyle == "dashed" ? line.style_dashed : previousDayHiLoLineStyle == "dotted" ? line.style_dotted : line.style_solid
  166.  
  167.  
  168. support_last_week_line_color = lastWeeklyHiLoColor == "aqua" ? color.aqua : lastWeeklyHiLoColor == "black" ? color.black : lastWeeklyHiLoColor == "blue" ? color.blue : lastWeeklyHiLoColor == "fuchsia" ? color.fuchsia : lastWeeklyHiLoColor == "gray" ? color.gray : lastWeeklyHiLoColor == "green" ? color.green : lastWeeklyHiLoColor == "lime" ? color.lime : lastWeeklyHiLoColor == "maroon" ? color.maroon : lastWeeklyHiLoColor == "navy" ? color.navy : lastWeeklyHiLoColor == "olive" ? color.olive : lastWeeklyHiLoColor == "orange" ? color.orange : lastWeeklyHiLoColor == "purple" ? color.purple : lastWeeklyHiLoColor == "red" ? color.red : lastWeeklyHiLoColor == "silver" ? color.silver : lastWeeklyHiLoColor == "teal" ? color.teal : lastWeeklyHiLoColor == "white" ? color.white : lastWeeklyHiLoColor == "yellow" ? color.yellow : color.black
  169. support_last_week_line_label_color = lastWeeklyHiLoColor == "aqua" ? color.new(color.aqua,lblTP) : lastWeeklyHiLoColor == "black" ? color.new(color.black,lblTP) : lastWeeklyHiLoColor == "blue" ? color.new(color.blue,lblTP) : lastWeeklyHiLoColor == "fuchsia" ? color.new(color.fuchsia,lblTP) : lastWeeklyHiLoColor == "gray" ? color.new(color.gray,lblTP) : lastWeeklyHiLoColor == "green" ? color.new(color.green,lblTP) : lastWeeklyHiLoColor == "lime" ? color.new(color.lime,lblTP) : lastWeeklyHiLoColor == "maroon" ? color.new(color.maroon,lblTP) : lastWeeklyHiLoColor == "navy" ? color.new(color.navy,lblTP) : lastWeeklyHiLoColor == "olive" ? color.new(color.olive,lblTP) : lastWeeklyHiLoColor == "orange" ? color.new(color.orange,lblTP) : lastWeeklyHiLoColor == "purple" ? color.new(color.purple,lblTP) : lastWeeklyHiLoColor == "red" ? color.new(color.red,lblTP) : lastWeeklyHiLoColor == "silver" ? color.new(color.silver,lblTP) : lastWeeklyHiLoColor == "teal" ? color.new(color.teal,lblTP) : lastWeeklyHiLoColor == "white" ? color.new(color.white,lblTP) : lastWeeklyHiLoColor == "yellow" ? color.new(color.yellow,lblTP) : color.new(color.black,lblTP)
  170.  
  171. support_last_week_line_style = lastWeeklyHiLoStyle == "solid" ? line.style_solid : lastWeeklyHiLoStyle == "dashed" ? line.style_dashed : lastWeeklyHiLoStyle == "dotted" ? line.style_dotted : line.style_solid
  172.  
  173. wlineTP = 30
  174. support_week_line_color = weeklyHiLoColor == "aqua" ? color.new(color.aqua,wlineTP) : weeklyHiLoColor == "black" ? color.new(color.black,wlineTP) : weeklyHiLoColor == "blue" ? color.new(color.blue,wlineTP) : weeklyHiLoColor == "fuchsia" ? color.new(color.fuchsia,wlineTP) : weeklyHiLoColor == "gray" ? color.new(color.gray,wlineTP) : weeklyHiLoColor == "green" ? color.new(color.green,wlineTP) : weeklyHiLoColor == "lime" ? color.new(color.lime,wlineTP) : weeklyHiLoColor == "maroon" ? color.new(color.maroon,wlineTP) : weeklyHiLoColor == "navy" ? color.new(color.navy,wlineTP) : weeklyHiLoColor == "olive" ? color.new(color.olive,wlineTP) : weeklyHiLoColor == "orange" ? color.new(color.orange,wlineTP) : weeklyHiLoColor == "purple" ? color.new(color.purple,wlineTP) : weeklyHiLoColor == "red" ? color.new(color.red,wlineTP) : weeklyHiLoColor == "silver" ? color.new(color.silver,wlineTP) : weeklyHiLoColor == "teal" ? color.new(color.teal,wlineTP) : weeklyHiLoColor == "white" ? color.new(color.white,wlineTP) : weeklyHiLoColor == "yellow" ? color.new(color.yellow,wlineTP) : color.new(color.black,wlineTP)
  175. support_week_line_style = weeklyHiLoStyle == "solid" ? line.style_solid : weeklyHiLoStyle == "dashed" ? line.style_dashed : weeklyHiLoStyle == "dotted" ? line.style_dotted : line.style_solid
  176.  
  177.  
  178.  
  179. chart_time_period_int = timeframe.period == "1" ? 1 : timeframe.period == "3" ? 3 : timeframe.period == "5" ? 5 : timeframe.period == "15" ? 15 : timeframe.period == "30" ? 30 : timeframe.period == "45" ? 45 : 15
  180. tickerExchangeOffset = 4
  181.  
  182. // Asian Session
  183. int start_session_hour_int = 0
  184. int end_session_hour_int = 0
  185. int end_line_hour_int = 0
  186.  
  187. start_session_hour_int := user_ssth == "00" ? 0 : user_ssth == "01" ? 1 : user_ssth == "02" ? 2 : user_ssth == "03" ? 3 : user_ssth == "04" ? 4 : user_ssth == "05" ? 5 : user_ssth == "06" ? 6 : user_ssth == "07" ? 7 : user_ssth == "08" ? 8 : user_ssth == "09" ? 9 : user_ssth == "10" ? 10 : user_ssth == "11" ? 11 : user_ssth == "12" ? 12 : user_ssth == "13" ? 13 : user_ssth == "14" ? 14 : user_ssth == "15" ? 15 : user_ssth == "16" ? 16 : user_ssth == "17" ? 17 : user_ssth == "18" ? 18 : user_ssth == "19" ? 19 : user_ssth == "20" ? 20 : user_ssth == "21" ? 21 : user_ssth == "22" ? 22 : user_ssth == "23" ? 23 : 0
  188. start_session_minute_int = user_sstm == "00" ? 0 : user_sstm == "15" ? 15 : user_sstm == "30" ? 30 : user_sstm == "45" ? 45 : 0
  189.  
  190. end_session_hour_int := user_esth == "00" ? 0 : user_esth == "01" ? 1 : user_esth == "02" ? 2 : user_esth == "03" ? 3 : user_esth == "04" ? 4 : user_esth == "05" ? 5 : user_esth == "06" ? 6 : user_esth == "07" ? 7 : user_esth == "08" ? 8 : user_esth == "09" ? 9 : user_esth == "10" ? 10 : user_esth == "11" ? 11 : user_esth == "12" ? 12 : user_esth == "13" ? 13 : user_esth == "14" ? 14 : user_esth == "15" ? 15 : user_esth == "16" ? 16 : user_esth == "17" ? 17 : user_esth == "18" ? 18 : user_esth == "19" ? 19 : user_esth == "20" ? 20 : user_esth == "21" ? 21 : user_esth == "22" ? 22 : user_esth == "23" ? 23 : 0
  191. end_session_minute_int = user_estm == "00" ? 0 : user_estm == "15" ? 15 : user_estm == "30" ? 30 : user_estm == "45" ? 45 : 0
  192.  
  193. end_line_hour_int := user_elth == "00" ? 0 : user_elth == "01" ? 1 : user_elth == "02" ? 2 : user_elth == "03" ? 3 : user_elth == "04" ? 4 : user_elth == "05" ? 5 : user_elth == "06" ? 6 : user_elth == "07" ? 7 : user_elth == "08" ? 8 : user_elth == "09" ? 9 : user_elth == "10" ? 10 : user_elth == "11" ? 11 : user_elth == "12" ? 12 : user_elth == "13" ? 13 : user_elth == "14" ? 14 : user_elth == "15" ? 15 : user_elth == "16" ? 16 : user_elth == "17" ? 17 : user_elth == "18" ? 18 : user_elth == "19" ? 19 : user_elth == "20" ? 20 : user_elth == "21" ? 21 : user_elth == "22" ? 22 : user_elth == "23" ? 23 : 0
  194. end_line_minute_int = user_eltm == "00" ? 0 : user_eltm == "15" ? 15 : user_eltm == "30" ? 30 : user_eltm == "45" ? 45 : 0
  195.  
  196. end_session_minute_int_offset = (end_session_minute_int + chart_time_period_int)
  197.  
  198. // End Section
  199.  
  200. // London Session
  201. int london_start_session_hour_int = 0
  202. int london_end_session_hour_int = 0
  203.  
  204. london_start_session_hour_int := london_ssth == "00" ? 0 : london_ssth == "01" ? 1 : london_ssth == "02" ? 2 : london_ssth == "03" ? 3 : london_ssth == "04" ? 4 : london_ssth == "05" ? 5 : london_ssth == "06" ? 6 : london_ssth == "07" ? 7 : london_ssth == "08" ? 8 : london_ssth == "09" ? 9 : london_ssth == "10" ? 10 : london_ssth == "11" ? 11 : london_ssth == "12" ? 12 : london_ssth == "13" ? 13 : london_ssth == "14" ? 14 : london_ssth == "15" ? 15 : london_ssth == "16" ? 16 : london_ssth == "17" ? 17 : london_ssth == "18" ? 18 : london_ssth == "19" ? 19 : london_ssth == "20" ? 20 : london_ssth == "21" ? 21 : london_ssth == "22" ? 22 : london_ssth == "23" ? 23 : 0
  205. london_start_session_minute_int = london_sstm == "00" ? 0 : london_sstm == "15" ? 15 : london_sstm == "30" ? 30 : london_sstm == "45" ? 45 : 0
  206.  
  207. london_end_session_hour_int := london_esth == "00" ? 0 : london_esth == "01" ? 1 : london_esth == "02" ? 2 : london_esth == "03" ? 3 : london_esth == "04" ? 4 : london_esth == "05" ? 5 : london_esth == "06" ? 6 : london_esth == "07" ? 7 : london_esth == "08" ? 8 : london_esth == "09" ? 9 : london_esth == "10" ? 10 : london_esth == "11" ? 11 : london_esth == "12" ? 12 : london_esth == "13" ? 13 : london_esth == "14" ? 14 : london_esth == "15" ? 15 : london_esth == "16" ? 16 : london_esth == "17" ? 17 : london_esth == "18" ? 18 : london_esth == "19" ? 19 : london_esth == "20" ? 20 : london_esth == "21" ? 21 : london_esth == "22" ? 22 : london_esth == "23" ? 23 : 0
  208. london_end_session_minute_int = london_estm == "00" ? 0 : london_estm == "15" ? 15 : london_estm == "30" ? 30 : london_estm == "45" ? 45 : 0
  209.  
  210.  
  211. london_end_session_minute_int_offset = (london_end_session_minute_int + chart_time_period_int)
  212.  
  213. // End Section
  214.  
  215. // Check Chart Period to see if aspects should display
  216. isValidResolution() => timeframe.isdwm == true or timeframe.period == "120" or timeframe.period == "240" or timeframe.period == "180" or timeframe.period == "360" ? 0 : 1
  217. isBelowHourValidResolution() => timeframe.isdwm == true or timeframe.period == "120" or timeframe.period == "240" or timeframe.period == "180" or timeframe.period == "360" ? 0 : 1
  218.  
  219.  
  220. // NY Session
  221. int ny_start_session_hour_int = 0
  222. int ny_end_session_hour_int = 0
  223.  
  224. ny_start_session_hour_int := ny_ssth == "00" ? 0 : ny_ssth == "01" ? 1 : ny_ssth == "02" ? 2 : ny_ssth == "03" ? 3 : ny_ssth == "04" ? 4 : ny_ssth == "05" ? 5 : ny_ssth == "06" ? 6 : ny_ssth == "07" ? 7 : ny_ssth == "08" ? 8 : ny_ssth == "09" ? 9 : ny_ssth == "10" ? 10 : ny_ssth == "11" ? 11 : ny_ssth == "12" ? 12 : ny_ssth == "13" ? 13 : ny_ssth == "14" ? 14 : ny_ssth == "15" ? 15 : ny_ssth == "16" ? 16 : ny_ssth == "17" ? 17 : ny_ssth == "18" ? 18 : ny_ssth == "19" ? 19 : ny_ssth == "20" ? 20 : ny_ssth == "21" ? 21 : ny_ssth == "22" ? 22 : ny_ssth == "23" ? 23 : 0
  225. ny_start_session_minute_int = ny_sstm == "00" ? 0 : ny_sstm == "15" ? 15 : ny_sstm == "30" ? 30 : ny_sstm == "45" ? 45 : 0
  226.  
  227. ny_end_session_hour_int := ny_esth == "00" ? 0 : ny_esth == "01" ? 1 : ny_esth == "02" ? 2 : ny_esth == "03" ? 3 : ny_esth == "04" ? 4 : ny_esth == "05" ? 5 : ny_esth == "06" ? 6 : ny_esth == "07" ? 7 : ny_esth == "08" ? 8 : ny_esth == "09" ? 9 : ny_esth == "10" ? 10 : ny_esth == "11" ? 11 : ny_esth == "12" ? 12 : ny_esth == "13" ? 13 : ny_esth == "14" ? 14 : ny_esth == "15" ? 15 : ny_esth == "16" ? 16 : ny_esth == "17" ? 17 : ny_esth == "18" ? 18 : ny_esth == "19" ? 19 : ny_esth == "20" ? 20 : ny_esth == "21" ? 21 : ny_esth == "22" ? 22 : ny_esth == "23" ? 23 : 0
  228. ny_end_session_minute_int = ny_estm == "00" ? 0 : ny_estm == "15" ? 15 : ny_estm == "30" ? 30 : ny_estm == "45" ? 45 : 0
  229.  
  230.  
  231. ny_end_session_minute_int_offset = (ny_end_session_minute_int + chart_time_period_int)
  232.  
  233. // End Section
  234.  
  235.  
  236. // Support Structures Time Details
  237. start_support_hour_int = 17
  238. start_support_minute_int = 0
  239. end_support_hour_int = 17
  240. end_support_minute_int = 0
  241. // End Section
  242.  
  243. // Forex.com use a different server time that other brokers
  244. // So need to adjust
  245. if (syminfo.timezone == "Etc/UTC")
  246. start_session_hour_int := start_session_hour_int + tickerExchangeOffset
  247. end_session_hour_int := end_session_hour_int + tickerExchangeOffset
  248. end_line_hour_int := end_line_hour_int + tickerExchangeOffset
  249.  
  250. london_start_session_hour_int := london_start_session_hour_int + tickerExchangeOffset
  251. london_end_session_hour_int := london_end_session_hour_int + tickerExchangeOffset
  252.  
  253. ny_start_session_hour_int := ny_start_session_hour_int + tickerExchangeOffset
  254. ny_end_session_hour_int := ny_end_session_hour_int + tickerExchangeOffset
  255.  
  256. start_support_hour_int := start_support_hour_int + tickerExchangeOffset
  257. end_support_hour_int := end_support_hour_int + tickerExchangeOffset
  258.  
  259. // Asian Condition
  260. // Need to check the adjusted time to make sure it is correct
  261. if (start_session_hour_int >= 24)
  262. if (start_session_hour_int == 24)
  263. user_ssth := "00"
  264. else
  265. user_ssth := "0" + tostring(start_session_hour_int - 24)
  266. else
  267. if (start_session_hour_int < 10)
  268. user_ssth := "0" + tostring(start_session_hour_int)
  269. else
  270. user_ssth := tostring(start_session_hour_int)
  271.  
  272.  
  273. if (end_session_hour_int >= 24)
  274. if (end_session_hour_int == 24)
  275. user_esth := "00"
  276. else
  277. user_esth := "0" + tostring(end_session_hour_int - 24)
  278. else
  279. if (end_session_hour_int < 10)
  280. user_esth := "0" + tostring(end_session_hour_int)
  281. else
  282. user_esth := tostring(end_session_hour_int)
  283.  
  284. // End Condition
  285.  
  286. // London Condition
  287. // Need to check the adjusted time to make sure it is correct
  288. if (london_start_session_hour_int >= 24)
  289. if (london_start_session_hour_int == 24)
  290. london_ssth := "00"
  291. else
  292. london_ssth := "0" + tostring(london_start_session_hour_int - 24)
  293. else
  294. if (london_start_session_hour_int < 10)
  295. london_ssth := "0" + tostring(london_start_session_hour_int)
  296. else
  297. london_ssth := tostring(london_start_session_hour_int)
  298.  
  299.  
  300. if (london_end_session_hour_int >= 24)
  301. if (london_end_session_hour_int == 24)
  302. london_esth := "00"
  303. else
  304. london_esth := "0" + tostring(london_end_session_hour_int - 24)
  305. else
  306. if (london_end_session_hour_int < 10)
  307. london_esth := "0" + tostring(london_end_session_hour_int)
  308. else
  309. london_esth := tostring(london_end_session_hour_int)
  310.  
  311. // End Condition
  312.  
  313. // New York Condition
  314. // Need to check the adjusted time to make sure it is correct
  315. if (ny_start_session_hour_int >= 24)
  316. if (ny_start_session_hour_int == 24)
  317. ny_ssth := "00"
  318. else
  319. ny_ssth := "0" + tostring(ny_start_session_hour_int - 24)
  320. else
  321. if (ny_start_session_hour_int < 10)
  322. ny_ssth := "0" + tostring(ny_start_session_hour_int)
  323. else
  324. ny_ssth := tostring(ny_start_session_hour_int)
  325.  
  326.  
  327. if (ny_end_session_hour_int >= 24)
  328. if (ny_end_session_hour_int == 24)
  329. ny_esth := "00"
  330. else
  331. ny_esth := "0" + tostring(ny_end_session_hour_int - 24)
  332. else
  333. if (ny_end_session_hour_int < 10)
  334. ny_esth := "0" + tostring(ny_end_session_hour_int)
  335. else
  336. ny_esth := tostring(ny_end_session_hour_int)
  337.  
  338. // End Condition
  339.  
  340. // End Section
  341.  
  342. // this is the tradable session, from end of Asia to the end of NY
  343. trd_ses = (user_esth) + (user_estm) + "-" + (ny_esth) + (ny_estm)
  344. //
  345. rth_ses = ""
  346. london_rth_ses = ""
  347. ny_rth_ses = ""
  348.  
  349. rth_fill_ses = ""
  350. london_rth_fill_ses = ""
  351. ny_rth_fill_ses = ""
  352.  
  353. // RM changed the session details, rather than using offset to the user input minute
  354. // So conditional logic is not required.
  355. // Note - Not 100% sure why this complex logic was introduced. There could be knockon issues, so have retained existing logic remmed out.
  356. // Actually looks like the extended logic is due to the back fill of the range
  357. rth_ses := (user_ssth) + (user_sstm) + "-" + (user_esth) + user_estm
  358. london_rth_ses := (london_ssth) + (london_sstm) + "-" + (london_esth) + london_estm
  359. ny_rth_ses := (ny_ssth) + (ny_sstm) + "-" + (ny_esth) + ny_estm
  360.  
  361. // Check the timeframe and the expected time and adjust appropiately
  362. if (timeframe.period == "5" or timeframe.period == "3" or timeframe.period == "1") and end_session_minute_int == 0
  363. rth_fill_ses := (user_ssth) + (user_sstm) + "-" + (user_esth) + "0" + tostring(end_session_minute_int_offset)
  364. else
  365. rth_fill_ses := (user_ssth) + (user_sstm) + "-" + (user_esth) + tostring(end_session_minute_int_offset)
  366.  
  367. if (timeframe.period == "5" or timeframe.period == "3" or timeframe.period == "1") and london_end_session_minute_int == 0
  368. london_rth_fill_ses := (london_ssth) + (london_sstm) + "-" + (london_esth) + "0" + tostring(london_end_session_minute_int_offset)
  369. else
  370. london_rth_fill_ses := (london_ssth) + (london_sstm) + "-" + (london_esth) + tostring(london_end_session_minute_int_offset)
  371.  
  372.  
  373. if (timeframe.period == "5" or timeframe.period == "3" or timeframe.period == "1") and ny_end_session_minute_int == 0
  374. ny_rth_fill_ses := (ny_ssth) + (ny_sstm) + "-" + (ny_esth) + "0" + tostring(ny_end_session_minute_int_offset)
  375. else
  376. ny_rth_fill_ses := (ny_ssth) + (ny_sstm) + "-" + (ny_esth) + tostring(ny_end_session_minute_int_offset)
  377.  
  378. // End Remove Logic Section
  379.  
  380. // End User Inputs
  381.  
  382. // General Functions
  383. open_bar(ses) =>
  384. t = time("D", ses)
  385. na(t[1]) and not na(t) or t[1] < t
  386.  
  387. is_open(ses) =>
  388. not na(time(timeframe.period, ses))
  389.  
  390.  
  391. is_end_day() =>
  392. hour == 16 and minute == 45 ? true : false
  393.  
  394. is_new_day() =>
  395. syminfo.timezone == "Etc/UTC" and hour == 0 and minute == 0 ? true : syminfo.timezone != "Etc/UTC" and hour == 20 and minute == 0 ? true : false
  396.  
  397.  
  398. get_label_offset(session) =>
  399. //o = 12//(barssince(not session[2]))
  400. //(o >= 12 and o <= 24) ? time[12] : time[24]
  401. (timeframe.period == "1") ? time[180] : (timeframe.period == "3") ? time[60] : (timeframe.period == "5") ? time[36] : (timeframe.period == "15") ? time[12] : (timeframe.period == "60") ? time[3] : time[12]
  402.  
  403. // With a new trading day starting at 5pm EST.
  404. // When moving to new day need to check if the server
  405. // still perceives is yesterday when the new trading day has started
  406. is_new_day_switch_period() =>
  407. (hour >= 20 and minute == 0) and (hour <= 23 and minute <= 59) ? true: false
  408.  
  409.  
  410. timerange(res, sess) => not na(time(res, sess)) ? 1 : 0
  411. //
  412.  
  413.  
  414. // Calculate ADR
  415. adr(length) =>
  416. range = high - low
  417. sma(range[1], length)
  418. to_pips(val) =>
  419. is_forex_pips ? round(val/syminfo.mintick/10) : round(val/syminfo.mintick)
  420.  
  421.  
  422. day_adr = security(syminfo.tickerid, 'D', adr(daily_adr_length), lookahead=barmerge.lookahead_on)
  423. one_day = 1000 * 60 * 60 * 24
  424. // End ADR Calculation
  425.  
  426.  
  427. srcHi = high
  428. srcLo = low
  429.  
  430. // Construct Asian Session Range
  431. var hi = 10e-10
  432. var lo = 10e10
  433.  
  434. startTimeDelta = 24 - start_session_hour_int + 1
  435. endTimeDelta = 24 - start_session_hour_int + 1
  436.  
  437. startTimeAlignment() => (hour + startTimeDelta) > 24? 0 : 1
  438.  
  439.  
  440. //
  441. isStartTimeAlignment = startTimeAlignment()
  442.  
  443. endBoxTimeAlignment() => start_session_hour_int >= end_session_hour_int and (hour + startTimeDelta) > 24? 1 : start_session_hour_int >= end_session_hour_int and (hour + startTimeDelta) <= 24? 0 : start_session_hour_int < end_session_hour_int and (hour + startTimeDelta) > 24? 0 : -1
  444. isEndBoxTimeAlignment = endBoxTimeAlignment()
  445.  
  446.  
  447. endTimeAlignment() => start_session_hour_int >= end_session_hour_int and (hour + startTimeDelta) > 24? 1 : start_session_hour_int >= end_session_hour_int and (hour + startTimeDelta) <= 24? 0 : start_session_hour_int < end_session_hour_int and isEndBoxTimeAlignment == 0? 1 : start_session_hour_int < end_session_hour_int and (hour + endTimeDelta) > 24? -1 : 0
  448. // Change above to support end of session being on the same day as the start on EST
  449. //endTimeAlignment() => (hour) >= (start_session_hour_int) and isStartTimeAlignment == 0? 0 : 1
  450.  
  451. isEndTimeAlignment = endTimeAlignment()
  452.  
  453. FromDate = timestamp(year, month, dayofmonth - isStartTimeAlignment, start_session_hour_int, start_session_minute_int)
  454. ToDate = timestamp(year, month, dayofmonth + isEndBoxTimeAlignment, end_session_hour_int, end_session_minute_int) - chart_time_period_int
  455.  
  456. LineFromDate = timestamp(year, month, dayofmonth + isEndBoxTimeAlignment, end_session_hour_int, end_session_minute_int) - chart_time_period_int
  457. LineToDate = timestamp(year, month, dayofmonth + isEndTimeAlignment, end_line_hour_int, end_line_minute_int)
  458.  
  459. // When a new period begins, reset hi/lo.
  460. hi := change(FromDate) ? srcHi : max(srcHi, hi)
  461. lo := change(FromDate) ? srcLo : min(srcLo, lo)
  462.  
  463. inSession = not na(time(timeframe.period, rth_ses))
  464.  
  465. rth_open_bar = open_bar(rth_ses)
  466. rth_is_open = is_open(rth_ses)
  467. rth_low = float(na)
  468. rth_low := rth_is_open ? rth_open_bar ? low : min(rth_low[1], low) : rth_low[1]
  469. rth_high = float(na)
  470. rth_high := rth_is_open ? rth_open_bar ? high : max(rth_high[1], high) : rth_high[1]
  471. rth_mid = avg(rth_low, rth_high)
  472.  
  473. float range = na
  474.  
  475. // Build the Asian Box
  476. trl = line.new(FromDate, rth_low, ToDate, rth_low, xloc=xloc.bar_time, color=line_color, style=box_line_style, width = boxLineWidth)
  477. line.delete(trl[1])
  478.  
  479. trh = line.new(FromDate, rth_high, ToDate, rth_high, xloc=xloc.bar_time, color=line_color, style=box_line_style, width = boxLineWidth)
  480. line.delete(trh[1])
  481.  
  482. trm = line.new(FromDate, rth_mid, ToDate, rth_mid, xloc=xloc.bar_time, color=midline_color, style=middle_line_style, width = sessionLineWidth)
  483. line.delete(trm[1])
  484.  
  485. startBox = line.new(FromDate, rth_high, FromDate, rth_low, extend=extend.none, xloc=xloc.bar_time, color=line_color, style=box_line_style, width=boxLineWidth)
  486. line.delete(startBox[1])
  487.  
  488. endBox = line.new(ToDate, rth_high, ToDate, rth_low, extend=extend.none, xloc=xloc.bar_time, color=line_color, style=box_line_style, width=boxLineWidth)
  489. line.delete(endBox[1])
  490. // End Section
  491.  
  492. //if not inSession and inSession[1]
  493.  
  494. //Apply the High / Low / Mid Session Lines for London / NY
  495. tl = line.new(LineFromDate, rth_low, LineToDate, rth_low, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  496. line.delete(tl[1])
  497.  
  498. th = line.new(LineFromDate, rth_high, LineToDate, rth_high, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  499. line.delete(th[1])
  500.  
  501. tm = line.new(LineFromDate, rth_mid, LineToDate, rth_mid, xloc=xloc.bar_time, color=midline_color, style=middle_line_style, width = sessionLineWidth)
  502. line.delete(tm[1])
  503. // End Section
  504.  
  505.  
  506. //Formula For Opening Range
  507. highRes = rth_high
  508. lowRes = rth_low
  509.  
  510. lineColor = color.new(color.white,100)
  511. //timerange(res, sess) => not na(time(res, sess)) ? 1 : 0
  512.  
  513. //Plot Statements For Opening Range Lines
  514. openRangeHigh = plot(timerange(timeframe.period, rth_fill_ses) > 0 and isBelowHourValidResolution() ? highRes : na, color=lineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  515. openRangeLow = plot(timerange(timeframe.period, rth_fill_ses) > 0 and isBelowHourValidResolution() ? lowRes : na, color=lineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  516. bgcolor(time(timeframe.period, rth_ses) > 0 and isBelowHourValidResolution() ? color.silver : na, transp=100, title="Asian Session Background Color")
  517.  
  518.  
  519. fill(openRangeHigh, openRangeLow, color=isBelowHourValidResolution() ? color.blue : na, transp=90, title="Fill Asian Range Color")
  520.  
  521. if (not inSession and inSession[1] and isBelowHourValidResolution())
  522. range := ((rth_high[1]-rth_low[1])/(syminfo.mintick))/10
  523. labelTime = get_label_offset(inSession)
  524.  
  525. if ((timeframe.isintraday or timeframe.isdaily) and showADR and (timenow - time) < (one_day * daily_adr))
  526. label mLabel = label.new(labelTime, rth_low[1], "A = " + tostring(range) + "\nADR = " + tostring(to_pips(day_adr)), xloc.bar_time, yloc.price, color.new(color.black,100), label.style_labelup, text_color, labelsize)
  527. else
  528. label mLabel = label.new(labelTime, rth_low[1], "A = " + tostring(range), xloc.bar_time, yloc.price, color.new(color.black,100), label.style_labelup, text_color, labelsize)
  529.  
  530. // End Sesction
  531.  
  532. // Construct London Session Range
  533. var london_hi = 10e-10
  534. var london_lo = 10e10
  535.  
  536. londonStartTimeDelta = 24 - london_start_session_hour_int + 1
  537. londonEndTimeDelta = 24 - london_end_session_hour_int + 1
  538.  
  539. startLondonTimeAlignment() => (hour + londonStartTimeDelta) > 24? 0 : 1
  540. isLondonStartTimeAlignment = startLondonTimeAlignment()
  541.  
  542. // These function deal with the shift of the box from one day to the next
  543. // At the moment they appear a little early. But wonder whether that is a
  544. // Nice feature to show the user that the session is about to start
  545.  
  546. endLondonTimeAlignment() => (hour) >= (london_start_session_hour_int) and isLondonStartTimeAlignment == 0? 0 : 1
  547. // Cause issue with displaying - works better with the above statement
  548. //endLondonTimeAlignment() => (hour) >= (london_start_session_hour_int) and (minute) >= (london_start_session_minute_int - chart_time_period_int) and isLondonStartTimeAlignment == 0? 0 : 1
  549. isLondonEndTimeAlignment = endLondonTimeAlignment()
  550.  
  551. float london_range = na
  552.  
  553. LondonFromDate = timestamp(year, month, dayofmonth - isLondonStartTimeAlignment, london_start_session_hour_int, london_start_session_minute_int)
  554. LondonToDate = timestamp(year, month, dayofmonth - isLondonEndTimeAlignment, london_end_session_hour_int, london_end_session_minute_int) - chart_time_period_int
  555.  
  556.  
  557. // When a new period begins, reset hi/lo.
  558. london_hi := change(LondonFromDate) ? srcHi : max(srcHi, london_hi)
  559. london_lo := change(LondonFromDate) ? srcLo : min(srcLo, london_lo)
  560.  
  561. inLondonSession = not na(time(timeframe.period, london_rth_ses))
  562.  
  563. london_rth_open_bar = open_bar(london_rth_ses)
  564. london_rth_is_open = is_open(london_rth_ses)
  565. london_rth_low = float(na)
  566. london_rth_low := london_rth_is_open ? london_rth_open_bar ? low : min(london_rth_low[1], low) : london_rth_low[1]
  567. london_rth_high = float(na)
  568. london_rth_high := london_rth_is_open ? london_rth_open_bar ? high : max(london_rth_high[1], high) : london_rth_high[1]
  569. london_rth_mid = avg(london_rth_low, london_rth_high)
  570.  
  571. if (show_london_session and isValidResolution())
  572.  
  573. //if inSession
  574. // Build the Asian Box
  575. ltrl = line.new(LondonFromDate, london_rth_low, LondonToDate, london_rth_low, xloc=xloc.bar_time, color=lline_color, style=lbox_line_style, width = lboxLineWidth)
  576. line.delete(ltrl[1])
  577.  
  578. ltrh = line.new(LondonFromDate, london_rth_high, LondonToDate, london_rth_high, xloc=xloc.bar_time, color=lline_color, style=lbox_line_style, width = lboxLineWidth)
  579. line.delete(ltrh[1])
  580.  
  581. ltrm = line.new(LondonFromDate, london_rth_mid, LondonToDate, london_rth_mid, xloc=xloc.bar_time, color=lmidline_color, style=lmiddle_line_style, width = lsessionLineWidth)
  582. line.delete(ltrm[1])
  583.  
  584. londonStartBox = line.new(LondonFromDate, london_rth_high, LondonFromDate, london_rth_low, extend=extend.none, xloc=xloc.bar_time, color=lline_color, style=lbox_line_style, width=lboxLineWidth)
  585. line.delete(londonStartBox[1])
  586.  
  587. londonEndBox = line.new(LondonToDate, london_rth_high, LondonToDate, london_rth_low, extend=extend.none, xloc=xloc.bar_time, color=lline_color, style=lbox_line_style, width=lboxLineWidth)
  588. line.delete(londonEndBox[1])
  589. // End Section
  590.  
  591. //if not inSession and inSession[1]
  592.  
  593. //Apply the High / Low / Mid Session Lines for London / NY
  594. //tl = line.new(LineFromDate, rth_low, LineToDate, rth_low, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  595. //line.delete(tl[1])
  596.  
  597. //th = line.new(LineFromDate, rth_high, LineToDate, rth_high, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  598. //line.delete(th[1])
  599.  
  600. //tm = line.new(LineFromDate, rth_mid, LineToDate, rth_mid, xloc=xloc.bar_time, color=midline_color, style=middle_line_style, width = sessionLineWidth)
  601. //line.delete(tm[1])
  602. // End Section
  603.  
  604. // End Condition
  605.  
  606. //Formula For Opening Range
  607. londonHighRes = london_rth_high
  608. londonLowRes = london_rth_low
  609.  
  610. LondonLineColor = color.new(color.white,100)
  611.  
  612. //Plot Statements For Opening Range Lines
  613. londonOpenRangeHigh = plot(timerange(timeframe.period, london_rth_fill_ses) > 0 and show_london_session and isBelowHourValidResolution() ? londonHighRes : na, color=LondonLineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  614. londonOpenRangeLow = plot(timerange(timeframe.period, london_rth_fill_ses) > 0 and show_london_session and isBelowHourValidResolution() ? londonLowRes : na, color=LondonLineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  615. bgcolor(time(timeframe.period, london_rth_fill_ses) > 0 and show_london_session and isBelowHourValidResolution() ? color.silver : na, transp=100, title="London Session Background Color")
  616. fill(londonOpenRangeHigh, londonOpenRangeLow, color=show_london_session and isBelowHourValidResolution() ? color.teal : na, transp=90, title="Fill London Range Color")
  617.  
  618. if show_london_session_rng and not inLondonSession and inLondonSession[1] and isBelowHourValidResolution()
  619. london_range := ((london_rth_high[1]-london_rth_low[1])/(syminfo.mintick))/10
  620. londonLabelTime = get_label_offset(inLondonSession)
  621.  
  622. label mLondonLabel = label.new(londonLabelTime, london_rth_low[1], "L = " + tostring(london_range), xloc.bar_time, yloc.price, color.new(color.black,100), label.style_labelup, ltext_color, llabelsize)
  623.  
  624. // End Sesction
  625.  
  626.  
  627. // Construct New York Session Range
  628. var ny_hi = 10e-10
  629. var ny_lo = 10e10
  630.  
  631. nyStartTimeDelta = 24 - ny_start_session_hour_int + 1
  632. nyEndTimeDelta = 24 - ny_end_session_hour_int + 1
  633.  
  634. startNyTimeAlignment() => (hour + nyStartTimeDelta) > 24? 0 : 1
  635. isNyStartTimeAlignment = startNyTimeAlignment()
  636.  
  637.  
  638. endNyTimeAlignment() => (hour) >= (ny_start_session_hour_int) and isNyStartTimeAlignment == 0? 0 : 1
  639. //endNyTimeAlignment() => (hour) >= (ny_start_session_hour_int) and (minute) >= (ny_start_session_minute_int - chart_time_period_int) and isNyStartTimeAlignment == 0? 0 : 1
  640. isNyEndTimeAlignment = endNyTimeAlignment()
  641.  
  642.  
  643. float ny_range = na
  644.  
  645. NyFromDate = timestamp(year, month, dayofmonth - isNyStartTimeAlignment, ny_start_session_hour_int, ny_start_session_minute_int)
  646. NyToDate = timestamp(year, month, dayofmonth - isNyEndTimeAlignment, ny_end_session_hour_int, ny_end_session_minute_int) - chart_time_period_int
  647.  
  648.  
  649. // When a new period begins, reset hi/lo.
  650. ny_hi := change(NyFromDate) ? srcHi : max(srcHi, ny_hi)
  651. ny_lo := change(NyFromDate) ? srcLo : min(srcLo, ny_lo)
  652.  
  653. inNySession = not na(time(timeframe.period, ny_rth_ses))
  654.  
  655. ny_rth_open_bar = open_bar(ny_rth_ses)
  656. ny_rth_is_open = is_open(ny_rth_ses)
  657. ny_rth_low = float(na)
  658. ny_rth_low := ny_rth_is_open ? ny_rth_open_bar ? low : min(ny_rth_low[1], low) : ny_rth_low[1]
  659. ny_rth_high = float(na)
  660. ny_rth_high := ny_rth_is_open ? ny_rth_open_bar ? high : max(ny_rth_high[1], high) : ny_rth_high[1]
  661. ny_rth_mid = avg(ny_rth_low, ny_rth_high)
  662.  
  663. if (show_ny_session and isValidResolution())
  664.  
  665. //if inSession
  666. // Build the Asian Box
  667. ntrl = line.new(NyFromDate, ny_rth_low, NyToDate, ny_rth_low, xloc=xloc.bar_time, color=nline_color, style=nbox_line_style, width = nboxLineWidth)
  668. line.delete(ntrl[1])
  669.  
  670. ntrh = line.new(NyFromDate, ny_rth_high, NyToDate, ny_rth_high, xloc=xloc.bar_time, color=nline_color, style=nbox_line_style, width = nboxLineWidth)
  671. line.delete(ntrh[1])
  672.  
  673. ntrm = line.new(NyFromDate, ny_rth_mid, NyToDate, ny_rth_mid, xloc=xloc.bar_time, color=nmidline_color, style=nmiddle_line_style, width = nsessionLineWidth)
  674. line.delete(ntrm[1])
  675.  
  676. nyStartBox = line.new(NyFromDate, ny_rth_high, NyFromDate, ny_rth_low, extend=extend.none, xloc=xloc.bar_time, color=nline_color, style=nbox_line_style, width=nboxLineWidth)
  677. line.delete(nyStartBox[1])
  678.  
  679. nyEndBox = line.new(NyToDate, ny_rth_high, NyToDate, ny_rth_low, extend=extend.none, xloc=xloc.bar_time, color=nline_color, style=nbox_line_style, width=nboxLineWidth)
  680. line.delete(nyEndBox[1])
  681. // End Section
  682.  
  683. //if not inSession and inSession[1]
  684.  
  685. //Apply the High / Low / Mid Session Lines for London / NY
  686. //tl = line.new(LineFromDate, rth_low, LineToDate, rth_low, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  687. //line.delete(tl[1])
  688.  
  689. //th = line.new(LineFromDate, rth_high, LineToDate, rth_high, xloc=xloc.bar_time, color=line_color, style=upperlower_line_style, width = sessionLineWidth)
  690. //line.delete(th[1])
  691.  
  692. //tm = line.new(LineFromDate, rth_mid, LineToDate, rth_mid, xloc=xloc.bar_time, color=midline_color, style=middle_line_style, width = sessionLineWidth)
  693. //line.delete(tm[1])
  694. // End Section
  695.  
  696. // End Condition
  697.  
  698. //Formula For Opening Range
  699. nyHighRes = ny_rth_high
  700. nyLowRes = ny_rth_low
  701.  
  702. NyLineColor = color.new(color.white,100)
  703.  
  704. //Plot Statements For Opening Range Lines
  705. nyOpenRangeHigh = plot(timerange(timeframe.period, ny_rth_fill_ses) > 0 and show_ny_session and isBelowHourValidResolution() ? nyHighRes : na, color=NyLineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  706. nyOpenRangeLow = plot(timerange(timeframe.period, ny_rth_fill_ses) > 0 and show_ny_session and isBelowHourValidResolution() ? nyLowRes : na, color=NyLineColor, style=plot.style_line, linewidth=0, show_last=5, editable=false)
  707. bgcolor(time(timeframe.period, ny_rth_fill_ses) > 0 and show_ny_session and isBelowHourValidResolution() ? color.silver : na, transp=100, title="New York Session Background Color")
  708. fill(nyOpenRangeHigh, nyOpenRangeLow, color=show_ny_session and isBelowHourValidResolution() ? color.silver : na, transp=90, title="Fill New York Range Color")
  709.  
  710. if show_ny_session_rng and not inNySession and inNySession[1] and isBelowHourValidResolution()
  711. ny_range := ((ny_rth_high[1]-ny_rth_low[1])/(syminfo.mintick))/10
  712. nyLabelTime = get_label_offset(inNySession)
  713.  
  714. label mNyLabel = label.new(nyLabelTime, ny_rth_low[1], "N = " + tostring(ny_range), xloc.bar_time, yloc.price, color.new(color.black,100), label.style_labelup, ntext_color, nlabelsize)
  715.  
  716. // End Sesction
  717.  
  718.  
  719.  
  720. getData(r, s) => security(syminfo.tickerid, r, s, barmerge.gaps_off, barmerge.lookahead_on)
  721.  
  722. pdh = getData('D', high[1])
  723. pdl = getData('D', low[1])
  724.  
  725. wh = getData('1W', high[0])
  726. wl = getData('1W', low[0])
  727.  
  728. lwh = getData('1W', high[1])
  729. lwl = getData('1W', low[1])
  730.  
  731. float pdh_label_price = na
  732. float pdl_label_price = na
  733. int checkSwitch = 1
  734.  
  735. if (is_new_day_switch_period())
  736. pdh_label_price := getData('D', high[1])
  737. pdl_label_price := getData('D', low[1])
  738. checkSwitch = 0
  739. else
  740. pdh_label_price := getData('D', high[0])
  741. pdl_label_price := getData('D', low[0])
  742. checkSwitch = 1
  743.  
  744.  
  745.  
  746. supportStartTimeDelta = 24 - start_session_hour_int + 1
  747. supportEndTimeDelta = 24 - start_session_hour_int + 1
  748.  
  749. supportStartTimeAlignment() => (hour + supportStartTimeDelta) > 24? 0 : 1
  750. isSupportStartTimeAlignment = supportStartTimeAlignment()
  751.  
  752. supportEndTimeAlignment() => (hour + supportEndTimeDelta) > 24? 1 : 0
  753. isSupportEndTimeAlignment = supportEndTimeAlignment()
  754.  
  755.  
  756.  
  757. //SupportFromStartWeekDate = timestamp(startWeekYear, startWeekMonth, startWeekDayofMonth - isSupportStartTimeAlignment, start_support_hour_int, start_support_minute_int)
  758. SupportFromStartWeekDate = timestamp(year, month, dayofmonth - isSupportStartTimeAlignment, start_support_hour_int, start_support_minute_int)
  759. SupportFromDate = timestamp(year, month, dayofmonth - isSupportStartTimeAlignment, start_support_hour_int, start_support_minute_int)
  760. SupportToDate = timestamp(year, month, dayofmonth + isSupportEndTimeAlignment, end_support_hour_int, end_support_minute_int) - chart_time_period_int
  761.  
  762. if (showPreviousDayHiLo and isBelowHourValidResolution())
  763.  
  764.  
  765.  
  766. // Build the Previous support line Box
  767. yesterdayHighLine = line.new(SupportFromDate, pdh, SupportToDate, pdh, xloc=xloc.bar_time, extend=extend.none, color=support_line_color, style=support_line_style, width = supportLineWidth)
  768. line.delete(yesterdayHighLine[1])
  769.  
  770. yesterdayLowLine = line.new(SupportFromDate, pdl, SupportToDate, pdl, xloc=xloc.bar_time, extend=extend.none, color=support_line_color, style=support_line_style, width = supportLineWidth)
  771. line.delete(yesterdayLowLine[1])
  772.  
  773.  
  774. pdCheckIsNewDay = is_new_day()
  775. // Show the label
  776. if (showHiLoPriceRange and pdCheckIsNewDay)
  777.  
  778. if (showHiLoPriceLabel)
  779. // Add Previous Day High
  780. label pdHi_label = label.new(time - (time-time[1])*15, pdh_label_price, "YH (" + tostring(((pdh_label_price-pdl_label_price)/(syminfo.mintick))/10) + ")", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_line_label_color, nlabelsize)
  781. label.delete(pdHi_label[1])
  782.  
  783. // Add Previous Day Low
  784. label pdLow_label = label.new(time - (time-time[1])*14, pdl_label_price, "YL", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_line_label_color, nlabelsize)
  785. label.delete(pdLow_label[1])
  786. else
  787. // Add Previous Day High
  788. label pdHi_label = label.new(time - (time-time[1])*15, pdh_label_price, tostring(((pdh_label_price-pdl_label_price)/(syminfo.mintick))/10), xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_line_label_color, nlabelsize)
  789. label.delete(pdHi_label[1])
  790.  
  791.  
  792.  
  793. if (showHiLoPriceLabel and not showHiLoPriceRange and pdCheckIsNewDay)
  794.  
  795. // Add Previous Day High
  796. label pdHi_label = label.new(time - (time-time[1])*14, pdh_label_price, "YH", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_line_label_color, nlabelsize)
  797. label.delete(pdHi_label[1])
  798.  
  799. // Add Previous Day Low
  800. label pdLow_label = label.new(time - (time-time[1])*14, pdl_label_price, "YL", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_line_label_color, nlabelsize)
  801. label.delete(pdLow_label[1])
  802.  
  803. if (showWeeklyHiLo and isBelowHourValidResolution())
  804.  
  805. // Build the week high lo support line Box
  806. weekHighLine = line.new(SupportFromStartWeekDate, wh, SupportToDate, wh, xloc=xloc.bar_time, extend=extend.none, color=support_week_line_color, style=support_line_style, width = supportLineWidth)
  807. line.delete(weekHighLine[1])
  808.  
  809. weekLowLine = line.new(SupportFromStartWeekDate, wl, SupportToDate, wl, xloc=xloc.bar_time, extend=extend.none, color=support_week_line_color, style=support_line_style, width = supportLineWidth)
  810. line.delete(weekLowLine[1])
  811.  
  812. // Show the label
  813. if (weeklyHiLoShowLabel and is_new_day())
  814.  
  815. // Add Week High
  816. label wkHi_label = label.new(time - (time-time[1])*14, wh, "WH", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_week_line_color, nlabelsize)
  817. label.delete(wkHi_label[1])
  818.  
  819. // Add Week Low
  820. label wkLow_label = label.new(time - (time-time[1])*14, wl, "WL", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_week_line_color, nlabelsize)
  821. label.delete(wkLow_label[1])
  822.  
  823. if (showLastWeeklyHiLo and isBelowHourValidResolution())
  824.  
  825. // Build the week high lo support line Box
  826. weekLastHighLine = line.new(SupportFromStartWeekDate, lwh, SupportToDate, lwh, xloc=xloc.bar_time, extend=extend.none, color=support_last_week_line_color, style=support_last_week_line_style, width = supportLastWeekLineWidth)
  827. line.delete(weekLastHighLine[1])
  828.  
  829. weekLastLowLine = line.new(SupportFromStartWeekDate, lwl, SupportToDate, lwl, xloc=xloc.bar_time, extend=extend.none, color=support_last_week_line_color, style=support_last_week_line_style, width = supportLastWeekLineWidth)
  830. line.delete(weekLastLowLine[1])
  831.  
  832. // Show the label
  833. if (lastWeeklyHiLoShowLabel and is_new_day())
  834.  
  835. // Add Week High
  836. label lwkHi_label = label.new(time - (time-time[1])*14, lwh, "PWH", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_last_week_line_label_color, nlabelsize)
  837. label.delete(lwkHi_label[1])
  838.  
  839. // Add Week Low
  840. //label wkLow_label = label.new(x=bar_index[4], y=lwl, text="PWL", color=color.new(color.black,100), style=label.style_none, textcolor=support_last_week_line_label_color, size=nlabelsize)
  841. label lwkLow_label = label.new(time - (time-time[1])*14, lwl, "PWL", xloc.bar_time, yloc.price, color.new(color.black,100), label.style_none, support_last_week_line_label_color, nlabelsize)
  842. label.delete(lwkLow_label[1])
  843.  
  844. // Show Hi / Low of Day Time
  845.  
  846.  
  847. //f_print(_txt) => var _lbl = label(na), label.delete(_lbl), _lbl := label.new(time + (time-time[1])*3, high, _txt, xloc.bar_time, yloc.price, size = size.large)
  848.  
  849. endOfDay = is_end_day()
  850. //rsi = rsi(close, 7)
  851. //hb = highestbars(rsi, 20)
  852.  
  853.  
  854. var highOfDayHour = 10e-10
  855. var highOfDayMinute = 10e-10
  856. var lowOfDayHour = 10e-10
  857. var lowOfDayMinute = 10e-10
  858.  
  859. lookbackLength = 95
  860.  
  861.  
  862. hb = highestbars(lookbackLength)
  863. highBarIndex = -hb
  864.  
  865. highBarTime = time[highBarIndex]
  866. highBarHour = hour[highBarIndex]
  867. highBarMinute = minute[highBarIndex]
  868.  
  869.  
  870. lb = lowestbars(lookbackLength)
  871. lowBarIndex = -lb
  872.  
  873. lowBarTime = time[lowBarIndex]
  874. lowBarHour = hour[lowBarIndex]
  875. lowBarMinute = minute[lowBarIndex]
  876.  
  877.  
  878. if (showHiLoTime and isValidResolution() and endOfDay)
  879.  
  880. highOfDayHour = highBarHour
  881. lowOfDayHour = lowBarHour
  882.  
  883. label.new(bar_index[10], high[highBarIndex], "HOD: " + tostring(highOfDayHour) + ":" + tostring(highBarMinute), style=label.style_none, textcolor=color.silver)
  884. label.new(bar_index[10], low[lowBarIndex], "LOD: " + tostring(lowOfDayHour) + ":" + tostring(lowBarMinute), style=label.style_none, textcolor=color.silver)
  885.  
  886. hourIndexNullHour = valuewhen(not na(highOfDayHour), highOfDayHour, 0)
  887.  
  888.  
  889. // Check whether an alert needs to be fired
  890.  
  891. // Alert for whether prices has closed outside the range
  892.  
  893. inTradableSession = not na(time(timeframe.period, trd_ses))
  894.  
  895. isCloseBelow = false
  896. isCloseAbove = false
  897.  
  898. //if (not inSession and inSession[1] and isBelowHourValidResolution())
  899. if (inTradableSession and close[1] >= rth_low and close < rth_low)
  900. isCloseBelow := true
  901.  
  902. if (inTradableSession and close[1] <= rth_high and close > rth_high)
  903. isCloseAbove := true
  904.  
  905.  
  906. alertcondition((isCloseBelow or isCloseAbove), title='Asian Range Break', message='Price has closed outside the Asian Session Range.')
  907.  
  908. // Debugger Section
  909. //
  910. f_print(_txt) => var _lbl = label(na), label.delete(_lbl), _lbl := label.new(time + (time-time[1])*3, high, _txt, xloc.bar_time, yloc.price, size = size.large)
  911. //
  912. //if (not inSession and inSession[1])
  913. //if (not inSession and (inLondonSession or inNySession))
  914. // f_print(tostring(rth_high) + "\n" + tostring(rth_low))
  915. //if (isCloseBelow or isCloseAbove)
  916. // f_print("Break Occured=" + trd_ses)
  917.  
  918. //f_print("ny_rth_fill_ses = " + ny_rth_fill_ses + "\nlondon_rth_ses=" + london_rth_ses + "\nny_rth_ses=" + ny_rth_ses + "\nisLondonEndTimeAlignment=" + tostring(isLondonEndTimeAlignment) + "\nlondon_start_session_minute_int=" + tostring(london_start_session_minute_int))
  919. //f_print("isEndTimeAlignment = " + tostring(isEndTimeAlignment) + " " + " isEndBoxTimeAlignment=" + tostring(isEndBoxTimeAlignment))
  920. //f_print("from Date = " + tostring(dayofmonth - 1 - isSupportStartTimeAlignment) + "\npd_rth_low = " + tostring(pd_rth_low) + "\nstart_support_hour_int = " + tostring(start_support_hour_int) + "\nhigh_range = " + tostring(high_range) + "\nlow_range=" + tostring(low_range))
  921. //f_print("rth_ses = " + (rth_ses) + "\nTimezone = " + syminfo.timezone + "\nisLondonEndTimeAlignment = " + tostring(isLondonEndTimeAlignment) + "\nlondon_end_session_hour_int = " + tostring(london_end_session_hour_int) + "\nisStartTimeAlignment = " + tostring(isStartTimeAlignment))
  922. //f_print("Bars since=" + tostring(round(barssince(not inSession[2]))) + " sess=")
Advertisement
Add Comment
Please, Sign In to add comment