ShirokiHeishi

Trend v4.0 Another update

96
Yet another update, default settings can be customized to your needs. Be aware that while this is similar to the other versions, this can only repaint an active bar, but that slows it down by one period. You are warned. Be that as it may, the basic idea is the same; trying to capture the really strong moves into overbought or oversold territory as defined by Relative Strength index. In RSI mode, you can see the smoothing has slowed it down a bit, but warrants backtesting.
First green bar go long, First red bar go short, first white bar possible trend exhaustion. Or use crossovers and such, play with the inputs OB/OS, RSI length, signal length, tick length, swing length, as I said customize to your tastes. I offer no surety as to its efficacy, but we all learn.
Trade Responsibly,
Shiroki
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
//norepaint
study("Trend v4.0", overlay=true)
overlay = input(false, title="Show Trend Color?")
mode    = input(false, title="RSI mode?")
Period  = input(4, title="Length")
Period2 = input(10, title="Signal")
src     = input(ohlc4, title="Source", type=source)
up      = security(tickerid,period,rma(max(change(src), 0), Period),false)
down    = security(tickerid,period,rma(-min(change(src), 0), Period),false)
rsi     =  ema(down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)),Period2)
OB      = input(50)
OS      = input(50)
trend   = rsi>wma(rsi,Period2) and rsi>=OB?teal:rsi<wma(rsi,Period2) and rsi<=OS?maroon:na
trendid = rsi>wma(rsi,Period2) and rsi>=OB?1:rsi<wma(rsi,Period2)  and rsi<=OS?-1:0
p1      = input(defval=3,minval=2,title="Up length")
p2      = input(defval=3,minval=2, title="Down length")
p3      = input(8, title="Swing threshold", minval=0)
cross_s = cross(sma(hlc3,p1) , sma(hlc3,p2)[1])
tick = barssince(cross_s)
barcolor(overlay?trend:na, color=trend)
rsio    = rsi>=OB?rsi:rsi<=OS?rsi:na
plotshape(tick>=p3?tick:na, style=shape.square, color=white, transp=0, location=location.bottom)
plotshape(trendid==1?trendid:na, style=shape.square, color=tick>=p3?white:teal, location=location.bottom, transp=0)
plotshape(trendid==-1?trendid:na,style=shape.square, color=tick>=p3?white:maroon,location=location.bottom, transp=0)
plot(mode?rsi:na, color=white,linewidth=2, transp=0)
plot(mode?wma(rsi,Period2):na, color=maroon,linewidth=2, transp=0)
plot(mode?OB:na, color=#2F4F4F, transp=0)
plot(mode?OS:na, color=#2F4F4F, transp=0)