tradingview指标公式分享

tradingview指标公式分享
下⾯免费分享⼀下我在tradingview上的两个指标公式。tradingview这个⽹站可以看全球⾦融资产,还是很推荐⼤家去试试的。这些公式是我受雷公lonecapital的启发,学习研究了很长时间才做出来的,花费了很多时间和⼼思在上⾯。分享出来是为了让⼤家更好的理解趋势,所以请不要消费我的指标公式。
需要说明的是,没有万能的指标,不要指望⼀个指标就让你稳定获利,重点是通过指标我们理解趋势的变化,掌握市场规律。对我的指标我也还有不满意的地⽅,以后可能会再改进,对我的指标有什么意见或者建议可以私信联系我。
喜欢的朋友可以点赞、点击“在看”、转发分享、打赏,感谢⽀持。
1、主图指标——均线公式
//公式来⾃⼩灰灰交易之旅
//添加20、50、100、200ema和sma双均线,竖线显⽰sma均线抵扣价位置,添加均线交叉信号和背景⾊显⽰均线多头或空头排列。
//@version=4
study(title="k200", overlay = true)
//绘制ema和sma均线
SMA10 = sma(close, 10)
plot(SMA10, ay, title="SMA10")
SMA20 = sma(close,20)
SMA50 = sma(close, 50)
plot(SMA50, ange, title="SMA50",linewidth=2)
SMA100 = sma(close, 100)
plot(SMA100, color=color.blue, title="SMA100",linewidth=2)
the world浏览器SMA200 = sma(close, 200)
plot(SMA200, , title="SMA200",linewidth=2)
EMA20 = ema(close,20)
常艳近况plot(EMA20, d, title="EMA20",style=plot.style_circles,linewidth=2)
EMA50 = ema(close, 50)
plot(EMA50, ange, title="EMA50",style=plot.style_circles,linewidth=2)
EMA100 = ema(close, 100)
plot(EMA100, color=color.blue, title="EMA100",style=plot.style_circles,linewidth=2)
EMA200 = ema(close, 200)
plot(EMA200, , title="EMA200",style=plot.style_circles,linewidth=2)
//添加抵扣价标签
x = input(20)
y = input(50)
z = input(100)
r = input(200)
close1 = close[x]
close2 = close[y]
close3 = close[z]
close4 = close[r]
// plot(close1,d,trackprice=true,transp=100,title='Title')
// plot(close2,ange,trackprice=true,transp=100,title='Title') // plot(close3,color=color.blue,trackprice=true,transp=100,title='Title') // plot(close4,,trackprice=true,transp=100,title='Title') l = w(bar_index-x, na, tostring(close[x]),
d,
textcolor=color.white,
style=close[x] > open[x] ? label.style_labeldown : label.style_labelup, yloc=close[x] > open[x] ? yloc.abovebar : yloc.belowbar
)
label.delete(l[1])
l2 = w(bar_index-y, na, tostring(close[y]),
SMN
ange,
textcolor=color.white,
style=close[y] > open[y] ? label.style_labeldown : label.style_labelup, yloc=close[y] > open[y] ? yloc.abovebar : yloc.belowbar
)
label.delete(l2[1])
l3 = w(bar_index-z, na, tostring(close[z]),
color=color.blue,
textcolor=color.white,
style=close[z] > open[z] ? label.style_labeldown : label.style_labelup, yloc=close[z] > open[z] ? yloc.abovebar : yloc.belowbar
)
diflabel.delete(l3[1])
l4 = w(bar_index-r, na, tostring(close[r]),
,
textcolor=color.white,
style=close[r] > open[r] ? label.style_labeldown : label.style_labelup, yloc=close[r] > open[r] ? yloc.abovebar : yloc.belowbar
)
label.delete(l4[1])
//均线交叉公式,计算均线交叉时所需第⼆天收盘价,如价格⼤于收盘价则均线⾦叉,否则为均线死叉,圆点为ema均线交叉所需收盘价,+号表⽰sma均线交叉所需收盘价。
青铜工艺ATR = atr(input(defval=20,title="ATR",type=input.integer))[1]
xl1=input(defval=20,title="xl1",type=input.integer)
xl2=input(defval=50,title="xl2",type=input.integer)
xl3=input(defval=100,title="xl3",type=input.integer)
xl4=input(defval=200,title="xl4",type=input.integer)
MAL1=sma(close, xl1)
MAL2 = sma(close, xl2)
MAL3 = sma(close, xl3)
MAL4 = sma(close, xl4)
EMAL1 = ema(close, xl1)
EMAL2 = ema(close, xl2)
EMAL3 = ema(close, xl3)
EMAL4 = ema(close, xl4)
x25=(xl1*xl2*(MAL2-MAL1)-xl1*close[xl2-1]+xl2*close[xl1-1])/(xl2-xl1)
plot((x25=close-5*ATR)?x25:na,"x25", color.fuchsia,style=plot.style_cross, linewidth=3,offset=1)
xe25=((xl1+1)*(xl2-1)*EMAL2-(xl2+1)*(xl1-1)*EMAL1)/(2*xl2-2*xl1)
plot((xe25=close-5*ATR)?xe25:na,"xe25", color.fuchsia,style=plot.style_circles, linewidth=3,offset=1)
x51=(xl2*xl3*(MAL3-MAL2)-xl2*close[xl3-1]+xl3*close[xl2-1])/(xl3-xl2)
plot((x51=close-5*ATR)?x51:na,"x51", color.aqua,style=plot.style_cross, linewidth=3,offset=1)
xe51=((xl2+1)*(xl3-1)*EMAL3-(xl3+1)*(xl2-1)*EMAL2)/(2*xl3-2*xl2)
plot((xe51=close-5*ATR)?xe51:na,"xe51", color.aqua,style=plot.style_circles, linewidth=3,offset=1)
x120=(xl3*xl4*(MAL4-MAL3)-xl3*close[xl4-1]+xl4*close[xl3-1])/(xl4-xl3)
plot((x120=close-5*ATR)?x120:na,"x120", ,style=plot.style_cross, linewidth=3,offset=1)
xe120=((xl3+1)*(xl4-1)*EMAL4-(xl4+1)*(xl3-1)*EMAL3)/(2*xl4-2*xl3)
plot((xe120=close-5*ATR)?xe120:na,"xe120", ,style=plot.style_circles, linewidth=3,offset=1)
//ema50、100、200均线多头排列则背景⾊变为绿⾊,ema50、100、200为空头排列则背景⾊变为红⾊,没有变⾊就是混沌区域,⾛势不明
aa=min(min(min(SMA20,EMA20),min(SMA50,EMA50)),min(SMA100,EMA100))
bb=max(max(max(SMA20,EMA20),max(SMA50,EMA50)),max(SMA100,EMA100))
plot(SMA20, color=bb-aa
plot(20000, title='EA', color=EMA50>=EMA100 and EMA100>=EMA200 ? : EMA50
//sma均线抵扣线
cond = barstate.islast
bh = close+5*ATR
bl=close-5*ATR
moveBar = input(0)
d0 = input(0) + moveBar
d1 = input(10) + moveBar
d2 = input(20) + moveBar
d3 = input(50) + moveBar
d4 = input(100) + moveBar
d5 = input(200) + moveBar
plot(cond?bh:na,ay,linewidth=2,offset=-d1,style=plot.style_histogram,transp=0) plot(cond?bh:na,d,linewidth=2,offset=-d2,style=plot.style_histogram,transp=0) plot(cond?bh:na,ange,linewidth=2,offset=-d3,style=plot.style_histogram,transp=0) plot(cond?bh:na,color=color.blue,linewidth=2,offset=-d4,style=plot.style_histogram,transp=0) plot(cond?bh:na,,linewidth=2,offset=-d5,style=plot.style_histogram,transp=0) 2、副图指标——乖离公式
// 乖离公式来⾃⼩灰灰交易之旅
//@version=3
study(title="dif_diverse")
//定义ema20、50、100、200均线
LengthEMA1 = input(20,minval=1)
EMA20 = ema(close, LengthEMA1)
LengthEMA2 = input(50,minval=1)
EMA50 = ema(close, LengthEMA2)
LengthEMA3 = input(100,minval=1)
EMA100 = ema(close, LengthEMA3)
LengthEMA4 = input(200,minval=1)
EMA200 = ema(close, LengthEMA4)
//收盘价与ema20均线之间的乖离
dif20=close/EMA20*100-100
//ema20与ema50均线之间的乖离
dif25=EMA20/EMA50*100-100
plot(dif25, color=orange, title="dif25", linewidth=2)
/
/ema50与ema100均线之间的乖离
dif51=EMA50/EMA100*100-100
plot(dif51, color=blue, title="dif51", linewidth=2)
//ema100与ema200均线之间的乖离
dif120=EMA100/EMA200*100-100
plot(dif120, color=green, title="dif120", linewidth=2)
//均线间的整体乖离
difxx=0.5*dif20+0.5*dif25+0.5*dif51+0.5*dif120
//根据整体乖离制作类似macd的图形
difxxagv=sma(difxx, 50)
dea = ema(difxx, 50)
macd=(difxx-dea)*2
//定义超卖超买区域,⼤于difmax为超买,⼩于difmin为超卖difmin=0.9*lowest(difxx,LengthEMA4)
克曼模型difmax=0.9*highest(difxx,LengthEMA4)
plot(difxx, color=black, title="difxx", linewidth=2)
plot(difxxagv, color=red, title="difxxagv", linewidth=2)
plot(macd,color=gray,title="macd",style=histogram)
plot(difmin, color=red, title="difmin",style=cross)
plot(difmax, color=blue, title="difmax",style=cross)
plot(0, color=purple, title="0")
下⾯是指标添加后的图形。

本文发布于:2024-09-20 17:30:56,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/720923.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:均线   指标   公式   交叉
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议