bsharpe

Peaks&Valleys

289 2 35
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
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
ประเทศไทย
Việt Nam
日本
한국
简体
繁體
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