Histogram Colors and Cumulative tick count

crscrs85

Member
i found a cumulative tick indicator that counts from market open to close (930-1600). I am trying to modify it to include pre and post market as well but it wont plot anything when i change the times to 400 and 2000.

I am also trying to modify it from a line to histo which i did successfully with green bars for values above zero and red below zero but i want to add dark green and dark red for increasing and decreasing values. If the hashtag is removed from line 15 the code works fine. All the DIFF is code i copied and pasted from the MACD for reference as i tried to modify it myself and line 17 is what i was working on to add the color to increasing or decreasing values.

thanks

# credit https://tosindicators.com/indicators/cumulative-tick

declare lower;

def newday = GetDay() != GetDay()[1];
def tickData = hlc3(symbol = "$TICK");
addlabel(yes, tickData, color.white);

#all time inputs are based off eastern standard time in TOS
def cumulativeTickValue = if SecondsTillTime(930) < 0 and SecondsTillTime(1600) > 0 then tickData + cumulativeTickValue[1] else 0;

plot cumulativeTickplot = if cumulativeTickValue != 0 then cumulativeTickValue else Double.NaN;
cumulativeTickplot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#cumulativeTickPlot.AssignValueColor(if cumulativeTickPlot > 0 then color.green else color.red);

#cumulativeTickplot.AssignValueColor(if cumulativeTickplot > 0 and cumulativeTickPlot > #cumulativeTickPlot[1] then color.green else if cumulativeTickplot > 0 then color.Dark_green if #cumulativeTickPlot < 0 and cumulativeTickplot < cumulativetickplot[1] then color.Dark.red if #culmulativeTickplot < 0 color.red


#Diff.SetDefaultColor(GetColor(5));
#Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Diff.SetLineWeight(3);
#Diff.DefineColor("Positive and Up", Color.GREEN);
#Diff.DefineColor("Positive and Down", Color.Dark_GREEN);
#Diff.DefineColor("Negative and Down", Color.RED);
#Diff.DefineColor("Negative and Up", Color.Dark_RED);
#Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else #Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else #Diff.color("Negative and Up"));

AddVerticalLine(newday, "", Color.GRAY, Curve.SHORT_DASH);
 
Solution
i found a cumulative tick indicator that counts from market open to close (930-1600). I am trying to modify it to include pre and post market as well but it wont plot anything when i change the times to 400 and 2000.

I am also trying to modify it from a line to histo which i did successfully with green bars for values above zero and red below zero but i want to add dark green and dark red for increasing and decreasing values. If the hashtag is removed from line 15 the code works fine. All the DIFF is code i copied and pasted from the MACD for reference as i tried to modify it myself and line 17 is what i was working on to add the color to increasing or decreasing values.

thanks

# credit...
i found a cumulative tick indicator that counts from market open to close (930-1600). I am trying to modify it to include pre and post market as well but it wont plot anything when i change the times to 400 and 2000.

I am also trying to modify it from a line to histo which i did successfully with green bars for values above zero and red below zero but i want to add dark green and dark red for increasing and decreasing values. If the hashtag is removed from line 15 the code works fine. All the DIFF is code i copied and pasted from the MACD for reference as i tried to modify it myself and line 17 is what i was working on to add the color to increasing or decreasing values.

thanks

# credit https://tosindicators.com/indicators/cumulative-tick

declare lower;

def newday = GetDay() != GetDay()[1];
def tickData = hlc3(symbol = "$TICK");
addlabel(yes, tickData, color.white);

#all time inputs are based off eastern standard time in TOS
def cumulativeTickValue = if SecondsTillTime(930) < 0 and SecondsTillTime(1600) > 0 then tickData + cumulativeTickValue[1] else 0;

plot cumulativeTickplot = if cumulativeTickValue != 0 then cumulativeTickValue else Double.NaN;
cumulativeTickplot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#cumulativeTickPlot.AssignValueColor(if cumulativeTickPlot > 0 then color.green else color.red);

