xmd79

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

May 22nd, 2023
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. //The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
  2. //I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
  3. //All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
  4. //Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
  5. //My scripts/indicators/ideas are only for educational purposes!
  6. //Copyright by Zeiierman
  7.  
  8. //@version=4
  9. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  10. // © Zeiierman
  11.  
  12. study("High & Low Of Custom Session - OpeningRange Breakout (Expo)", shorttitle="High/Low Of Custom Session (Expo)",overlay=true)
  13.  
  14. // Inputs
  15. my_session = input("1200-1300", type=input.session, title='Custom Session')
  16. Lines = input(false, title="Show High/Low Lines?")
  17. ExtendLine = input(true, title="Extend Session High/Low Lines?")
  18. FILL = input(true, title="Show Session BGcolor?")
  19.  
  20. // Determine if we are in a session
  21. in_session = time(timeframe.period, my_session)
  22. is_new_session(res, sess) =>
  23. t = time(res, sess)
  24. na(t[1]) and not na(t) or t[1] < t
  25.  
  26. new_session = is_new_session("1440", my_session)
  27.  
  28. // Start of Session
  29. is_newbar(res,sess) =>
  30. t = time(res,sess)
  31. not na(t) and (na(t[1]) or t > t[1])
  32. new = (is_newbar("1440", my_session) ? 1 : 0)
  33.  
  34. // Plot Start Of Session
  35. col_Start_of_Session = new_session and new==1? color.aqua:na
  36. plotshape(high, color=col_Start_of_Session, style=shape.circle, location= location.absolute, size=size.small, title="Start_of_Session")
  37.  
  38.  
  39. // In Session High/Low Calculations
  40. var float _low = close
  41. var float _high = close
  42.  
  43. _low := new_session? low : in_session ? min(low, _low[1]) : na
  44. _high := new_session ? high : in_session ? max(high, _high[1]) : na
  45.  
  46. col_low = _low == low? na: Lines?color.red:na
  47. col_high = _high== high? na:Lines? color.green:na
  48.  
  49. // Plot High/Low Line
  50. Low=plot(_low, style=plot.style_line, linewidth=1, color=col_low)
  51. High=plot(_high, style=plot.style_line, linewidth=1, color=col_high)
  52.  
  53. // BG Color
  54. Fill_col = FILL ? color.aqua:na
  55. fill(Low,High, color=Fill_col)
  56. //
  57.  
  58. // End of Session
  59. start_of_session_value = valuewhen((new==1),high,0)
  60. end_session_condition = start_of_session_value !=start_of_session_value[1]?0: in_session?1:0
  61. end_session = (end_session_condition == 0) and (end_session_condition[1]==1)? color.orange:na
  62. plotshape(close, color=end_session, location=location.absolute, style=shape.circle, size=size.small)
  63.  
  64. // Extend High/Low Session Lines
  65. v_extend_low = valuewhen((_low == low),low,0)
  66. col_v_extend_low = (end_session_condition == 0) and v_extend_low ==v_extend_low[1] and ExtendLine? color.red:na
  67. plot(v_extend_low, color=col_v_extend_low, title="Extend Low")
  68.  
  69. v_extend_high = valuewhen((_high == high),high,0)
  70. col_v_extend_high = (end_session_condition == 0) and v_extend_high ==v_extend_high[1] and ExtendLine? color.green:na
  71. plot(v_extend_high, color=col_v_extend_high, title="Extend High")
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment