Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //@version=4
  2. study('Pivots High&Low', overlay=true)
  3.  
  4. lenH = input(title='Length High', type=input.integer, defval=20, minval=1)
  5. lenL = input(title='Length Low', type=input.integer, defval=20, minval=1)
  6.  
  7. fun(src, len, isHigh, _style, _yloc, _color) =>
  8. // len 이전 값 : src[len]
  9. // nz : 값이 없으면 0으로 만들어준다.
  10. p = nz(src[len])
  11. isFound = true
  12. for i = 0 to len * 2
  13. // High를 구할 때는, p 보다 큰 값이 있는지 확인한다.
  14. if isHigh and src[i] > p
  15. // 더 큰 값이 있으면 src[len] 은 Pivot High가 아니다.
  16. isFound := false
  17. // Low를 구할 때는, p 보다 작은 값이 있는지 확인한다.
  18. if not isHigh and src[i] < p
  19. // 더 작은 값이 있으면 src[len] 은 Pivot Low가 아니다.
  20. isFound := false
  21.  
  22. if isFound
  23. // 새로 라벨을 생성한다.
  24. // x 좌표는 bar_index[len] : 현재 bar에서 len 이전
  25. label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
  26. line.new(bar_index[len], p, bar_index, p, extend=extend.right, color=_color)
  27.  
  28.  
  29. fun(high, lenH, true, label.style_labeldown, yloc.abovebar, color.red)
  30. fun(low, lenL, false, label.style_labelup, yloc.belowbar, color.lime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement