A request was made for a MTF (Multi Timeframe) version of the TOS Accumulation Swing Index. I use to rely on MTF indicators extensively. Using a higher agg, eliminated the little flubbles that would kick me out too early.
However, the downside of MTF indicator as part of an exit strategy is that you have to wait for the higher aggregation candle to close before the signal is confirmed and if a stock is headed south waiting for a 10-20min candle is a long wait. Therefore I do not use MTF indicators as part of my exit strategies. A non-MTF indicator combined with zscore is more efficient.
However, the downside of MTF indicator as part of an exit strategy is that you have to wait for the higher aggregation candle to close before the signal is confirmed and if a stock is headed south waiting for a 10-20min candle is a long wait. Therefore I do not use MTF indicators as part of my exit strategies. A non-MTF indicator combined with zscore is more efficient.
Code:
# TOS MTF AccumulationSwingIndex
#global variables
input agg = AggregationPeriod.TEN_MIN ;
def cclose = close(period = agg);
def oopen = open(period = agg);
def hhigh = high(period = agg);
def llow = low(period = agg);
#
input smaLength = 10;
def limit = 30;
def AbsHighClose = AbsValue(hhigh - cclose[1]);
def AbsLowClose = AbsValue(llow - cclose[1]);
def AbsCloseOpen = AbsValue(cclose[1] - oopen[1]);
def K = If(AbsHighClose >= AbsLowClose, AbsHighClose, AbsLowClose);
def R = If(AbsHighClose >= AbsLowClose,
If(AbsHighClose >= (hhigh - llow), AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen),
If(AbsLowClose >= (hhigh - llow), AbsLowClose - 0.5 * AbsHighClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen));
def nRes = If(R != 0,
(50 * (((cclose - cclose[1]) + 0.50 * (cclose - oopen) + 0.25 * (cclose[1] - oopen[1])) / R ) * K / limit) + if !IsNaN(nRes[1]) then nRes[1] else 0,
0 + if !IsNaN(nRes[1]) then nRes[1] else 0);
def ASI = nRes;
def sma = SimpleMovingAvg(ASI,smaLength);
# ########################################################
# charting and formatting
declare lower;
plot pASI = ASI;
pASI.SetLineWeight(3);
pASI.AssignValueColor(if asi>sma then Color.Green else Color.RED);
plot pSMA = sma;
pSMA.SetPaintingStrategy(PaintingStrategy.DASHES);
pSMA.SetLineWeight(1);
pSMA.AssignValueColor(Color.VIOLET);
DefineGlobalColor("bear", CreateColor(225, 0, 0)) ;
DefineGlobalColor("bull", CreateColor(0, 165, 0)) ;
AddCloud(pASI, pSMA, GlobalColor("bull"), GlobalColor("bear"));
Last edited: