codypd

Crude Roll Trade Simulator

271 0 19
EDIT: The screen cap was unintended with the script publication. The yellow arrow is pointing to a different indicator I wrote. The "Roll Sim" indicator is shown below that one. Yes I could do a different screen cap, but then I'd have to rewrite this and frankly I don't have time. END EDIT

If you have ever wanted to visualize the contango / backwardation pressure of a roll trade, this script will help you approximate it.

I am writing this description in haste so go with me on my rough explanations.

A "roll trade" is one involving futures that are continually rolled over into future months. Popular roll trade instruments are USO ( oil             futures ) and UVXY             (volatility futures ).

Roll trades suffer hits from contango but get rewarded in periods of backwardation. Use this script to track the contango / backwardation pressure on what you are trading.

That involves identifying and providing both the underlying indexes and derivatives for both the front and back month of the roll trade. What does that mean? Well the defaults simulate (crudely) the UVXY             roll trade: The folks at Proshares buy futures that expire 60 days away and then sell those 30 days later as short term futures (again, this is a crude description - see the prospectus) and we simulate that by providing the Roll Sim indicator the symbols VIX             and VXV             along with VIXY             and VIXM             . We also provide the days between the purchase and sale of the rolled futures contract (in sessions, which is 22 days by my reckoning).

The script performs ema smoothing and plots both the index lines ( VIX             and VXV             as solid lines in our case) and the derivatives ( VIXY             and VIXM             as dotted lines in our case) with the line graphs offset by the number of sessions between the buy and sell. The gap you see represents the contango / backwardation the derivative roll trades are experiencing and gives you an idea how much movement has to happen for that gap to widen, contract or even invert. The background gets painted red in periods of backwardation (when the longer term futures cost less than when sold as short term futures ).

Fortunately indexes are calibrated to the same underlying factors, so their values relative to each other are meaningful (ie VXV             of 18 and VIX             of 15 are based on the same calculation on premiums for S&P500             symbols, with VXV             being normally higher for time value). That means the indexes graph well without and adjustments needed. Unfortunately derivatives suffer contango / backwardation at different rates so the value of VIXY             vs VIXM             isn't really meaningful ( VIXY             may take a reverse split one year while VIXM             doesn't) ... what is meaningful is their relative change in value day to day. So I have included a "front month multiplier" which can be used to get the front month line "moved up or down" on the screen so it can be compared to the back month.

As a practical matter, I have come to hide the lines for the derivatives (like VIXY             and VIXM             ) and just focus on the gap changes between the indexes which gives me an idea of what is going on in the market and what contango/backwardation pressure is likely to exist next week.

Hope it is useful to you.
Remove from Favorite Scripts Add to Favorite Scripts
study("Roll Sim")

BMSYM=input(title="Back Month Symbol", type=symbol, defval="VXV")
BMETF=input(title="Back Month ETN", type=symbol, defval="VIXM")
FMSYM=input(title="Front Month Symbol", type=symbol, defval="VIX")
FMETF=input(title="Front Month ETN", type=symbol, defval="VIXY")
SYMOFFSET=input(title="Offset", type=integer, defval=22)
FMMULT=input(title="Front Month Multiplier", type=float, defval=1.0)



BMSYMPRICE = ema(security(BMSYM, period , close), SYMOFFSET)
FMSYMPRICE = ema(security(FMSYM, period , close), SYMOFFSET)

BMETFPRICE = ema(security(BMETF, period , close), SYMOFFSET)
FMETFPRICE = ema(security(FMETF, period , close), SYMOFFSET)


plotbm=plot(BMSYMPRICE, color=red, offset=SYMOFFSET)
plotfm=plot(FMMULT*FMSYMPRICE, color=black)

plotbme=plot(BMETFPRICE, style=circles, color=red, offset=SYMOFFSET)
plotfme=plot(FMMULT*FMETFPRICE, style=circles, color=black)

bgcolor(FMSYMPRICE> BMSYMPRICE[SYMOFFSET] ? red : white, 60 )
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out