xmd79

Volume Profile Channel

Jun 1st, 2023
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. // © Julien_Eche
  2.  
  3. //@version=5
  4. indicator("Volume Profile Channel", shorttitle="VP Channel", overlay=true)
  5.  
  6. // Variable declaration
  7. length = input(20, "Length of POC and High/Low Calculation")
  8. pocLineWidth = input.int(1, "POC Line Width", minval=1)
  9. showPOCLine = input(true, "Show POC Line")
  10.  
  11. // Retrieve values of classic Volume Profile indicators
  12. areaHigh = request.security(syminfo.tickerid, "D", high[1])
  13. areaLow = request.security(syminfo.tickerid, "D", low[1])
  14. poc = request.security(syminfo.tickerid, "D", close[1])
  15.  
  16. // Calculate the smoothed POC line and historical high/low with the specified length
  17. smoothedPOC = ta.sma(poc, length)
  18. rangeHigh = ta.highest(areaHigh, length)
  19. rangeLow = ta.lowest(areaLow, length)
  20.  
  21. // Plot the volume channel lines
  22. plot(showPOCLine ? smoothedPOC : na, color=color.silver, linewidth=pocLineWidth, title="Smoothed POC", style=plot.style_linebr)
  23. p1 = plot(rangeHigh, color=color.teal, linewidth=1, title="Upper Channel")
  24. p2 = plot(rangeLow, color=color.red, linewidth=1, title="Lower Channel")
  25. p0 = plot(smoothedPOC, color=color.rgb(0, 0, 0, 100), linewidth=1, title="Lower Channel")
  26.  
  27. // Fill the area between the upper and lower channel lines
  28. fill(p1, p0, color=color.new(color.teal, 90))
  29. fill(p2, p0, color=color.new(color.red, 90))
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment