Repaints TICK Grid for ThinkOrSwim

Repaints

samer800

Moderator - Expert
VIP
Lifetime
W7NtZpW.png


I added trend options you may check and test it. * working only during regular trading hours.

Author message:
The Tick Index is a short-term barometer of internal market strength.
It shows the number of stocks trading on an uptick minus the number of stocks trading on a downtick, and is used by day traders to view the overall market sentiment at a given point in time.
It's categorized as a Breadth Indicator because it analyzes the "Breadth and Scope" of an entire Index.

CODE: - Update - added option to change the trading hours

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © TheMas7er and bmistiaen
#indicator('TICK Grid (TheMas7er)', 'TICK Grid')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
# update - option to enter the trading hours - 12/2022
declare lower;
#// Inputs
input startTime  = 0930;
input endTime    = 1600;
input index      = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};
input barColor   = no;
input EnableBackgroundColor = yes;
input showDynamicBand = yes;
input DynamicBandAgg = AggregationPeriod.DAY;
input ShowMaLine = yes;
input maType     = AverageType.WEIGHTED;
input maLength   = 53;
input smoothingType = AverageType.SIMPLE;
input trendLength = 10;

def na = Double.NaN;
def pos = if IsNaN(close) then na else Double.POSITIVE_INFINITY;
def neg = if IsNaN(close) then na else Double.NEGATIVE_INFINITY;
def RTH = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;

#--- Color
DefineGlobalColor("colorUp"  , CreateColor(76, 175, 80));
DefineGlobalColor("colorDown", Color.DARK_GRAY);
#---
def indexH;
def indexL;
def _ticko;
def _tickh;
def _tickl;
def _tickc;
switch (index) {
case Nasdaq:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK/Q");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK/Q");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK/Q");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK/Q");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK/Q",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK/Q",DynamicBandAgg);
case NYSE:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK",DynamicBandAgg);
case Russell2000:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKRL");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKRL");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKRL");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKRL");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKRL",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKRL",DynamicBandAgg);
case SnP500:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKSP");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKSP");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKSP");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKSP");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKSP",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKSP",DynamicBandAgg);
case DJIA:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKI");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKI");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKI");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKI");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKI",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKI",DynamicBandAgg);
case All_US:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKUS");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKUS");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKUS");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKUS");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKUS",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKUS",DynamicBandAgg);
}
#// Functions
##f_showLevel(_show, _level) =>
#script f_showLevel {
#    input _show = yes;
#    input _level = 1000;
#    def level = if _show then if _level then _level else Double.NaN else Double.NaN;
#    plot return = level;
#}
#// Levels
def hh = Average(highest(indexH,1),50);
def hl = Average(Lowest(indexH,2), 50);
def ll = Average(Lowest(indexl,1),50);
def lh = Average(highest(indexl,2),50);

def tickhi  = if showDynamicBand then if RTH then hl else na else na;
def tickhi1 = if showDynamicBand then if RTH then hh else na else na;
def ticklo  = if showDynamicBand then if RTH then lh else na else na;
def ticklo1 = if showDynamicBand then if RTH then ll else na else na;
def zeroAvg = (tickhi1 + ticklo1) / 2;

def ticko;
def tickh;
def tickl;
def tickc;
def avgo;
def avgh;
def avgl;
def avgc;
if RTH {
    ticko = if isNaN(_ticko) then _ticko[1] else _ticko;
    tickh = if isNaN(_tickh) then _tickh[1] else _tickh;
    tickl = if isNaN(_tickl) then _tickl[1] else _tickl;
    tickc = if isNaN(_tickc) then _tickc[1] else _tickc;
    avgo  = if isNaN(_ticko) then avgo[1] else _ticko;
    avgh  = if isNaN(_tickh) then avgh[1] else _tickh;
    avgl  = if isNaN(_tickl) then avgl[1] else _tickl;
    avgc  = if isNaN(_tickc) then avgc[1] else _tickc;
} else {
    ticko = na;
    tickh = na;
    tickl = na;
    tickc = na;
    avgo = avgo[1];
    avgh = avgh[1];
    avgl = avgl[1];
    avgc = avgc[1];
}
#// Plot Candles
def candleUp = tickc > ticko;

