I am trying to make a custom index that follow QQQ, here is my code:
declare lower;
input cutoff=4;
input sym1 = "aapl";
input sym2 = "msft";
input sym3 = "amzn";
input sym4 = "tsla";
input sym5 = "goog";
def v1=close(sym1)+open(sym1)+low(sym1)+high(sym1);
def v2=close(sym2)+open(sym2)+low(sym2)+high(sym2);
def v3=close(sym3)+open(sym3)+low(sym3)+high(sym3);
def v4=close(sym4)+open(sym4)+low(sym4)+high(sym4);
def v5=close(sym5)+open(sym5)+low(sym5)+high(sym5);
def curve=power((v1/4*v2/4*v3/4*v4/4*v5/4),1/5);
plot c= reference EhlersSuperSmootherFilter(curve, cutoff);
The code is a little messy, but basically i use OHLC/4 as price, and then take geometric average, raise to power 1/n, in this case, n=5 stocks. However, when i plot it on 1 min chart, there is some value missing as shown in below chart, i dunn really know why this happen. Appreciate if anyone can shed some light.
declare lower;
input cutoff=4;
input sym1 = "aapl";
input sym2 = "msft";
input sym3 = "amzn";
input sym4 = "tsla";
input sym5 = "goog";
def v1=close(sym1)+open(sym1)+low(sym1)+high(sym1);
def v2=close(sym2)+open(sym2)+low(sym2)+high(sym2);
def v3=close(sym3)+open(sym3)+low(sym3)+high(sym3);
def v4=close(sym4)+open(sym4)+low(sym4)+high(sym4);
def v5=close(sym5)+open(sym5)+low(sym5)+high(sym5);
def curve=power((v1/4*v2/4*v3/4*v4/4*v5/4),1/5);
plot c= reference EhlersSuperSmootherFilter(curve, cutoff);
The code is a little messy, but basically i use OHLC/4 as price, and then take geometric average, raise to power 1/n, in this case, n=5 stocks. However, when i plot it on 1 min chart, there is some value missing as shown in below chart, i dunn really know why this happen. Appreciate if anyone can shed some light.