Dontpanic_es

PriceChannel for D1 v1.0

//@version=2
strategy(title = "PriceChannel for D1 v1.0", shorttitle = "PriceChannel D1", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 0)

//Settings
needlong = input(true, "long")
needshort = input(true, "short")
slowlen = input(30, defval = 30, minval = 2, maxval = 200, title = "PriceChannel Period")
pcbars = input(1, defval = 1, minval = 1, maxval = 20, title = "PriceChannel Bars")
usecol = input(true, "Use color-filter")
usebod = input(true, "Use body-filter")
needbg = input(false, defval = false, title = "Need trend Background?")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
src = close

//PriceChannel
lasthigh = highest(src, slowlen)
lastlow = lowest(src, slowlen)
center = (lasthigh + lastlow) / 2

//Trend
ub = low > center ? 1 : 0
db = high < center ? 1 : 0
trend = sma(ub, pcbars) == 1 ? 1 : sma(db, pcbars) == 1 ? -1 : trend

//Body
body = abs(close - open)
abody = sma(body, 10)

//Signals
up = trend == 1 and (close < open or usecol == false) and (body > abody / 5 or usebod == false)
dn = trend == -1 and (close > open or usecol == false) and (body > abody / 5 or usebod == false)

//alert (не работает не выводится в окно напоминалок)
alertcondition(up, title="LG", message="в Лонг")
alertcondition(dn, title="SH", message="В шорт")

//Lines
plot(center, color = blue, linewidth = 3, transp = 0, title = "PriceChannel Center")

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 80)


//Trading
if up
strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if dn
strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()
Script apenas com convite

O acesso a este script é restrito aos usuários autorizados pelo autor e pode requerir pagamento. Você pode adicioná-lo a seus favoritos, mas só poderá utilizá-lo após solicitar permissão e obtê-la do autor. Contate Dontpanic_es para mais informações, ou siga as instruções do autor abaixo.

TradingView não sugere pagar por um script e usá-lo até que você confie 100% em seu autor e entenda como o script funciona. Em muitos casos você pode encontrar uma boa alternativa de código aberto gratuitamente nos Scripts da Comunidade.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?

Aviso: por favor leia antes de solicitar acesso