Cumulative Tick Counter

T

Trendman

Guest
I wrote what I thought was an easy code to count and display accumulative tick count. The display for some reason does not include the first bar. I am using the secondsTill Time function to say every new day set the counter to zero as I am only interested in viewing the cumulative tick for each day. I included the code on a 15 minute bar chart of the $TICK chart and at the end of the day the total tick count displayed does not balance, it is missing the value of the first 15 minute bar.

I think I need a fresh pair of eyes on this!


def TickValue = close(symbol = "$TICK");
def CumTickValue = if secondsTillTime(930) < 0 and secondsTillTime(1600) > 0 then TickValue + CumTickValue[1] else 0;
AddLabel(yes, "Cum Tick: " + CumTickValue, if CumTickValue < 0 then Color.Red else Color.green);

# End Code

Thank
Frank
 
Solution
I wrote what I thought was an easy code to count and display accumulative tick count. The display for some reason does not include the first bar. I am using the secondsTill Time function to say every new day set the counter to zero as I am only interested in viewing the cumulative tick for each day. I included the code on a 15 minute bar chart of the $TICK chart and at the end of the day the total tick count displayed does not balance, it is missing the value of the first 15 minute bar.

I think I need a fresh pair of eyes on this!


def TickValue = close(symbol = "$TICK");
def CumTickValue = if secondsTillTime(930) < 0 and secondsTillTime(1600) > 0 then TickValue + CumTickValue[1] else 0;
AddLabel(yes, "Cum Tick: " +...
I wrote what I thought was an easy code to count and display accumulative tick count. The display for some reason does not include the first bar. I am using the secondsTill Time function to say every new day set the counter to zero as I am only interested in viewing the cumulative tick for each day. I included the code on a 15 minute bar chart of the $TICK chart and at the end of the day the total tick count displayed does not balance, it is missing the value of the first 15 minute bar.

I think I need a fresh pair of eyes on this!


def TickValue = close(symbol = "$TICK");
def CumTickValue = if secondsTillTime(930) < 0 and secondsTillTime(1600) > 0 then TickValue + CumTickValue[1] else 0;
AddLabel(yes, "Cum Tick: " + CumTickValue, if CumTickValue < 0 then Color.Red else Color.green);

# End Code

Thank
Frank

Just a minor change. I have included a debug option to display an addchartbuble to assist when debugging.

Ruby:
def TickValue = close(symbol = "$TICK");
def CumTickValue = if secondstillTime(930) <= 0 and secondsTillTime(1600) > 0 then TickValue + CumTickValue[1] else 0;
AddLabel(yes, "Cum Tick: " + CumTickValue, if CumTickValue < 0 then Color.Red else Color.green);
input debug = yes;
addchartBubble(debug and cumtickvalue,low,cumtickvalue,color.white,no);
# End Code
 
Solution
Just a minor change. I have included a debug option to display an addchartbuble to assist when debugging.
Thank you for the response. I do see the chart bubbles, however i am trying to reset the cumulative counter to zero at the start of each new day so the cumulative counter would display today only. The change you made displays a cumulation of all days.
 
Thank you for the response. I do see the chart bubbles, however i am trying to reset the cumulative counter to zero at the start of each new day so the cumulative counter would display today only. The change you made displays a cumulation of all days.

The bubbles were justt to trouble shoot the problem you were having with the code not accessing the first 15 minute bar of the day. The ciode does start over the count each day because of your condition. I have added a constraint (getday() = getlastday()) to the bubbles if you are considering using them to just display on the last day's activity. It still shows that the same values are in the bubbles before the constraint was added.

Capture.jpg
Ruby:
def TickValue = close(symbol = "$TICK");
def CumTickValue = if SecondsTillTime(930) <= 0 and SecondsTillTime(1600) > 0 then TickValue + CumTickValue[1] else 0;
AddLabel(yes, "Cum Tick: " + CumTickValue, if CumTickValue < 0 then Color.RED else Color.GREEN);
input debug = yes;
AddChartBubble(debug and GetDay() == GetLastDay() and CumTickValue, low, CumTickValue, Color.WHITE, no);
# End Code
 
Got it, thank you so much.
I originally tried GetDay() == GetDay[1] and when that did not work I tried the SecondsTilTime.
Again, thank you for your help. The debug helped a lot.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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