TradingView
BacktestRookies
3 Oca 2018 02:03

52 Week High/Low 

ASTRAZENECA PLC ORD USD0.25LSE

Açıklama

52 Week High / Low Indicator

A simple, unobtrusive indicator that can be used on any timeframe to display the 52 week high/low values.

Features

  • Works on any timeframe.
  • Unobtrusive: Simple horizontal lines showing only the current 52 week values.
  • Allows the user to select whether to calculate the 52-week values from candle close values or the respective highs/lows.


For full overview and code commentary - Visit the backtest-rookies website.
Yorumlar
I_quacker_I
Hi, thanks for this I've been using it for a while now and really comes in handy. Is there a way code a line X percentage down (User Adjustable) from the most recent 52 Week high? Would be great to quickly see pullback depth when flicking through charts.
MrNobodyUSA
Any way to make the lines stop on the applicable high and low candle?
dsumit
superb bro
sabankl87
How to change it to solid lines for 52W high and lows?
Pandorra
@BacktestRookies Great Job!
Could you kindly update this, to make indicator values settled based on Daily close (for the previous year). Not on Weekly close (or Hi/Lo)

Thank you very much
MMuthu4322
Can you kindly update this for Version 4?
MMuthu4322
I tried to convert and it does not work

// Weekly 52 High & Low
parameterWeeklyBars = input(defval=52, title="Number of weekly bars")
weeklyHH = security(syminfo.tickerid, "W", highest(high, parameterWeeklyBars), lookahead=barmerge.lookahead_on)
weeklyLL = security(syminfo.tickerid, "W", lowest(low, parameterWeeklyBars), lookahead=barmerge.lookahead_on)
weeklyHC = security(syminfo.tickerid, "W", highest(close, parameterWeeklyBars), lookahead=barmerge.lookahead_on)
weeklyLC = security(syminfo.tickerid, "W", lowest(close, parameterWeeklyBars), lookahead=barmerge.lookahead_on)
weeklyPlotHigh = parameterWeeklyBars == 0 or timeframe.isweekly or timeframe.ismonthly ? na :
parameterPrices == "Highs/Lows" ? weeklyHH : weeklyHC
weeklyPlotLow = parameterWeeklyBars == 0 or timeframe.isweekly or timeframe.ismonthly ? na :
parameterPrices == "Highs/Lows" ? weeklyLL : weeklyLC
plot(weeklyPlotHigh, title='52 Week High', trackprice=true, color=color.red, offset=-9999, linewidth=3)
plot(weeklyPlotLow, title='52 Week Low', trackprice=true, color=color.green, offset=-9999, linewidth=3)
MartinBrousseau
@MMuthu4322,

//@version=5
indicator("52 Week High/Low",shorttitle="52W",overlay=true)

high_low_close = input.string(defval="Highs/Lows", title="Base 52 week values on candle:", options=["Highs/Lows", "Close"] )

weekly_hh = request.security(syminfo.tickerid,"W", ta.highest(high,52), lookahead=barmerge.lookahead_on)
weekly_ll = request.security(syminfo.tickerid,"W", ta.lowest(low,52), lookahead=barmerge.lookahead_on)
weekly_hc = request.security(syminfo.tickerid,"W",ta.highest(close,52), lookahead=barmerge.lookahead_on)
weekly_lc = request.security(syminfo.tickerid,"W", ta.lowest(close,52), lookahead=barmerge.lookahead_on)

high_plot = high_low_close == "Highs/Lows" ? weekly_hh : weekly_hc
low_plot = high_low_close == "Highs/Lows" ? weekly_ll : weekly_lc

plot(high_plot, title='52 Week High', trackprice=true, color=color.orange, offset=-9999)
plot(low_plot, title='52 Week Low', trackprice=true, color=color.orange, offset=-9999)
MMuthu4322
@MartinBrousseau, Thank you.
dhanoo007cox
Thanks a bunch for sharing this code.
Daha Fazla