Revised Combo Script with Divergences

TC1909 · study · 94 行 · 点赞 485 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=4
 
 
study(title="EMA CROSS WITH RSI AND STOCH", shorttitle="EMA RSI STOCH", format=format.price, precision=2, resolution="")
 
//RSI
 
lookback = input(title="Lookback", type=input.integer, defval=7)
rsiOB = input(title="RSI Overbought", type=input.integer, defval=70)
rsiOS = input(title="RSI Oversold", type=input.integer, defval=30)
rsiLen = input(title="RSI Length", type=input.integer, defval=7)
rsi = rsi(close, rsiLen)
 
plot(rsi, "RSI", color=#8E1599)
band1 = hline(80, "Upper Band", color=#C0C0C0)
band0 = hline(20, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=#9915FF, transp=90, title="Background")
 
//Stoch
 
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
plot(k, title="%K", color=#0094FF)
plot(d, title="%D", color=#FF6A00)
//h0 = hline(80, "Upper Band", color=#606060)
//h1 = hline(20, "Lower Band", color=#606060)
 
//EMA's
 
fastemalen = input(50, minval=1, title="Length")
fastemasrc = input(close, title="Source")
fastoffset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out = ema(fastemasrc, fastemalen)
//plot(out, title="EMA", color=color.red, offset=fastoffset)
 
slowemalen = input(100, minval=1, title="Length")
slowemasrc = input(close, title="Source")
slowoffset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
slowout = ema(slowemasrc, slowemalen)
//plot(slowout, title="EMA", color=color.green, offset=slowoffset)
 
//Keltner Channerl variable
 
length = input(100, minval=1)
mult = input(3.0, "Multiplier")
src = input(close, title="Source")
exp = input(true, "exponential")
BandsStyle = input("true range", options = ["range", "true range"], title="Bands Style")
esma(source, length)=>
	s = sma(source, length)
	e = ema(source, length)
	exp ? e : s
ma = esma(src, length)
range = BandsStyle == "true range" ? tr(true) : high - low
rangema = rma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
//c = color.blue
//u = plot(upper, color=#0094FF, title="Upper")
//plot(ma, color=#0094FF, title="Basis")
//l = plot(lower, color=#0094FF, title="Lower")
//fill(u, l, color=#0094FF, transp=95, title="Background")
 
Keltbuysignal = close < lower
Keltsellsignal = close > upper
 
//bgcolor(Keltbuysignal ? color.fuchsia : Keltsellsignal ? color.yellow : na, title="Kelt buy Signal", transp=60)
 
 
//EMA drawn to the chart
 
//plot(slowout, color=out > slowout ? color.green : color.red, linewidth=2)
 
 
 
//Market Exhasution
 
RSIsellsignal = rsi > rsiOB
STOCHsellsignal = k > rsiOB
EMA_sell = out > slowout
sellSignal = EMA_sell and RSIsellsignal and STOCHsellsignal and Keltsellsignal 
 
RSIbuysignal = rsi < rsiOS
STOCHbuysignal = k < rsiOS
EMA_buy = out < slowout
buySignal = EMA_buy and RSIbuysignal and STOCHbuysignal and Keltbuysignal
 
bgcolor(buySignal ? color.lime : sellSignal ? color.red : na, title="Trade Signal", transp=60)
 
alertcondition(buySignal, title="Buy Singal", message="Buy Signal for {{ticker}}")
alertcondition(sellSignal, title="Sell Signal", message="Sell Signal for {{ticker}}")

← 返回列表