declare lower; # Inputs input TimeFrame = {default Day, Chart}; input symbol = "$TICK/Q"; # Using regular TICK for Nasdaq input showOnlyToday = yes; input extremeLevel = 2000; input warningLevel = 1000; input smoothingLength = 5; # Check aggregation period validity def cap = GetAggregationPeriod(); def errorInAggregation = TimeFrame == TimeFrame.Day and cap >= AggregationPeriod.WEEK; Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period"); # Get TICK data def tickValue = if !IsNaN(close(symbol)) then close(symbol) else 0; def tickHigh = if !IsNaN(high(symbol)) then high(symbol) else 0; def tickLow = if !IsNaN(low(symbol)) then low(symbol) else 0; # Calculate period index def yyyyMmDd = GetYYYYMMDD(); def periodIndx; switch (TimeFrame) { case Chart: periodIndx = 0; case Day: periodIndx = yyyyMmDd; } # Check for period rollover def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes); # Calculate Cumulative TICK def cumTick; if (isPeriodRolled) { cumTick = tickValue; } else { cumTick = cumTick[1] + tickValue; } # Calculate smoothed cumulative TICK def cumTickSmooth = Average(cumTick, smoothingLength); # Calculate rate of change (momentum) def tickMomentum = cumTick - cumTick[smoothingLength]; def accelerating = tickMomentum > tickMomentum[1]; def decelerating = tickMomentum < tickMomentum[1]; # Calculate TICK extremes for the day def dayHighTick = if isPeriodRolled then tickHigh else Max(tickHigh, dayHighTick[1]); def dayLowTick = if isPeriodRolled then tickLow else Min(tickLow, dayLowTick[1]); # Detect divergences with price def priceUp = close > close[smoothingLength]; def priceDown = close < close[smoothingLength]; def bullishDivergence = priceDown and cumTick > cumTick[smoothingLength] and cumTick < 0; def bearishDivergence = priceUp and cumTick < cumTick[smoothingLength] and cumTick > 0; # Market regime determination def strongBullish = cumTick > extremeLevel and accelerating; def bullish = cumTick > warningLevel; def strongBearish = cumTick < -extremeLevel and decelerating; def bearish = cumTick < -warningLevel; def neutral = AbsValue(cumTick) <= warningLevel; # Plot Cumulative TICK histogram plot CumTickPlot = cumTick; CumTickPlot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); CumTickPlot.SetLineWeight(3); CumTickPlot.AssignValueColor( if cumTick > extremeLevel then Color.GREEN else if cumTick > warningLevel then Color.DARK_GREEN else if cumTick < -extremeLevel then Color.RED else if cumTick < -warningLevel then Color.DARK_RED else Color.GRAY ); # Plot smoothed line plot SmoothedTick = cumTickSmooth; SmoothedTick.SetDefaultColor(Color.CYAN); SmoothedTick.SetLineWeight(2); # Plot momentum line (scaled) plot MomentumLine = tickMomentum * 0.1; MomentumLine.SetDefaultColor(Color.MAGENTA); MomentumLine.SetLineWeight(1); MomentumLine.SetStyle(Curve.SHORT_DASH); # Reference lines plot ExtremeHigh = extremeLevel; ExtremeHigh.SetDefaultColor(Color.DARK_GREEN); ExtremeHigh.SetStyle(Curve.SHORT_DASH); plot WarningHigh = warningLevel; WarningHigh.SetDefaultColor(Color.GRAY); WarningHigh.SetStyle(Curve.SHORT_DASH); plot ZeroLine = 0; ZeroLine.SetDefaultColor(Color.WHITE); ZeroLine.SetStyle(Curve.FIRM); plot WarningLow = -warningLevel; WarningLow.SetDefaultColor(Color.GRAY); WarningLow.SetStyle(Curve.SHORT_DASH); plot ExtremeLow = -extremeLevel; ExtremeLow.SetDefaultColor(Color.DARK_RED); ExtremeLow.SetStyle(Curve.SHORT_DASH); # Main action label AddLabel(yes, if strongBullish then "STRONG BUY PRESSURE - Ride Longs!" else if bullish and accelerating then "Bullish TICK - Long Bias" else if bullish and !accelerating then "Bullish Weakening - Watch Longs" else if strongBearish then "STRONG SELL PRESSURE - Ride Shorts!" else if bearish and decelerating then "Bearish TICK - Short Bias" else if bearish and !decelerating then "Bearish Weakening - Watch Shorts" else if neutral and tickMomentum > 200 then "Building Bullish Pressure" else if neutral and tickMomentum < -200 then "Building Bearish Pressure" else "Neutral TICK - No Edge", if strongBullish then Color.GREEN else if bullish then Color.DARK_GREEN else if strongBearish then Color.RED else if bearish then Color.DARK_RED else if neutral and AbsValue(tickMomentum) > 200 then Color.YELLOW else Color.GRAY ); # TICK stats label AddLabel(yes, "Cum TICK: " + Round(cumTick, 0) + " | " + "Current: " + Round(tickValue, 0) + " | " + "Day Range: " + Round(dayHighTick, 0) + "/" + Round(dayLowTick, 0), if cumTick > 0 then Color.GREEN else Color.RED ); # Divergence warnings AddLabel(bullishDivergence, "BULLISH DIVERGENCE: Price ↓ TICK ↑", Color.GREEN ); AddLabel(bearishDivergence, "BEARISH DIVERGENCE: Price ↑ TICK ↓", Color.RED ); # Extreme reading alerts AddLabel(AbsValue(cumTick) > extremeLevel, if cumTick > extremeLevel then "⚠ EXTREME BULLISH: Potential Exhaustion" else "⚠ EXTREME BEARISH: Potential Bounce", Color.YELLOW );