Cumulative Tick Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Someone recently mentioned that the $TICK index can be used for trend confirmation. I just came across this post in the Yahoo thinkScript group so I thought I would share it here as well.

IudRf3E.png


Accumulative $TICK Meter

Code:
#Hint: The NYSE TICK represents, at any given moment, the net number of stocks in the broad market that are trading at their offer prices minus those trading at their bids. When the NYSE TICK becomes very positive, it means that traders are lifting offers in the broad market: buyers are quite aggressive. When the TICK becomes very negative, it means that traders are hitting bids in the broad market: sellers are very aggressive. \n The swings in the NYSE TICK during the day, then, represent relative swings in short-term trader sentiment. The beauty of the measure is that it is assessing what bulls and bears are actually doing in the marketplace; not what they report as their sentiment or what they try to fool others into believing. \n

declare lower;
def upper = no;
input hidecumtick = yes;
input symbol = "$TICK"; #HINT symbol: Default SYMBOL is $TICK (New York Stock Exchange). This can be changed to see the tick values for the Russel 2000, the NASDAQ and many others.
input period = 20;
input smooth = 5;
input lookback = 4;
input filter = 300;
def p = period;
def i = barNumber();
def na = double.nan;
#input usetrend = {"No", default "Yes"};
def usetrend = yes;
rec htick = if IsNaN(high(symbol)) then htick[1] else high("$TICK") ;
rec ltick = if IsNaN(low(symbol)) then ltick[1] else low("$TICK");
rec avgh = if i == 1 then htick else Max(filter, avgh[1] + 2 / (p + 1) * (htick - avgh[1]));
rec avgl = if i == 1 then ltick else Min(-filter, avgl[1] + 2 / (p + 1) * (ltick - avgl[1]));

def hi = high("$TICK");
def lo = low("$TICK");

plot Last = if IsNaN(close(symbol)[-1]) then close(symbol) else double.nan;

plot amean = if IsNaN(close) then na else (avgh + avgl) / 2;
def trendmean = if usetrend AND (htick > avgh OR ltick < avgl) then amean else 0;

def bull = if htick > avgh then htick - avgh  else 0;
def bear = if ltick < avgl then ltick - avgl  else 0;

rec ctick = if i == 1 then 0 else if IsNaN(htick) OR IsNaN(ltick) then ctick[1] else ctick[1] + bull + bear + trendmean;

def ctickavg = ExpAverage(ctick, smooth);
plot cumtick = if IsNaN(close) then na else ctickavg;
plot nettick = if IsNaN(close) then na else ctick;

plot zero = 0;
cumtick.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
AssignPriceColor(if !upper then color.current else if cumtick > cumtick[lookback] AND ltick < avgl then color.green else if cumtick > cumtick[lookback] then color.gray else if cumtick < cumtick[lookback] AND htick > avgh then color.red else color.gray);
cumtick.SetLineWeight(2);
def hcumtick=if !hidecumtick then cumtick else na;
def hzero=if !hidecumtick then zero else na;
AddCloud(hcumtick, hzero );
plot buy = if cumtick > cumtick[lookback] AND ltick < avgl then low - tickSize() else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then na else na;
plot sell = if cumtick > cumtick[lookback] AND ltick < avgl then na else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then high + tickSize() else na;

plot ahi = if IsNaN(close) then na else avgh;
plot alo = if IsNaN(close) then na else avgl;
plot hib = if hi < 0 then hi else na;
plot lob = if lo > 0 then lo else na;
plot phi = hi;
plot plo = lo;

buy.SetDefaultColor(color.green);
buy.SetPaintingStrategy(paintingStrategy.ARROW_UP);
sell.SetDefaultColor(color.red);
sell.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);

#plot zero=0;
#
# Formatting:
#
hib.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
hib.SetDefaultColor(color.black);
hib.SetLineWeight(5);
lob.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
lob.SetDefaultColor(color.black);
lob.SetLineWeight(5);

Last.SetDefaultColor(Color.white);
Last.SetPaintingStrategy(paintingStrategy.DASHES);
phi.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
phi.AssignValueColor(if hi > ahi then color.dark_GREEN else color.gray);
phi.SetLineWeight(5);
plo.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
plo.AssignValueColor(if lo < alo then color.dark_red else color.gray);
plo.SetLineWeight(5);
zero.SetDefaultColor(color.gray);
zero.SetLineWeight(1);
amean.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
amean.SetLineWeight(5);
amean.SetStyle(curve.POINTS);
ahi.SetDefaultColor(color.green);
ahi.SetStyle(curve.SHORT_DASH);
alo.SetDefaultColor(color.red);
alo.SetStyle(curve.SHORT_DASH);