AddChart(high = if candleUp then tickh else na, low = tickl , open = tickc,  close = ticko,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorUp"));

AddChart(high = if !candleUp then tickh else na , low = tickl , open = ticko,  close = tickc,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorDown"));

#// Plot levels
#def count = (if(isNaN(tickh),0,1) + if(isNaN(tickl),0,1) + if(isNaN(tickc),0,1) + if(isNaN(ticko),0,1));
def inHigh  = avgh;
def inLow   = avgl;
def inClose = avgc;
def inOpen  = avgo;
def ohlc = (inHigh + inLow + inClose + inOpen) / 4;
def tickMa  = MovingAverage(maType,ohlc,maLength);
def maColor = MovingAverage(maType,tickMa,maLength);
def trendMa = MovingAverage(smoothingType,tickMa,trendLength);
plot Avg = if ShowMaLine and RTH then tickMa else na;
Avg.AssignValueColor(if Avg>maColor then Color.CYAN else
                     if Avg<maColor then Color.MAGENTA else Color.GRAY);


AddCloud(if RTH and tickMa>trendMa then pos else na, neg, Color.DARK_GREEN);
AddCloud(if RTH and tickMa<trendMa then pos else na, neg, Color.DARK_RED);

plot highTop = if !RTH then na else tickhi1;
highTop.SetDefaultColor(Color.GRAY);
plot highBot = if !RTH then na else tickhi;
highBot.SetDefaultColor(Color.GRAY);
highBot.SetStyle(Curve.SHORT_DASH);

plot ZeroLine = if !RTH then na else zeroAvg;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);

plot lowBot = if !RTH then na else ticklo1;
lowBot.SetDefaultColor(Color.GRAY);
plot lowTop = if !RTH then na else ticklo;
lowTop.SetDefaultColor(Color.GRAY);
lowTop.SetStyle(Curve.SHORT_DASH);

def extUp = tickMa>trendMa and tickMa>maColor;
def Up    = tickMa>trendMa and tickMa<maColor;
def extDn = tickMa<trendMa and tickMa<maColor;
def Dn    = tickMa<trendMa and tickMa>maColor;

AssignPriceColor(if !barColor then Color.CURRENT else
                 if extUp then Color.GREEN else
                 if up then Color.DARK_GREEN else
                 if extDn then Color.RED else
                 if Dn then Color.DARK_RED else Color.GRAY);

AssignBackgroundColor(if !EnableBackgroundColor then Color.CURRENT else if tickMa>trendMa then CreateColor(1,25,16) else if  tickMa<trendMa then CreateColor(38,0,0) else Color.CURRENT);


# --- END CODE
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

W7NtZpW.png


I added trend options you may check and test it. * working only during regular trading hours.

Author message:
The Tick Index is a short-term barometer of internal market strength.
It shows the number of stocks trading on an uptick minus the number of stocks trading on a downtick, and is used by day traders to view the overall market sentiment at a given point in time.
It's categorized as a Breadth Indicator because it analyzes the "Breadth and Scope" of an entire Index.

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © TheMas7er and bmistiaen
#indicator('TICK Grid (TheMas7er)', 'TICK Grid')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
declare lower;
#// Inputs
input index      = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};
input barColor   = yes;
input EnableBackgroundColor = yes;
input showDynamicBand = yes;
input DynamicBandAgg = AggregationPeriod.DAY;
input ShowMaLine = yes;
input maLength   = 53;
input smoothingType = AverageType.SIMPLE;
input trendLength = 10;


def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def RTH      = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0;

