kvande97

Short VXX - OptionsRockstar

135
Backtesting Script
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

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?
//@version=2
strategy("Short VXX", overlay=true)
fastLength = input(5, title="Fast SMA Length")
slowLength = input(15, title="Slow SMA Length")
atrLength = input(14, title="ATR Length")
percentRisk = input(1, title="Percent Risk")
startYear = input(2014, title="Start Year")
price = close

mafast = sma(price, fastLength)
maslow = sma(price, slowLength)
atr = atr(atrLength)
risk = (percentRisk/100)
contracts = (strategy.equity*risk)/(atr/4)

plot(mafast, color=white)
plot(maslow, color=blue)

if(cross(mafast, maslow) and (mafast<maslow) and (year>=startYear))
    strategy.entry("VXX Short", strategy.short, qty=(contracts), comment="VXX Short")
strategy.exit("VXX Short", profit = atr*50, loss = atr*25, comment="VXX Exit")