#Hiding depending on if upper or lower
phi.setHiding(upper);
plo.setHiding(upper);
zero.setHiding(upper);
last.setHiding(upper);
hib.setHiding(upper);
lob.setHiding(upper);

ahi.setHiding(upper);
alo.setHiding(upper);
cumtick.setHiding(hidecumtick);
nettick.setHiding(hidecumtick);
buy.setHiding(!upper);
sell.setHiding(!upper);

amean.setHiding(upper);

Simple TICK Meter

Code:
##### Simple Tick
##### Made By Signet
##### Version 1.0
##### 11/22/2018
##### Revised 12/19/2018
#https://www.dummies.com/personal-finance/investing/day-trading/how-to-use-the-tick-and-trin-in-day-trading/
##http://tradingsmart.net/indicators/tick-trin-label/
#Hint: TICK and TRIN are two indicators that measure the general sentiment of the market. They can be used both to determine near term market movement. Theses indicators are not well know by traders. TRIN is a calculator, its formula is ((Advancing issues/declining issues) / (advancing volume/declining volume)), it's a contrarian indicator to detect overbought and oversold levels in the market.

#How to day trade with these indicators? TICK value between +200 and -300 indicate a neutral market sentiment. It became bullish when its value became higher than +200 and bearish when it is lower -300. Very bullish when its value is higher than +500 and very bearish when it is lower than -500. Note that when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon. Generally a rising TRIN is bearish and a falling TRIN is bullish. A TRIN value higher than 1 is bearish while bullish when it is below 0.9
declare lower;

plot HighTick = high("$tick");
plot LowTick = low ("$tick");
#plot ZeroLine = 0;
plot up = 800;
plot down = -1000;
plot Noise = 600;
plot Noise2 = -600;
Noise.SetDefaultColor(Color.dark_orange);
Noise2.SetDefaultColor(Color.dark_orange);
up.SetDefaultColor(Color.UPTICK);
down.SetDefaultColor(Color.UPTICK);
HighTick.AssignValueColor(if HighTick >= 800 then Color.UPTICK else Color.DOWNTICK );
HighTick.SetLineWeight(2);
HighTick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LowTick.AssignValueColor(if LowTick <= -1000 then Color.DOWNTICK else Color.DOWNTICK);
LowTick.SetLineWeight(2);
LowTick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

def Trin = close("$TRIN");
plot Zeroline = 0;
Zeroline.AssignValueColor(if Trin <= 1 then Color.GREEN else if Trin > 1 then Color.dark_Orange else Color.dark_GRAY);
Zeroline.SetLineWeight(2);
Zeroline.SetPaintingStrategy(PaintingStrategy.POINTS);