#cumulativeTickplot.AssignValueColor(if cumulativeTickplot > 0 and cumulativeTickPlot > #cumulativeTickPlot[1] then color.green else if cumulativeTickplot > 0 then color.Dark_green if #cumulativeTickPlot < 0 and cumulativeTickplot < cumulativetickplot[1] then color.Dark.red if #culmulativeTickplot < 0 color.red


#Diff.SetDefaultColor(GetColor(5));
#Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Diff.SetLineWeight(3);
#Diff.DefineColor("Positive and Up", Color.GREEN);
#Diff.DefineColor("Positive and Down", Color.Dark_GREEN);
#Diff.DefineColor("Negative and Down", Color.RED);
#Diff.DefineColor("Negative and Up", Color.Dark_RED);
#Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else #Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else #Diff.color("Negative and Up"));

AddVerticalLine(newday, "", Color.GRAY, Curve.SHORT_DASH);


this will draw a colored histogram
i added a check to see if tick is an error, to avoid working with nan values from it.


Code:
# histo_tick_count_00b

# https://usethinkscript.com/threads/histogram-colors-and-cumulative-tick-count.13542/
# Histogram Colors and Cumulative tick count
# credit https://tosindicators.com/indicators/cumulative-tick

declare lower;

def newday = GetDay() != GetDay()[1];
AddVerticalLine(newday, "", Color.GRAY, Curve.SHORT_DASH);

#def tickData = hlc3(symbol = "$TICK");
def tickData = if isnan(hlc3(symbol = "$TICK")) then 0 else hlc3(symbol = "$TICK");

addlabel(yes, tickData, color.white);

#input start = 0930;
#input end = 1600;
input start = 0400;
input end = 2000;

#all time inputs are based off eastern standard time in TOS
def cumulativeTickValue = if SecondsTillTime(start) < 0 and SecondsTillTime(end) > 0 then tickData + cumulativeTickValue[1] else 0;

#plot cumulativeTickplot = if cumulativeTickValue != 0 then cumulativeTickValue else Double.NaN;

# only show bars when there is tick data
#def cumulativeTickplot = if tickData > 0 then cumulativeTickValue else 0;

# always show tick data, current or previous
def cumulativeTickplot = cumulativeTickValue;
def ispos = cumulativeTickplot > 0;

plot z = cumulativeTickplot;
z.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
z.AssignValueColor(
     if ispos and cumulativeTickplot > cumulativeTickplot[1] then color.green
else if ispos and cumulativeTickplot < cumulativeTickplot[1] then color.dark_green
else if !ispos and cumulativeTickplot < cumulativeTickplot[1] then color.red
else if !ispos and cumulativeTickplot > cumulativeTickplot[1] then color.dark_red
else color.gray);
#

996p07D.jpg
 
Solution

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

Thanks brother. One more question, can you change it to where it cumulates over the length of the chart viewed instead of resetting each day and add in pre and post market to the count?
 
Last edited:
$TICK is only available during regular trading hours and no data is available pre and post market.

@halcyonguy can confirm, but I believe to accumulate across all data without resetting, you just need to change this line:

Code:
def cumulativeTickValue = if SecondsTillTime(start) < 0 and SecondsTillTime(end) > 0 then tickData + cumulativeTickValue[1] else 0;

To this:
Code:
def cumulativeTickValue = tickData + cumulativeTickValue[1];
 
$TICK is only available during regular trading hours and no data is available pre and post market.

@halcyonguy can confirm, but I believe to accumulate across all data without resetting, you just need to change this line:

Code:
def cumulativeTickValue = if SecondsTillTime(start) < 0 and SecondsTillTime(end) > 0 then tickData + cumulativeTickValue[1] else 0;

To this:
Code:
def cumulativeTickValue = tickData + cumulativeTickValue[1];
that did it! thanks man much appreciated
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
381 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