#--- Color
DefineGlobalColor("colorUp"  , CreateColor(76, 175, 80));
DefineGlobalColor("colorDown", Color.DARK_GRAY);
#---
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    def v = volume;
    def VWMA = SimpleMovingAvg(src * v, len) / SimpleMovingAvg(v, len);
    plot result = VWMA;
}
def indexH;
def indexL;
def _ticko;
def _tickh;
def _tickl;
def _tickc;
switch (index) {
case Nasdaq:
    _ticko = open("$TICK/Q");
    _tickh = high("$TICK/Q");
    _tickl = low("$TICK/Q");
    _tickc = close("$TICK/Q");
    indexH = high("$TICK/Q", Period=DynamicBandAgg);
    indexL = low("$TICK/Q", Period=DynamicBandAgg);
case NYSE:
    _ticko = open("$TICK");
    _tickh = high("$TICK");
    _tickl = low("$TICK");
    _tickc = close("$TICK");
    indexH = high("$TICK", Period=DynamicBandAgg);
    indexL = low("$TICK", Period=DynamicBandAgg);
case Russell2000:
    _ticko = open("$TIKRL");
    _tickh = high("$TIKRL");
    _tickl = low("$TIKRL");
    _tickc = close("$TIKRL");
    indexH = high("$TIKRL", Period=DynamicBandAgg);
    indexL = low("$TIKRL", Period=DynamicBandAgg);
case SnP500:
    _ticko = open("$TIKSP");
    _tickh = high("$TIKSP");
    _tickl = low("$TIKSP");
    _tickc = close("$TIKSP");
    indexH = high("$TIKSP", Period=DynamicBandAgg);
    indexL = low("$TIKSP", Period=DynamicBandAgg);
case DJIA:
    _ticko = open("$TIKI");
    _tickh = high("$TIKI");
    _tickl = low("$TIKI");
    _tickc = close("$TIKI");
    indexH = high("$TIKI", Period=DynamicBandAgg);
    indexL = low("$TIKI", Period=DynamicBandAgg);
case All_US:
    _ticko = open("$TIKUS");
    _tickh = high("$TIKUS");
    _tickl = low("$TIKUS");
    _tickc = close("$TIKUS");
    indexH = high("$TIKUS", Period=DynamicBandAgg);
    indexL = low("$TIKUS", Period=DynamicBandAgg);
}
#// Functions
#f_showLevel(_show, _level) =>
script f_showLevel {
    input _show = yes;
    input _level = 1000;
    def level = if _show then if _level then _level else Double.NaN else Double.NaN;
    plot return = level;
}
#// Levels
def hh = Average(highest(indexH,1),50);
def hl = Average(Lowest(indexH,2), 50);
def ll = Average(Lowest(indexl,1),50);
def lh = Average(highest(indexl,2),50);

def tickhi  = f_showLevel(showDynamicBand, hl);
def tickhi1 = f_showLevel(showDynamicBand, hh);
def ticklo  = f_showLevel(showDynamicBand, lh);
def ticklo1 = f_showLevel(showDynamicBand, ll);
def zero    = (tickhi1 + ticklo1) / 2;

def ticko;
def tickh;
def tickl;
def tickc;
if RTH {
    ticko = _ticko;
    tickh = _tickh;
    tickl = _tickl;
    tickc = _tickc;
} else {
    ticko = na;
    tickh = na;
    tickl = na;
    tickc = na;
}
#// Plot Candles
def candleUp = ticko < tickc;
AddChart(high = if candleUp then tickh else na, low = tickl , open = tickc,  close = ticko,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorUp"));

AddChart(high = if !candleUp then tickh else na , low = tickl , open = ticko,  close = tickc,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorDown"));

#// Plot levels
def ohlc = (tickh + tickl + tickc + ticko) / 4;
def tickMa = WMA(ohlc,maLength);
def maColor = WMA(tickMa,maLength);
def trendMa = MovingAverage(smoothingType,tickMa,trendLength);
plot Avg = if ShowMaLine then tickMa else na;
Avg.AssignValueColor(if Avg>maColor then Color.CYAN else
                     if Avg<maColor then Color.MAGENTA else Color.GRAY);


AddCloud(if tickMa>trendMa then pos else na, neg, Color.DARK_GREEN);
AddCloud(if tickMa<trendMa then pos else na, neg, Color.DARK_RED);

plot highBot = if IsNaN(close) then na else tickhi;
highBot.SetDefaultColor(Color.GRAY);
highBot.SetStyle(Curve.SHORT_DASH);
plot highTop = if IsNaN(close) then na else tickhi1;
highTop.SetDefaultColor(Color.GRAY);
plot ZeroLine = if IsNaN(close) then na else zero;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);
plot lowTop = if IsNaN(close) then na else ticklo;
lowTop.SetDefaultColor(Color.GRAY);
lowTop.SetStyle(Curve.SHORT_DASH);
plot lowBot = if IsNaN(close) then na else ticklo1;
lowBot.SetDefaultColor(Color.GRAY);

def extUp = tickMa>trendMa and tickMa>maColor;
def Up    = tickMa>trendMa and tickMa<maColor;
def extDn = tickMa<trendMa and tickMa<maColor;
def Dn    = tickMa<trendMa and tickMa>maColor;

AssignPriceColor(if !barColor then Color.CURRENT else
                 if extUp then Color.GREEN else
                 if up then Color.DARK_GREEN else
                 if extDn then Color.RED else
                 if Dn then Color.DARK_RED else Color.GRAY);

AssignBackgroundColor(if !EnableBackgroundColor then Color.CURRENT else if tickMa>trendMa then CreateColor(1,25,16) else if  tickMa<trendMa then CreateColor(38,0,0) else Color.CURRENT);


# --- END CODE
Thank You Samer800
 
for futures trading, the lines/background color red/ green do not show up till 10 AM ish on lower time frame. Can this be used for futures trading? thank you for sharing the indicator!
 
awesome, can we start this from 9:30 AM EST ? It starts from 10:30 EST
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © TheMas7er and bmistiaen
#indicator('TICK Grid (TheMas7er)', 'TICK Grid')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
# update - option to enter the trading hours - 12/2022
declare lower;
#// Inputs
input startTime  = 0930;
input endTime    = 1600;
input index      = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};
input barColor   = no;
input EnableBackgroundColor = yes;
input showDynamicBand = yes;
input DynamicBandAgg = AggregationPeriod.DAY;
input ShowMaLine = yes;
input maType     = AverageType.WEIGHTED;
input maLength   = 53;
input smoothingType = AverageType.SIMPLE;
input trendLength = 10;