input show_Trin = yes;
AddLabel(show_Trin, Concat("$TRIN: ", Trin) + if Trin > 1 then " : Sellers Market" else if Trin < 1 then " : Buyers Market" else "", if Trin <= 1 then Color.dark_GREEN else Color.RED);
#A trin of less than 1.00 usually means that a lot of buyers are acting strongly. A trin above 1.00 indicates that the sellers are acting more strongly.
#
def Tick = close("$TICK");
#If the tick is a positive number, that’s good: The market as a whole has a lot of buying interest. A positive tick shows that most people in the market have a positive perspective right now. Extremes show a catalyst event, and this label will stay gray unless an extreme tick is present.
#
def NeutralMarket_Top = +200;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def NeutralMarket_Bottom = -300;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def BullishValue = +500;
#Hint BullishValue: Very bullish when its value is higher than +500.
def BearishValue = -500;
#Hint BullishValue: Very  bearish when it is lower than -500.
def Upper_Xtreme_Limit = 999;
#Hint Upper_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Lower_Xtreme_Limit = -999;
#Hint Lower_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Upper_Caution_Limit = 600;
#Hint Upper_Caution_Limit: Causes Label to change color when $TICK reaches this number.  
def Lower_Caution_Limit = -600;
#Hint Lower_Caution_Limit: Causes Label to change color when $TICK reaches this number.
input show_tick = yes;
AddLabel (show_tick, Concat("$TICK: ", Tick) +

if (close < NeutralMarket_Top and close > NeutralMarket_Bottom) then " Neutral Market"  else

if (close > NeutralMarket_Top and close < BullishValue ) then " Bullish Position" else

if (close > BullishValue and close < Upper_Caution_Limit)   then " Bullish Extreme" else

if close > Upper_Xtreme_Limit then " CAUTION Upper Extreme" else

if (close < NeutralMarket_Bottom and close > BearishValue ) then " Bearish Position" else

if (close < BearishValue and close > Lower_Caution_Limit) then " Bearish Extreme" else

if close < Lower_Xtreme_Limit then "  CAUTION Upper Extreme" else "",

if (close > 0 and close < NeutralMarket_Top ) then Color.DARK_GREEN else

if (close > NeutralMarket_Top and close < BullishValue ) then Color.dark_GREEN else

if (close > BullishValue and close < Upper_Caution_Limit)   then Color.dark_GREEN else

if (close > Upper_Caution_Limit and close < Upper_Xtreme_Limit)   then Color.blue else

if close > Upper_Xtreme_Limit   then Color.RED else

if (close < 0 and close > NeutralMarket_Bottom ) then Color.DARK_RED else

if (close < NeutralMarket_Bottom and close > BearishValue ) then Color.red else

if (close < BearishValue and close > Lower_Caution_Limit)   then Color.DARK_ORANGE else

if (close < Lower_Caution_Limit and close > Lower_Xtreme_Limit) then Color.RED else

if close < Lower_Xtreme_Limit then Color.RED else Color.dark_GRAY);

def A = close(“$UVOL”);
def D = close (“$DVOL”);

def C = close(“$ADVN”);
def E = close (“$DECN”);

#addlabel (yes, If ((C / E) / (A / D)) > 1 then "Trin Decline " else if  ((C / E) / (A / D)) < 1 then "Trin Advance" else "", If  ((C / E) / (A / D)) > 1 then color.red else if  ((C / E) / (A / D)) < 1 then color.green else color.gray);

$TICK and $TRIN Meters with Labels

Code:
##### Smart Tick
##### Made By Signet
##### Version 1.0
##### 11/22/2018
##### Revised 12/19/2018
#https://www.dummies.com/personal-finance/investing/day-trading/how-to-use-the-tick-and-trin-in-day-trading/
##http://tradingsmart.net/indicators/tick-trin-label/
#Hint: TICK and TRIN are two indicators that measure the general sentiment of the market. They can be used both to determine near term market movement. Theses indicators are not well know by traders. TRIN is a calculator, its formula is ((Advancing issues/declining issues) / (advancing volume/declining volume)), it's a contrarian indicator to detect overbought and oversold levels in the market.

#How to day trade with these indicators? TICK value between +200 and -300 indicate a neutral market sentiment. It became bullish when its value became higher than +200 and bearish when it is lower -300. Very bullish when its value is higher than +500 and very bearish when it is lower than -500. Note that when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon. Generally a rising TRIN is bearish and a falling TRIN is bullish. A TRIN value higher than 1 is bearish while bullish when it is below 0.9
#declare hide_on_daily;
Declare lower;
def NeutralMarket_Top = +200;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def NeutralMarket_Bottom = -300;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def BullishValue = +500;
#Hint BullishValue: Very bullish when its value is higher than +500.
def BearishValue = -500;
#Hint BullishValue: Very  bearish when it is lower than -500.
def Upper_Xtreme_Limit = 999;
#Hint Upper_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Lower_Xtreme_Limit = -999;
#Hint Lower_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Upper_Caution_Limit = 600;
#Hint Upper_Caution_Limit: Causes Label to change color when $TICK reaches this number.  
def Lower_Caution_Limit = -600;
#Hint Lower_Caution_Limit: Causes Label to change color when $TICK reaches this number.
 
Plot Tick = close("$TICK");
Plot Trin = close("$TRIN");
Trin.AssignValueColor(if Trin < 1 THEN COLOR.Uptick ELSE COLOR.Downtick);

plot Upper_Xtreme = if tick > Upper_Xtreme_Limit then Upper_Xtreme_Limit else double.nan;
Upper_Xtreme.AssignValueColor(COLOR.white);;
Upper_Xtreme.AssignValueColor(COLOR.white);

