Squeeze - Expansion Indicator - JD

Duyck · study · 67 行 · 点赞 1,268 · TradingView 原页

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

Pine Script

//@version=3
// The Squeeze-Expansion Indicator or SE indicator shows the contraction and expansion of the volatility of the price,
// it does this by evaluating the movement of the standard deviations of the price.
// This indicator can be use in a similar way to ADX and momentum indicators and can potentially keep you out of NO-TRADE zones
// It can also be used as an exit indicator to show when a move has likely lost momentum.
//
// color coding of the SE indicator
// -the BLUE area indicates the AMOUNT of SQUEEZE of the price deviations
// -the ORANGE area indicates the AMOUNT of EXPANSION of the price deviations
// -the highlighted (BLUE) line indicate SQUEEZE tightening
// -the highlighted (GREEN and RED) lines indicate the RELEASE
//
// - BLUE line rising indicates a likely bounce back if the price
// - GREEN/RED line rising indicates a likely continuation/breakout of the price
//
// JD.
//
// #NotTradingAdvice
// #DYOR
//
// I build thes indicators for myself and provide them open source, to use for free to use and improve upon,
// as I believe the best way to learn is toghether.
// If, however, you value these contributions, feel free to leave a little something in the tip-jar for my next coffee break ;-)
// BTC: 1G9xXYWSoxJR2ikkB7Px6RwBLC5pjHmwZD
 
study(title="Squeeze - Expansion Indicator - JD", shorttitle="SE indicator - JD", overlay=false)
//inputs
src = close
anchor=input(1,title="Anchor for deviations, 1 = sma, 2 = ema")
length = input(50, title="lookback length")
tf_mult = input(1, title="timeframe multiplier (usefull for quickly refecencing longer timerframes",minval=1)
color_bars = input(false, title="color price bars?")
 
//BB calculations
basis = anchor==1?sma(src, length*tf_mult):ema(src, length)
dev = stdev(src, length*tf_mult)
 
price=
 ohlc4>basis?
  (high-basis)*2/dev:
  (low-basis)*2/dev
 
// Squeez - Expansion Calculations
sq=5-dev/highest(dev,50)*5
top=dev/lowest(dev,50)-1
 
sq_color=
 rising(sq,1)?
  top<sq?color(teal,0):
  falling(top,1)?color(teal,25):olive:olive
p_sq=plot(sq,title="squeeze",linewidth=2,color=sq_color,transp=80)
 
top_color=
 rising(top,1)?
  top>sq?price>=0?color(lime,0):color(fuchsia,0):
  falling(sq,1)?price>=0?color(green,25):color(red,25):orange:orange
p_top=plot(top,title="top",linewidth=2,color=top_color,transp=85)
pm0=plot(0,style=circles,color=gray)
 
fill(p_top,pm0,color=rising(sq,1) and falling(top,1)?color(yellow,95):yellow,transp=90)
fill(p_sq,pm0,color=rising(sq,1) and falling(top,1)?color(teal,95):teal,transp=90)
 
plotshape(top[1]<sq[1] and top>=sq?top:na,title="release",style=shape.diamond,location=location.absolute,size=size.small,color=yellow)
plotshape(top[1]>sq[1] and top<=sq?top:na, title="contract",style=shape.diamond,location=location.absolute,size=size.small,color=purple,transp=0)
 
b_col=top_color==orange?white:top_color
barcolor(color_bars?b_col:na)

← 返回列表