def na = Double.NaN;
def pos = if IsNaN(close) then na else Double.POSITIVE_INFINITY;
def neg = if IsNaN(close) then na else Double.NEGATIVE_INFINITY;
def RTH = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;

#--- Color
DefineGlobalColor("colorUp"  , CreateColor(76, 175, 80));
DefineGlobalColor("colorDown", Color.DARK_GRAY);
#---
def indexH;
def indexL;
def _ticko;
def _tickh;
def _tickl;
def _tickc;
switch (index) {
case Nasdaq:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK/Q");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK/Q");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK/Q");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK/Q");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK/Q",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK/Q",DynamicBandAgg);
case NYSE:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK",DynamicBandAgg);
case Russell2000:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKRL");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKRL");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKRL");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKRL");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKRL",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKRL",DynamicBandAgg);
case SnP500:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKSP");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKSP");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKSP");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKSP");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKSP",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKSP",DynamicBandAgg);
case DJIA:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKI");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKI");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKI");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKI");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKI",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKI",DynamicBandAgg);
case All_US:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKUS");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKUS");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKUS");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKUS");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKUS",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKUS",DynamicBandAgg);
}
#// Functions
##f_showLevel(_show, _level) =>
#script f_showLevel {
#    input _show = yes;
#    input _level = 1000;
#    def level = if _show then if _level then _level else Double.NaN else Double.NaN;
#    plot return = level;
#}
#// Levels
def hh = Average(highest(indexH,1),50);
def hl = Average(Lowest(indexH,2), 50);
def ll = Average(Lowest(indexl,1),50);
def lh = Average(highest(indexl,2),50);

def tickhi  = if showDynamicBand then if RTH then hl else na else na;
def tickhi1 = if showDynamicBand then if RTH then hh else na else na;
def ticklo  = if showDynamicBand then if RTH then lh else na else na;
def ticklo1 = if showDynamicBand then if RTH then ll else na else na;
def zeroAvg = (tickhi1 + ticklo1) / 2;

def ticko;
def tickh;
def tickl;
def tickc;
def avgo;
def avgh;
def avgl;
def avgc;
if RTH {
    ticko = if isNaN(_ticko) then _ticko[1] else _ticko;
    tickh = if isNaN(_tickh) then _tickh[1] else _tickh;
    tickl = if isNaN(_tickl) then _tickl[1] else _tickl;
    tickc = if isNaN(_tickc) then _tickc[1] else _tickc;
    avgo  = if isNaN(_ticko) then avgo[1] else _ticko;
    avgh  = if isNaN(_tickh) then avgh[1] else _tickh;
    avgl  = if isNaN(_tickl) then avgl[1] else _tickl;
    avgc  = if isNaN(_tickc) then avgc[1] else _tickc;
} else {
    ticko = na;
    tickh = na;
    tickl = na;
    tickc = na;
    avgo = avgo[1];
    avgh = avgh[1];
    avgl = avgl[1];
    avgc = avgc[1];
}
#// Plot Candles
def candleUp = tickc > ticko;