plot Upper_Limit = if tick > Upper_Caution_Limit then Upper_Caution_Limit else double.nan;
Upper_Limit.AssignValueColor(COLOR.RED);

plot Bullishbottom = NeutralMarket_Top;
Bullishbottom.AssignValueColor(COLOR.Green);

plot BullishTop = BullishValue;
BullishTop.AssignValueColor(COLOR.dark_Green);

plot BearishBottom = NeutralMarket_Bottom;
Bearishbottom.AssignValueColor(COLOR.Red);

plot BearishTop = BearishValue;
BearishTop.AssignValueColor(COLOR.dark_Red);

plot Lower_Limit = if tick < Lower_Caution_Limit then Lower_Caution_Limit else double.nan ;
Lower_Limit.AssignValueColor(COLOR.RED);

plot Lower_Xtreme = if tick < lower_Xtreme_Limit then lower_Xtreme_Limit else double.nan ;
Lower_Xtreme.AssignValueColor(COLOR.white);

Tick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Tick.DefineColor("Positive", Color.UPTICK);
Tick.DefineColor("Negative", Color.DOWNTICK);
tick.definecolor("Extreme", color.cyan);
tick.definecolor("neutral", color.gray);
tick.definecolor("bullish",color.blue);
tick.definecolor("bearish",color.dark_orange);
Tick.AssignValueColor(
if (Tick >= neutralMarket_bottom and tick <= neutralMarket_top)  then Tick.color("neutral") else
if (Tick > NeutralMarket_Top and tick < Upper_Caution_Limit) then Tick.color("Positive") else
if (Tick < NeutralMarket_bottom and tick > Lower_Caution_Limit) then Tick.color("Negative") else
if (Tick > Upper_Caution_Limit and tick < Upper_Xtreme_Limit)  then  Tick.color("Bullish")  else
if  (Tick < Lower_Caution_Limit and tick > Lower_Xtreme_Limit)  then  Tick.color("bearish")  else
if tick > Upper_Xtreme_Limit or tick < Lower_Xtreme_Limit then Tick.color("Extreme")
else Tick.color("neutral"));

#A trin of less than 1.00 usually means that a lot of buyers are acting strongly. A trin above 1.00 indicates that the sellers are acting more strongly.
INPUT SHOW_trin = YES;
AddLabel(SHOW_trin, Concat("$TRIN: ", Trin) + if trin > 1 then " : Sellers Market" else if trin < 1 then " : Buyers Market" else "", IF Trin <= 1 THEN COLOR.GREEN ELSE Color.Red);

#If the tick is a positive number, that’s good: The market as a whole has a lot of buying interest. A positive tick shows that most people in the market have a positive perspective right now. Extremes show a catalyst event, and this label will stay gray unless an extreme tick is present.
AddLabel (yes, Concat("$TICK: ", Tick) + if
        (Close < NeutralMarket_Top and
    Close > NeutralMarket_Bottom) then
" Neutral Market"  else if
        (Close > NeutralMarket_Top and
    Close < BullishValue ) then
" Bullish Market" else if
        (Close > BullishValue and
    Close < Upper_Caution_Limit) then
" Bullish Extreme" else if
    Close > Upper_Xtreme_Limit then
" CAUTION Upper Extreme" else if
        (Close < NeutralMarket_Bottom and
    Close > BearishValue ) then
" Bearish Position" else if
        (Close < BearishValue and
    Close > Lower_Caution_Limit) then
" Bearish Extreme" else if
    Close < Lower_Xtreme_Limit then
" CAUTION Upper Extreme" else "", if
        (Close > 0 and
    Close < NeutralMarket_Top ) then
Color.Dark_Green else if
        (Close > NeutralMarket_Top and
    Close < BullishValue ) then
Color.Green else if
        (Close > BullishValue and
    Close < Upper_Caution_Limit) then
Color.Light_Green else if
        (Close > Upper_Caution_Limit and
    Close < Upper_Xtreme_Limit) then
Color.Cyan else if
    Close > Upper_Xtreme_Limit then
Color.red else if
        (Close < 0 and
    Close > NeutralMarket_Bottom ) then
Color.Dark_red else if
        (Close < NeutralMarket_Bottom and
    Close > BearishValue ) then
Color.pink else if
        (Close < BearishValue and
    Close > Lower_Caution_Limit) then
Color.dark_Orange else if
        (Close < Lower_Caution_Limit and
    Close > Lower_Xtreme_Limit) then
Color.red else if
    Close < Lower_Xtreme_Limit then
Color.red else Color.Gray);

