declare hide_on_daily; input n = 6; #hint n: Length for Momentum calculations. input CandleColor = yes; input TrendMarkers = no; input ShowData = yes; input TickSymb = {default "/nq"}; def tick = if IsNaN(close("$TIKSP")) then tick[1] else close("$TICK/Q"); def AD = if IsNaN(close("$ADSPD")) then AD[1] else close("$ADSPD"); def Breadth = if IsNaN(close("$VOLSPD")) then Breadth[1] else close("$VOLSPD"); def price = close; def Hrs = Floor(9.5 + SecondsFromTime(0930) / 60 / 60) - 1; def Min = ((9.5 + SecondsFromTime(930) / 60 / 60) % 1) * 60; def active = if SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0 then 1 else 0; def lowestAD = if Active and !Active[1] then AD else if Active and AD < lowestAD[1] then AD else lowestAD[1]; def AD_low_Time_Hrs = if AD == lowestAD then Hrs else AD_low_Time_Hrs[1]; def AD_low_Time_min = if AD == lowestAD then min else AD_low_Time_min[1]; def highestAD = if Active and !Active[1] then AD else if Active and AD > highestAD[1] then AD else highestAD[1]; def AD_high_Time_Hrs = if AD == highestAD then Hrs else AD_high_Time_Hrs[1]; def AD_high_Time_min = if AD == highestAD then min else AD_high_Time_min[1]; def sumAD = if Active and !Active[1] then AD else if Active then sumAD[1] + AD else sumAD[1]; def barLength = if Active and !Active[1] then 1 else if Active then barLength[1] + 1 else barLength[1]; def MA_AD = sumAD / barLength; def CumTick = fold i = 0 to active with p while active do CumTick[1] + tick; def CumTickMomo = (CumTick - Lowest(CumTick, n)) / (Highest(CumTick, n) - Lowest(CumTick, n)); def ADMomo = (AD - Lowest(AD, n)) / (Highest(AD, n) - Lowest(AD, n)); def BreadthMomo = (Breadth - Lowest(Breadth, n)) / (Highest(Breadth, n) - Lowest(Breadth, n)); def PriceMomo = (price - Lowest(price, n)) / (Highest(price, n) - Lowest(price, n)); plot QuadTrendUp = if PriceMomo > .5 then low - TickSize() else Double.NaN; QuadTrendUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP); QuadTrendUp.SetLineWeight(1); QuadTrendUp.SetDefaultColor(Color.GREEN); QuadTrendUp.SetHiding(!TrendMarkers); plot QuadTrendDn = if PriceMomo < .5 then high + TickSize() else Double.NaN; QuadTrendDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN); QuadTrendDn.SetLineWeight(1); QuadTrendDn.SetDefaultColor(Color.Black); QuadTrendDn.SetHiding(!TrendMarkers); AssignPriceColor(if CandleColor and !IsNaN(QuadTrendUp) then Color.Green else if CandleColor and !IsNaN(QuadTrendDn) then Color.Red else Color.CURRENT);