AddChart(high = if candleUp then tickh else na, low = tickl , open = tickc,  close = ticko,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorUp"));

AddChart(high = if !candleUp then tickh else na , low = tickl , open = ticko,  close = tickc,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorDown"));

#// Plot levels
#def count = (if(isNaN(tickh),0,1) + if(isNaN(tickl),0,1) + if(isNaN(tickc),0,1) + if(isNaN(ticko),0,1));
def inHigh  = avgh;
def inLow   = avgl;
def inClose = avgc;
def inOpen  = avgo;
def ohlc = (inHigh + inLow + inClose + inOpen) / 4;
def tickMa  = MovingAverage(maType,ohlc,maLength);
def maColor = MovingAverage(maType,tickMa,maLength);
def trendMa = MovingAverage(smoothingType,tickMa,trendLength);
plot Avg = if ShowMaLine and RTH then tickMa else na;
Avg.AssignValueColor(if Avg>maColor then Color.CYAN else
                     if Avg<maColor then Color.MAGENTA else Color.GRAY);


AddCloud(if RTH and tickMa>trendMa then pos else na, neg, Color.DARK_GREEN);
AddCloud(if RTH and tickMa<trendMa then pos else na, neg, Color.DARK_RED);

plot highTop = if !RTH then na else tickhi1;
highTop.SetDefaultColor(Color.GRAY);
plot highBot = if !RTH then na else tickhi;
highBot.SetDefaultColor(Color.GRAY);
highBot.SetStyle(Curve.SHORT_DASH);

plot ZeroLine = if !RTH then na else zeroAvg;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);

plot lowBot = if !RTH then na else ticklo1;
lowBot.SetDefaultColor(Color.GRAY);
plot lowTop = if !RTH then na else ticklo;
lowTop.SetDefaultColor(Color.GRAY);
lowTop.SetStyle(Curve.SHORT_DASH);

def extUp = tickMa>trendMa and tickMa>maColor;
def Up    = tickMa>trendMa and tickMa<maColor;
def extDn = tickMa<trendMa and tickMa<maColor;
def Dn    = tickMa<trendMa and tickMa>maColor;

AssignPriceColor(if !barColor then Color.CURRENT else
                 if extUp then Color.GREEN else
                 if up then Color.DARK_GREEN else
                 if extDn then Color.RED else
                 if Dn then Color.DARK_RED else Color.GRAY);

AssignBackgroundColor(if !EnableBackgroundColor then Color.CURRENT else if tickMa>trendMa then CreateColor(1,25,16) else if  tickMa<trendMa then CreateColor(38,0,0) else Color.CURRENT);


# --- END CODE
 
for futures trading, the lines/background color red/ green do not show up till 10 AM ish on lower time frame. Can this be used for futures trading? thank you for sharing the indicator!
try the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © TheMas7er and bmistiaen
#indicator('TICK Grid (TheMas7er)', 'TICK Grid')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
# update - option to enter the trading hours - 12/2022
declare lower;
#// Inputs
input startTime  = 0930;
input endTime    = 1600;
input index      = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};
input barColor   = no;
input EnableBackgroundColor = yes;
input showDynamicBand = yes;
input DynamicBandAgg = AggregationPeriod.DAY;
input ShowMaLine = yes;
input maType     = AverageType.WEIGHTED;
input maLength   = 53;
input smoothingType = AverageType.SIMPLE;
input trendLength = 10;

def na = Double.NaN;
def pos = if IsNaN(close) then na else Double.POSITIVE_INFINITY;
def neg = if IsNaN(close) then na else Double.NEGATIVE_INFINITY;
def RTH = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;

