This is a way to put the implied vol and historical vol chart on the same graph:

declare lower;

declare hide_on_intraday;

def IVLength = 30;

def HVLength = 20;

def longLength = 262;

def shortLength = 20;

def clLog = Log(close / close[1]);

def IVHVDiff = imp_volatility() – (StDev(clLog, shortLength) * Sqrt(shortLength * longLength / (shortLength – 1)));

plot iv = imp_volatility();

plot hv = (StDev(clLog, shortLength) * Sqrt(shortLength * longLength / (shortLength – 1)));