bsharpe

Peaks&Valleys

348 2 47
For Peaks:
marks bars whose high is higher than <input> bars on either side

For Valleys:
marks bars whose low is lower than <input> bars on either side

<input> defaults to 13
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
study(title="Peaks&Valleys",shorttitle="P&V", overlay = true)
width = input(13)
p = 0
v = 0
for i = 0 to (width * 2)
    p := p + ((i == width) ? 0 : (high[i] < high[width] ? 1 : 0))
    v := v + ((i == width) ? 0 : (low[i] > low[width] ? 1 : 0))
plotshape((p == (width * 2)), offset = -width, style = shape.labeldown)
plotshape((v == (width * 2)), offset = -width, style = shape.labelup, location = location.belowbar )
I was very interested in this study, but it repaints :(
Reply
very interesting-does this study repaint? thanks
+3 Reply
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out