Learn more about the TICK index here.
 
Free cumulative tick indicator for anyone who wants it. The indicator references total net difference between all index stock up and down ticks.

Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
declare lower;
input TimeFrame = {default Day, Week, Month, Year, Chart};
input symbol = "$TICK";
def isInvalid = IsNaN(hlc3(symbol));
def price = If (isInvalid, 0, hlc3(symbol));
input showOnlyToday = YES;
input avePeriod1 = 10;
input avePeriod2 = 34;
input UseUpDownColors = yes;
def cap = GetAggregationPeriod();
def errorInAggregation =
TimeFrame == TimeFrame.Day and cap >= AggregationPeriod.WEEK or
TimeFrame == TimeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def year = GetYear();
def periodIndx;
switch (TimeFrame)
{
case Chart:
periodIndx = 0;
case Day:
periodIndx = yyyyMmDd;
case Week:
periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
case Month:
periodIndx = RoundDown(yyyyMmDd / 100, 0);
case Year:
periodIndx = Floor(year - First(year));
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def cum;
if (isPeriodRolled)
{
cum = price;
}
else
{
cum = cum[1] + price;
}
plot CumTick = if isInvalid then Double.NaN else cum;
CumTick.SetPaintingStrategy(PaintingStrategy.POINTS);
CumTick.SetLineWeight(3);
CumTick.DefineColor("Up", Color.GREEN);
CumTick.DefineColor("Down",  Color.RED);
CumTick.DefineColor("Default", GetColor(1));
CumTick.DefineColor("Empty",  Color.RED);

CumTick.AssignValueColor(if !UseUpDownColors then CumTick.Color("Default") else  if CumTick[0] > CumTick[1] then CumTick.Color("Up") else CumTick.Color("Down"));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3));


def TAve1 = Average(CumTick, avePeriod1);

plot TAvec1 =  if showOnlyToday and GetDay() == GetLastDay() then TAve1 else if !showOnlyToday then TAve1 else Double.NaN;
TAvec1.AssignValueColor(if TAve1 > TAve1[1] then Color.CYAN else Color.MAGENTA) ;

def TAve2 = Average(CumTick, avePeriod2);

plot TAvec2 =  if showOnlyToday and GetDay() == GetLastDay() then TAve2 else if !showOnlyToday then TAve2 else Double.NaN;
TAvec2.AssignValueColor(if TAve2 > TAve2[1] then Color.GREEN else Color.RED) ;
 

skynetgen

Well-known member
Code:
#for identicating close above/below horizontal threshold (like on  $tick or $ADD)

input threshold=400;
input location=1000;
input price=close;
def above= price > threshold;
def below= price< -threshold;


plot pabove=if above then location else double.nan;
pabove.setPaintingStrategy(paintingStrategy.TRIANGLES); pabove.setdefaultcolor(color.green);
pabove.setLineWeight(5);

plot pbelow=if below then -location else double.nan;
pbelow.setPaintingStrategy(paintingStrategy.TRIANGLES); pbelow.setdefaultcolor(color.red);
pbelow.setLineWeight(5);

addcloud(threshold,-threshold,color.gray, color.gray);

GZiSP6Q.png


Entire chart setup (as shown in screenshot)
https://tos.mx/3dD2VrT
 
Last edited by a moderator:

Brain Monkey

New member
I effing love these! I used the Smart Tick today. I switched it to declare upper and laid it over the top of my $TICK box. I went into setting, switched the candles to bars and turned down the opacity of the bars to about 25%. This is a global setting, that's why you have to switch it to bars. I use this a graph of the vix futures and a 1 min graph of the /es futures to give me a heads up in case there is a shift in the markets.
 

ball

New member
Did you ever test the script for $TICK and $TRIN Meters with Labels

???

The AddLabel section is wrong.

It is comparing "Close" against the value set for Extreme Tick (ie Upper_Extreme_Limit) before it decides on the text of the label.
That does not make any sense.

You need to compare the value of the TICK against the Extreme Tick Level
 

Rojo Grande

