bsharpe

Peaks&Valleys

239 1 28
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 )
very interesting-does this study repaint? thanks
+2 Reply
United States
United Kingdom
India
Deutschland
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
中国
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out