Eduardomm1

Untitled

May 31st, 2021 (edited)
1,424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. //@version=4
  2. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  3. // © EduardoMattje
  4.  
  5. study("Highs and lows", "HnL", true)
  6.  
  7. // Inputs
  8.  
  9. i_displayLimit = input(0, "Display limit", minval=0, tooltip="Keep this at 0 if you want to display all values.\nChange it to hide past values, up until the specified number.")
  10.  
  11. // Variable
  12.  
  13. getHigh(resolution) => security(syminfo.tickerid, resolution, high[1], lookahead=barmerge.lookahead_on)
  14. getLow(resolution) => security(syminfo.tickerid, resolution, low[1], lookahead=barmerge.lookahead_on)
  15.  
  16. yesterdayHigh = getHigh("D")
  17. yesterdayLow = getLow("D")
  18.  
  19. weekHigh = getHigh("W")
  20. weekLow = getLow("W")
  21.  
  22. monthHigh = getHigh("M")
  23. monthLow = getLow("M")
  24.  
  25. // Plots
  26.  
  27. plot(yesterdayHigh, "Yesterday's high", color.teal, style=plot.style_stepline, show_last=i_displayLimit)
  28. plot(yesterdayLow, "Yesterday's low", color.red, style=plot.style_stepline, show_last=i_displayLimit)
  29.  
  30. plot(weekHigh, "Last week's high", color.teal, 2, plot.style_stepline, show_last=i_displayLimit)
  31. plot(weekLow, "Last week's low", color.red, 2, plot.style_stepline, show_last=i_displayLimit)
  32.  
  33. plot(monthHigh, "Last month's high", color.teal, 4, plot.style_stepline, show_last=i_displayLimit)
  34. plot(monthLow, "Last month's low", color.red, 4, plot.style_stepline, show_last=i_displayLimit)
  35.  
Add Comment
Please, Sign In to add comment