Member
VIP
Let me start with a disclaimer, I stink at descriptions, and I’m NOT the sharpest knife in the drawer. Now that that’s done, I’ve been playing with tick candles and was wondering if it possible to make a study that shows the minutes and/or seconds from the start of a candle to the start of the next candle, (how long it took to complete that particular candle). Maybe labels across the top of the chart that shows the times of the previous 5 candles. I was thinking this would be a way to gauge activity, without hovering over the candles to see the times. Something like one candle took 7 minutes, the next took 6 minutes thirty seconds, etc. Thanks for your time.
 

fpapedo

New member
VIP
Looking for script that would plot different color horizontal lines at tick extremes of 1000, 1200 and 1400. Anybody have anything like this?
 

spicytrader

New member
VIP
You don't need a script for that. All you have to do is draw price levels at those levels, format them or color-code them as you like and turn On the Left and Right extensions so that they stay on your TICK Chart.
 

TreeDT

New member
Anyone have any ideas of how to bring the equivalent of $TICK chart into a lower study? Ultimately, I would like to build a strategy so that changes in $TICK can be used, second by second or tick by tick. All of the studies that I've seen written have only been on closing price, but not within the bar itself. TICK is just the first example, I would like to use all of the market internals and create a strategy that shows buy/sell signals, but will also use some of the other studies pre-built and some found on this site.
 

2laggy4life

New member
I use a EdgeStudyCase Indicator which helps indicate potential for going long or shorting a stock, works pretty well actually for swing trading:

Code:
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here: tosindicators.com/supply-demand-edge
#Code written in 2019
#Full Youtube Tutorial here: https://youtu.be/RNtsjfHYWfs
#Credit to Ron Wikso for catching $TICK copy/paste error on lines 18 & 19
#Credit to Brent Wilderman for adding code that enables study to work w/ extended hours on and off


declare upper;
declare hide_on_daily;

input showTicks = yes;
input showAD = yes;

def regularSession = secondsFromTime(0930) > 0 && secondsTillTime(1600) > 0;

def hod = if regularSession then if (high > hod[1]) then high else hod[1] else high;
def lod = if regularSession then if (low < lod[1]) then low else lod[1] else low;

def highAD = if regularSession then if (high(symbol="$ADSPD") > highAD[1]) then high(symbol="$ADSPD") else highAD[1] else high(symbol="$ADSPD");
def lowAD = if regularSession then if (low(symbol="$ADSPD") < lowAD[1]) then low(symbol="$ADSPD") else lowAD[1] else low(symbol="$ADSPD");

def highTick = if regularSession then if (high(symbol="$TICK") > highTick[1]) then high(symbol="$TICK") else highTick[1] else high(symbol="$TICK");
def lowTick = if regularSession then if (low(symbol="$TICK") < lowTick[1]) then low(symbol="$TICK") else lowTick[1] else low(symbol="$TICK");

def currentHighAD = high(symbol="$ADSPD");
def currentLowAD = low(symbol="$ADSPD");
def currentHighTick = high(symbol="$TICK");
def currentLowTick = low(symbol="$TICK");

plot ADShortSignal = showAD && high == hod && currentHighAD < highAD;
ADShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ADShortSignal.SetDefaultColor(Color.WHITE);
ADShortSignal.SetLineWeight(1);

plot ADLongSignal = showAD && low == lod && currentLowAD > LowAD;
ADLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ADLongSignal.SetDefaultColor(Color.WHITE);
ADLongSignal.SetLineWeight(1);

plot TickShortSignal = showTicks && high == hod && currentHighTick < highTick;
TickShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TickShortSignal.SetDefaultColor(Color.RED);
TickShortSignal.SetLineWeight(2);

plot TickLongSignal = showTicks && low == lod && currentLowTick > lowTick;
TickLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TickLongSignal.SetDefaultColor(Color.LIGHT_GREEN);
TickLongSignal.SetLineWeight(2);

I think it was an indicator posted here some time ago.

I wanted to simply add a Scanner to check my watchlist for when this Study goes off to post an alert. I tried adding the following at the bottom:


Alert(currentLowAD, Sound.Ding);
Alert(lowtick,Sound.Ding);

And then made a Condition in the "Scan" to scan for whenever a ticker crosses this line.
It doesn't seem to be working, any help would be appreciated.

