Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study('Pivots High&Low', overlay=true)
- lenH = input(title='Length High', type=input.integer, defval=20, minval=1)
- lenL = input(title='Length Low', type=input.integer, defval=20, minval=1)
- fun(src, len, isHigh, _style, _yloc, _color) =>
- // len 이전 값 : src[len]
- // nz : 값이 없으면 0으로 만들어준다.
- p = nz(src[len])
- isFound = true
- for i = 0 to len * 2
- // High를 구할 때는, p 보다 큰 값이 있는지 확인한다.
- if isHigh and src[i] > p
- // 더 큰 값이 있으면 src[len] 은 Pivot High가 아니다.
- isFound := false
- // Low를 구할 때는, p 보다 작은 값이 있는지 확인한다.
- if not isHigh and src[i] < p
- // 더 작은 값이 있으면 src[len] 은 Pivot Low가 아니다.
- isFound := false
- if isFound
- // 새로 라벨을 생성한다.
- // x 좌표는 bar_index[len] : 현재 bar에서 len 이전
- label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
- line.new(bar_index[len], p, bar_index, p, extend=extend.right, color=_color)
- fun(high, lenH, true, label.style_labeldown, yloc.abovebar, color.red)
- fun(low, lenL, false, label.style_labelup, yloc.belowbar, color.lime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement