pr0nster

Volatility Sars

pr0nster Updated   
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
Release Notes:
I *believe* I fixed my formula. There is no logic for backtesting at the moment.
Release Notes:
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)
Protected script
This script is published closed-source but you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?