ETH vs BTC 200W SMA Overextension
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gjfsdrtytru

//@version=4
study("ETH vs BTC 200W SMA Overextension", "ETH/BTC 200W MA OX", overlay=false, resolution="D", max_bars_back=5000)

cycleLen = 1400
getMaLen = bar_index < cycleLen ? bar_index + 1 : cycleLen


ethSRC = security("BITSTAMP:ETHUSD","D",close)
ethSMA = sma(ethSRC,getMaLen)
ethOX = ethSRC/ethSMA

btcSRC = security("BITSTAMP:BTCUSD","D",close)
btcSMA = sma(btcSRC,getMaLen)
btcOX = btcSRC/btcSMA

OX = ethOX-btcOX
hotzone = OX-OX[20]

guideMid = color.new(color.black,50)
guideTop = color.new(color.purple,50)
guideLow = color.new(color.purple,50)

EQ = hline(0,"Equilibrium",guideMid,linestyle=hline.style_dashed)
OB = hline(2,"ETH More Overextended",guideTop,linestyle=hline.style_dashed)
OS = hline(-2,"BTC More Overextended",guideTop,linestyle=hline.style_dashed)
fill(OB,OS,color.purple,90)

plot(hotzone,color=color.purple)
BGcolour = hotzone > 2 ? color.new(color.red,90) : na
bgcolor(BGcolour, title="ETH Bubble")