pr0nster

Volatility Sars

pr0nster 已更新   
This script makes use of volatility stop in combination with parabolic sars and price over/under sma to visualize market conditions. I originally wrote it because I wanted something i could zoom all the way out with and easily get an idea at a glance which direction a market is headed. Try it, let me know what you think. Feedback is greatly appreciated!

Usage: Buy the red, sell the green
版本注释:
I *believe* I fixed my formula. There is no logic for backtesting at the moment.
版本注释:
flipped the arrows around.. green up arrows for buy.. red down arrows for sell, instead of vice versa.... heres the code for the script. if you guys make any changes and find them more suitable for you then feel free to share!

its not top secret, im not sure why i did not make it open... but heres the source anyways


//@version=3
study("Volatility Sars" , shorttitle="vsars_strat",overlay=true)

//---------- vstop --------------
vlength = input(50)
vmult = input(2)
atr_ = atr(vlength)

max1=0.0
min1=0.0
is_uptrend_prev = false
stop=0.0
vstop_prev=0.0
vstop1=0.0
is_uptrend=false
is_trend_changed=false
max_ = 0.0
min_ = 0.0
vstop=0.0

max1 := max(nz(max_), close)
min1 := min(nz(min_), close)


is_uptrend_prev := nz(is_uptrend, true)

stop := is_uptrend_prev ? max1 - vmult * atr_ : min1 + vmult * atr_
vstop_prev := nz(vstop)
vstop1 := is_uptrend_prev ? max(vstop_prev, stop) : min(vstop_prev, stop)
is_uptrend := close - vstop1 >= 0
is_trend_changed := is_uptrend != is_uptrend_prev
max_ := is_trend_changed ? close : max1
min_ := is_trend_changed ? close : min1
vstop := is_trend_changed ? is_uptrend ? max_ - vmult * atr_ : min_ + vmult * atr_ : vstop1
codiff = vstop - close
sarcolor = codiff < 0 ? red : green

//----------- psars ---------------------
start = input(0.015)
increment = input(0.015)
maximum = input(0.12)
out = sar(start, increment, maximum)

//----------- sma -----------------
sma = sma(close,20)

//----------- roc -----------------
source = close, length = input(3, minval=1)
roc = 100 * (source - source)/source
coroc = (codiff * 1) * roc

plotarrow(coroc, colorup = green, colordown = red, transp=40, minheight = 10, maxheight = 15,offset=1)
plot(out, color=sarcolor, style=circles, linewidth=3)
smap = plot(sma,color=(sma < ohlc4 ? green : red),linewidth=2,offset=-1)
ol = plot(open,color=(sma < ohlc4 ? green : red), linewidth=2,offset=-1)
fill(smap,ol)
受保护脚本
该脚本是闭源发布的,您可以自由使用它。您可以收藏它以在图表上使用。您无法查看或修改其源代码。
免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?