#--- Color
DefineGlobalColor("colorUp"  , CreateColor(76, 175, 80));
DefineGlobalColor("colorDown", Color.DARK_GRAY);
#---
def indexH;
def indexL;
def _ticko;
def _tickh;
def _tickl;
def _tickc;
switch (index) {
case Nasdaq:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK/Q");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK/Q");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK/Q");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK/Q");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK/Q",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK/Q",DynamicBandAgg);
case NYSE:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK",DynamicBandAgg);
case Russell2000:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKRL");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKRL");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKRL");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKRL");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKRL",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKRL",DynamicBandAgg);
case SnP500:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKSP");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKSP");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKSP");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKSP");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKSP",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKSP",DynamicBandAgg);
case DJIA:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKI");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKI");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKI");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKI");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKI",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKI",DynamicBandAgg);
case All_US:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKUS");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKUS");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKUS");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKUS");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKUS",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKUS",DynamicBandAgg);
}
#// Functions
##f_showLevel(_show, _level) =>
#script f_showLevel {
#    input _show = yes;
#    input _level = 1000;
#    def level = if _show then if _level then _level else Double.NaN else Double.NaN;
#    plot return = level;
#}
#// Levels
def hh = Average(highest(indexH,1),50);
def hl = Average(Lowest(indexH,2), 50);
def ll = Average(Lowest(indexl,1),50);
def lh = Average(highest(indexl,2),50);

def tickhi  = if showDynamicBand then if RTH then hl else na else na;
def tickhi1 = if showDynamicBand then if RTH then hh else na else na;
def ticklo  = if showDynamicBand then if RTH then lh else na else na;
def ticklo1 = if showDynamicBand then if RTH then ll else na else na;
def zeroAvg = (tickhi1 + ticklo1) / 2;

def ticko;
def tickh;
def tickl;
def tickc;
def avgo;
def avgh;
def avgl;
def avgc;
if RTH {
    ticko = if isNaN(_ticko) then _ticko[1] else _ticko;
    tickh = if isNaN(_tickh) then _tickh[1] else _tickh;
    tickl = if isNaN(_tickl) then _tickl[1] else _tickl;
    tickc = if isNaN(_tickc) then _tickc[1] else _tickc;
    avgo  = if isNaN(_ticko) then avgo[1] else _ticko;
    avgh  = if isNaN(_tickh) then avgh[1] else _tickh;
    avgl  = if isNaN(_tickl) then avgl[1] else _tickl;
    avgc  = if isNaN(_tickc) then avgc[1] else _tickc;
} else {
    ticko = na;
    tickh = na;
    tickl = na;
    tickc = na;
    avgo = avgo[1];
    avgh = avgh[1];
    avgl = avgl[1];
    avgc = avgc[1];
}
#// Plot Candles
def candleUp = tickc > ticko;

AddChart(high = if candleUp then tickh else na, low = tickl , open = tickc,  close = ticko,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorUp"));

AddChart(high = if !candleUp then tickh else na , low = tickl , open = ticko,  close = tickc,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorDown"));

#// Plot levels
#def count = (if(isNaN(tickh),0,1) + if(isNaN(tickl),0,1) + if(isNaN(tickc),0,1) + if(isNaN(ticko),0,1));
def inHigh  = avgh;
def inLow   = avgl;
def inClose = avgc;
def inOpen  = avgo;
def ohlc = (inHigh + inLow + inClose + inOpen) / 4;
def tickMa  = MovingAverage(maType,ohlc,maLength);
def maColor = MovingAverage(maType,tickMa,maLength);
def trendMa = MovingAverage(smoothingType,tickMa,trendLength);
plot Avg = if ShowMaLine and RTH then tickMa else na;
Avg.AssignValueColor(if Avg>maColor then Color.CYAN else
                     if Avg<maColor then Color.MAGENTA else Color.GRAY);


AddCloud(if RTH and tickMa>trendMa then pos else na, neg, Color.DARK_GREEN);
AddCloud(if RTH and tickMa<trendMa then pos else na, neg, Color.DARK_RED);

plot highTop = if !RTH then na else tickhi1;
highTop.SetDefaultColor(Color.GRAY);
plot highBot = if !RTH then na else tickhi;
highBot.SetDefaultColor(Color.GRAY);
highBot.SetStyle(Curve.SHORT_DASH);

plot ZeroLine = if !RTH then na else zeroAvg;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);

plot lowBot = if !RTH then na else ticklo1;
lowBot.SetDefaultColor(Color.GRAY);
plot lowTop = if !RTH then na else ticklo;
lowTop.SetDefaultColor(Color.GRAY);
lowTop.SetStyle(Curve.SHORT_DASH);

def extUp = tickMa>trendMa and tickMa>maColor;
def Up    = tickMa>trendMa and tickMa<maColor;
def extDn = tickMa<trendMa and tickMa<maColor;
def Dn    = tickMa<trendMa and tickMa>maColor;

AssignPriceColor(if !barColor then Color.CURRENT else
                 if extUp then Color.GREEN else
                 if up then Color.DARK_GREEN else
                 if extDn then Color.RED else
                 if Dn then Color.DARK_RED else Color.GRAY);

AssignBackgroundColor(if !EnableBackgroundColor then Color.CURRENT else if tickMa>trendMa then CreateColor(1,25,16) else if  tickMa<trendMa then CreateColor(38,0,0) else Color.CURRENT);


# --- END CODE
 
try the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © TheMas7er and bmistiaen
#indicator('TICK Grid (TheMas7er)', 'TICK Grid')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
# update - option to enter the trading hours - 12/2022
declare lower;
#// Inputs
input startTime  = 0930;
input endTime    = 1600;
input index      = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};
input barColor   = no;
input EnableBackgroundColor = yes;
input showDynamicBand = yes;
input DynamicBandAgg = AggregationPeriod.DAY;
input ShowMaLine = yes;
input maType     = AverageType.WEIGHTED;
input maLength   = 53;
input smoothingType = AverageType.SIMPLE;
input trendLength = 10;

