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
Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.

Хотите использовать этот скрипт на графике?
///@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)