pr0nster

Volatility Sars

pr0nster Mis à jour   
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
Notes de version:
I *believe* I fixed my formula. There is no logic for backtesting at the moment.
Notes de version:
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)
Script protégé
Ce script est publié en code source fermé et vous pouvez l'utiliser librement. Vous pouvez le préférer pour l'utiliser sur un graphique. Vous ne pouvez pas visualiser ou modifier son code source.
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?