def na = Double.NaN;
def pos = if IsNaN(close) then na else Double.POSITIVE_INFINITY;
def neg = if IsNaN(close) then na else Double.NEGATIVE_INFINITY;
def RTH = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;

#--- Color
DefineGlobalColor("colorUp"  , CreateColor(76, 175, 80));
DefineGlobalColor("colorDown", Color.DARK_GRAY);
#---
def indexH;
def indexL;
def _ticko;
def _tickh;
def _tickl;
def _tickc;
switch (index) {
case Nasdaq:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK/Q");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK/Q");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK/Q");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK/Q");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK/Q",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK/Q",DynamicBandAgg);
case NYSE:
    _ticko = Fundamental(FundamentalType.OPEN, "$TICK");
    _tickh = Fundamental(FundamentalType.HIGH, "$TICK");
    _tickl = Fundamental(FundamentalType.LOW, "$TICK");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TICK");
    indexH = Fundamental(FundamentalType.HIGH, "$TICK",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TICK",DynamicBandAgg);
case Russell2000:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKRL");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKRL");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKRL");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKRL");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKRL",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKRL",DynamicBandAgg);
case SnP500:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKSP");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKSP");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKSP");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKSP");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKSP",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKSP",DynamicBandAgg);
case DJIA:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKI");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKI");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKI");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKI");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKI",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKI",DynamicBandAgg);
case All_US:
    _ticko = Fundamental(FundamentalType.OPEN, "$TIKUS");
    _tickh = Fundamental(FundamentalType.HIGH, "$TIKUS");
    _tickl = Fundamental(FundamentalType.LOW, "$TIKUS");
    _tickc = Fundamental(FundamentalType.CLOSE, "$TIKUS");
    indexH = Fundamental(FundamentalType.HIGH, "$TIKUS",DynamicBandAgg);
    indexL = Fundamental(FundamentalType.LOW, "$TIKUS",DynamicBandAgg);
}
#// Functions
##f_showLevel(_show, _level) =>
#script f_showLevel {
#    input _show = yes;
#    input _level = 1000;
#    def level = if _show then if _level then _level else Double.NaN else Double.NaN;
#    plot return = level;
#}
#// Levels
def hh = Average(highest(indexH,1),50);
def hl = Average(Lowest(indexH,2), 50);
def ll = Average(Lowest(indexl,1),50);
def lh = Average(highest(indexl,2),50);

def tickhi  = if showDynamicBand then if RTH then hl else na else na;
def tickhi1 = if showDynamicBand then if RTH then hh else na else na;
def ticklo  = if showDynamicBand then if RTH then lh else na else na;
def ticklo1 = if showDynamicBand then if RTH then ll else na else na;
def zeroAvg = (tickhi1 + ticklo1) / 2;

