Intraday Tick- Market Breadth Indicator for ThinkorSwim

skynetgen

Well-known member
shared_CumulativeTick:
Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick.
#https://futures.io/thinkorswim/41392-cumulative-tick-script-2.html
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
# interesting code fore rolling periods
#skynetgen: coloration and explicit signals

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));

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.Line);
#CumTick.SetLineWeight(3);
CumTick.DefineColor("PosAndUp", Color.Green);
CumTick.DefineColor("PosAndDn", Color.Orange);
CumTick.DefineColor("NegAndDn", Color.Red);
CumTick.DefineColor("NegAndUP", Color.orange);


CumTick.AssignValueColor(
    if Cumtick>0 then
       ( if cumtick>cumtick[1] then CumTick.color("PosAndUp") else CumTick.color("PosAndDN"))
    else
      ( if cumtick>cumtick[1] then CumTick.color("NegAndUp") else CumTick.color("NegAndDN")));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3)); zero.hidetitle();
plot avgtick=average(cumtick,3);
plot xup=if avgtick crosses above 0 then 0 else double.nan;
plot xdn=if avgtick crosses below 0 then 0 else double.nan;
xup.setpaintingStrategy(paintingStrategy.ARROW_UP);xup.hideTitle();
xdn.setpaintingStrategy(paintingStrategy.ARROW_DowN);xdn.hideTitle();

shared_HorizontalTreshold_study:
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);



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

hockeycoachdoug

Member
2019 Donor
VIP
Is it possible to add to this and create something similar to TopTickTrader shown here TopTickTrader It would need to add paintbars for one thing. Also, they use the coloring of the paintbars to determine buying and selling pressure, and which side is in charge. They then apply this to stock symbols, which plot the underlying stock in what ever time increment, but paint the bar what ever color the Tick bias is( green or red in the examples). Seems like this could be a great addition to what you have already put together.
 

wtf_dude

Active member
Hey all,
Getting more into breadth signals and just expanding my knowledge base really... obviously there are so many options to choose from for signaling. I'm just curious which breadth or internal indices/indicators people rely on most often (most reliably)

-Advance/decline line
-Adv divided by Dec vs Adv - Dec
-$VOLSPD
-Mccllelan Osc and SI
etc etc etc

Seriously appreciate your feedback in advance.
 

Art

Member
Thanks @BenTen . I had these, but it didn't look like anything like the charts I posted above. I'll take another look at them. Thanks again.
 

BenTen

Administrative
Staff
VIP
@Art Ahh, I think I know what you wanted. There is an indicator in ThinkorSwim called Comparison. If you want to display any other tickers other than what you already have, that would be the way to go, especially if you want it as a lower study like the picture you shared.
 

Art

Member
@BenTen that's right - I wanted the lower study. Thinkorswim already has built-in AdvanceDecline Indicator NYSE line - posted below, I just wanted to add the rest

 
Last edited by a moderator:

Similar threads

Top