j1O9SB

SuperTrend Oscillator

Version 3: Improved aesthetically, complete turnaround for the strategy with which to use this indicator.
Once again, thanks to BlindFreddy and ChrisMoody for the bits of code that were assembled into this indicator.
Make the chart yours using the share button for the indicator with barcolors functionality.
Changes from v2 and looking forward: Indicator now uses a 14 length SuperTrend with no ATR multiplier. This my preferred use and I'd be grateful to hear your case for a different length/multiplier. Removed the Bollinger Bands and retracement dots due to these being gimmicky and marginally useful. There may be a version 4 should a similar concept using a rate of change analysis turn out to be useful. I have also tried -in vain- to plot internal trend peaks as horizontal S/R levels. Please pm if you are willing to help in that respect.
Strategy: The indicator will display the trend as a red/green area. It measures the spread between the closing price and the SuperTrend line, much like a CCI (close and ma). When the area contracts warning bars of the opposite trend color will warn of a reversal. When this happens, these areas will either be defended, reviving the trend, or will break, causing a trend flip. SuperTrend is unique in that breaks are typically large candles, and that its levels, especially on Weekly, Daily, Hourly, Minute timeframes, these levels will be defended (think similar to a 200sma or a 21ema). The STO making new highs within (internal) a trend is an overextension sign.
CVX Example: This is not a full analysis of CVX's stock, just an example potential trades. On the posted chart I used a weekly and a daily STO.
Long 1:The weekly showed warnings and then flipped. The daily made a double bottom, showed warnings and then flipped the daily STO at trendline support.
Long 2:The weekly still shows an uptrend, the daily made a weak break to downtrend and reversed back upwards at trendline support, forming a double bottom. Note the conservative exit when the STO made an internal new high.
Long 3: looking forward on CVX stock, the current downtrend made a weak break and is showing sings of reversal (pin bar) at horizontal support. Go long on flip of the daily (conservative) or flip of the hourly (aggressive).
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//@version=2
study(title="SuperTrend Oscillator",shorttitle="STO",overlay=false)
//Inputs
spt_ures=input(false,title="Use Cutsom Resolution?")
spt_res=input(type=resolution,defval="D")
spt_lenw=input(200,title="Length Of Warning Range")
spt_len=input(14,title="SuperTrend Length")
spt_mult=input(1,title="SuperTrend Multiple")
colup=green
coldn=red
//SuperTrend
spt_atr=atr(spt_len)
spt_nsb=hl2+spt_atr*spt_mult
spt_nlb=hl2-spt_atr*spt_mult
spt_lb=close[1]>spt_lb[1]?max(spt_nlb,spt_lb[1]):spt_nlb
spt_sb=close[1]<spt_sb[1]?min(spt_nsb,spt_sb[1]):spt_nsb
spt_tdur=close>spt_sb[1]?1:close<spt_lb[1]?-1:nz(spt_tdur[1],1)
spt_td=spt_ures?(security(tickerid,spt_res,spt_tdur)):spt_tdur
spt_lvlur=(close-(spt_td==1?spt_lb:spt_sb))
spt_lvl=spt_ures?(security(tickerid,spt_res,spt_lvlur)):spt_lvlur
//Components
spt_lvlup=spt_td==1?spt_lvl:na
spt_lvldn=spt_td==-1?spt_lvl:na
spt_tdup=(spt_td==1)and(spt_td[1]==-1)
spt_tddn=(spt_td==-1)and(spt_td[1]==1)
spt_matrur=sma((tr),spt_lenw)
spt_matr=spt_ures?(security(tickerid,spt_res,spt_matrur)):spt_matrur
spt_lvlwup=(spt_lvlup<spt_matr)and(close<close[1])
spt_lvlwdn=(spt_lvldn>-spt_matr)and(close>close[1])
//Color
spt_col=spt_td==1?colup:coldn
spt_colhst=spt_tdup?colup:spt_tddn?coldn:spt_lvlwdn?colup:spt_lvlwup?coldn:na
//Plot
p0=plot(0,color=spt_col,style=line,linewidth=1,transp=0,title="Midline")
p1=plot(spt_lvlup,color=colup,style=linebr,linewidth=1,transp=0,title="Uptrend Line")
p2=plot(spt_lvldn,color=coldn,style=linebr,linewidth=1,transp=0,title="Downtrend Line")
plot(spt_lvl,color=spt_colhst,style=histogram,linewidth=2,transp=0,title="Trend Change")
fill(p0,p1,color=colup,transp=90)
fill(p0,p2,color=red,transp=90)