def ticko;
def tickh;
def tickl;
def tickc;
def avgo;
def avgh;
def avgl;
def avgc;
if RTH {
    ticko = if isNaN(_ticko) then _ticko[1] else _ticko;
    tickh = if isNaN(_tickh) then _tickh[1] else _tickh;
    tickl = if isNaN(_tickl) then _tickl[1] else _tickl;
    tickc = if isNaN(_tickc) then _tickc[1] else _tickc;
    avgo  = if isNaN(_ticko) then avgo[1] else _ticko;
    avgh  = if isNaN(_tickh) then avgh[1] else _tickh;
    avgl  = if isNaN(_tickl) then avgl[1] else _tickl;
    avgc  = if isNaN(_tickc) then avgc[1] else _tickc;
} else {
    ticko = na;
    tickh = na;
    tickl = na;
    tickc = na;
    avgo = avgo[1];
    avgh = avgh[1];
    avgl = avgl[1];
    avgc = avgc[1];
}
#// Plot Candles
def candleUp = tickc > ticko;

AddChart(high = if candleUp then tickh else na, low = tickl , open = tickc,  close = ticko,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorUp"));

AddChart(high = if !candleUp then tickh else na , low = tickl , open = ticko,  close = tickc,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colorDown"));

#// Plot levels
#def count = (if(isNaN(tickh),0,1) + if(isNaN(tickl),0,1) + if(isNaN(tickc),0,1) + if(isNaN(ticko),0,1));
def inHigh  = avgh;
def inLow   = avgl;
def inClose = avgc;
def inOpen  = avgo;
def ohlc = (inHigh + inLow + inClose + inOpen) / 4;
def tickMa  = MovingAverage(maType,ohlc,maLength);
def maColor = MovingAverage(maType,tickMa,maLength);
def trendMa = MovingAverage(smoothingType,tickMa,trendLength);
plot Avg = if ShowMaLine and RTH then tickMa else na;
Avg.AssignValueColor(if Avg>maColor then Color.CYAN else
                     if Avg<maColor then Color.MAGENTA else Color.GRAY);


AddCloud(if RTH and tickMa>trendMa then pos else na, neg, Color.DARK_GREEN);
AddCloud(if RTH and tickMa<trendMa then pos else na, neg, Color.DARK_RED);

plot highTop = if !RTH then na else tickhi1;
highTop.SetDefaultColor(Color.GRAY);
plot highBot = if !RTH then na else tickhi;
highBot.SetDefaultColor(Color.GRAY);
highBot.SetStyle(Curve.SHORT_DASH);

plot ZeroLine = if !RTH then na else zeroAvg;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);

plot lowBot = if !RTH then na else ticklo1;
lowBot.SetDefaultColor(Color.GRAY);
plot lowTop = if !RTH then na else ticklo;
lowTop.SetDefaultColor(Color.GRAY);
lowTop.SetStyle(Curve.SHORT_DASH);

def extUp = tickMa>trendMa and tickMa>maColor;
def Up    = tickMa>trendMa and tickMa<maColor;
def extDn = tickMa<trendMa and tickMa<maColor;
def Dn    = tickMa<trendMa and tickMa>maColor;

AssignPriceColor(if !barColor then Color.CURRENT else
                 if extUp then Color.GREEN else
                 if up then Color.DARK_GREEN else
                 if extDn then Color.RED else
                 if Dn then Color.DARK_RED else Color.GRAY);

AssignBackgroundColor(if !EnableBackgroundColor then Color.CURRENT else if tickMa>trendMa then CreateColor(1,25,16) else if  tickMa<trendMa then CreateColor(38,0,0) else Color.CURRENT);


# --- END CODE

Hi

for futures trading, which input index should we select??


input index = {Nasdaq,default NYSE, Russell2000, SnP500, DJIA, All_US};

thanks
 
@samer800 is this a 133 ticks or 233 ticks chart? or 1000 ? I just wasnt sure from the code thank you

No, this is not a tick chart with 133 ticks or 233 ticks or 1000
This MTF indicator plots an index which has the name "tick" in it.

The TICK(Q), also known as the Tick Index, measures market breathe. It is like a barometer for the overall health of the stock market. It measures the difference between the number of stocks that are trading higher (on an uptick) and the number of stocks that are trading lower (on a downtick) at any given moment throughout the trading day.

So, if there are more stocks rising in price than falling, the TICK(Q) will be positive. Conversely, if there are more stocks falling in price than rising, the TICK(Q) will be negative. Essentially, it provides a quick snapshot of whether the market is generally bullish or bearish at a particular time. This MTF indicator can be used on any intraday time chart.

It's a useful tool for traders to gauge market sentiment and make informed decisions about their trades based on the overall direction of the market at any given moment
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
366 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top