Also thoughts on this indicator? Is there anything better out?
 

BenTen

Administrative
Staff member
Staff
VIP
@2laggy4life I assume you want to add alerts for the arrows. If so, use the code below:

Code:
# Alerts
Alert(TickLongSignal, " ", Alert.Bar, Sound.Chimes);
Alert(TickShortSignal, " ", Alert.Bar, Sound.Bell);
Alert(ADLongSignal, " ", Alert.Bar, Sound.Chimes);
Alert(ADShortSignal, " ", Alert.Bar, Sound.Bell);
 

2laggy4life

New member
Thank you, I appreciate it, that's exactly what I want!

@BenTen Also does this mean that for the Scanner Custom Filter, it would be something like this?

close crosses SupplyDemandEdgeStudy4hrAlert()."TickLongSignal" or close crosses SupplyDemandEdgeStudy()."ADLongSignal"

I went through the thread, and saw many of the replies in there as well regarding Scanners. This study uses an arrow so I changed it to be "True"

The Alerts you posted, I added to a new Study called "SupplyDemandEdgeStudy4hrAlert" (because my intention is to use it for 4 hr) But to test it, I put it in a Scanner Filter for 5 minutes.

Jv3IZrN.png


It still doesn't seem to be working, any thoughts?
I put it in the Stock Hacker as well as Option Hacker to test, but running the scan, doesn't yield any results.

If I have the stock opened and staring at the ticker though, it works with the alerts you provided
9OnIwuB.png


But I just want the same thing scanning my watchlist.

InVuxUj.png


I've tried literally everything I could think of but with no success.

The study is creating an arrow at the Low of Day or High of Day, that "bar" doesn't exist otherwise.
So I figured if the study was "true" it would trigger, so I don't understand where the logic was wrong.

I tried other things just to see if I could get anything at all to display.
 
Last edited:

ILIKESTOCKS

New member
Free cumulative tick indicator for anyone who wants it. The indicator references total net difference between all index stock up and down ticks.

Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
declare lower;
input TimeFrame = {default Day, Week, Month, Year, Chart};
input symbol = "$TICK";
def isInvalid = IsNaN(hlc3(symbol));
def price = If (isInvalid, 0, hlc3(symbol));
input showOnlyToday = YES;
input avePeriod1 = 10;
input avePeriod2 = 34;
input UseUpDownColors = yes;
def cap = GetAggregationPeriod();
def errorInAggregation =
TimeFrame == TimeFrame.Day and cap >= AggregationPeriod.WEEK or
TimeFrame == TimeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def year = GetYear();
def periodIndx;
switch (TimeFrame)
{
case Chart:
periodIndx = 0;
case Day:
periodIndx = yyyyMmDd;
case Week:
periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
case Month:
periodIndx = RoundDown(yyyyMmDd / 100, 0);
case Year:
periodIndx = Floor(year - First(year));
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def cum;
if (isPeriodRolled)
{
cum = price;
}
else
{
cum = cum[1] + price;
}
plot CumTick = if isInvalid then Double.NaN else cum;
CumTick.SetPaintingStrategy(PaintingStrategy.POINTS);
CumTick.SetLineWeight(3);
CumTick.DefineColor("Up", Color.GREEN);
CumTick.DefineColor("Down",  Color.RED);
CumTick.DefineColor("Default", GetColor(1));
CumTick.DefineColor("Empty",  Color.RED);

CumTick.AssignValueColor(if !UseUpDownColors then CumTick.Color("Default") else  if CumTick[0] > CumTick[1] then CumTick.Color("Up") else CumTick.Color("Down"));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3));


def TAve1 = Average(CumTick, avePeriod1);

plot TAvec1 =  if showOnlyToday and GetDay() == GetLastDay() then TAve1 else if !showOnlyToday then TAve1 else Double.NaN;
TAvec1.AssignValueColor(if TAve1 > TAve1[1] then Color.CYAN else Color.MAGENTA) ;

def TAve2 = Average(CumTick, avePeriod2);

plot TAvec2 =  if showOnlyToday and GetDay() == GetLastDay() then TAve2 else if !showOnlyToday then TAve2 else Double.NaN;
TAvec2.AssignValueColor(if TAve2 > TAve2[1] then Color.GREEN else Color.RED) ;
How to put labels to this for an upper study? Ideas?
 

Similar threads

Top