I'd like to be able to get the current minute of the hour in order to use it as a condition. (I do not care what hour it is, just the minute.) I've searched but it seems like everything is limited to how many seconds until or past a predefined (static) time.
Has anybody made some great time related functions for TOS?
I'd like to be able to get the current minute of the hour in order to use it as a condition. (I do not care what hour it is, just the minute.) I've searched but it seems like everything is limited to how many seconds until or past a predefined (static) time.
Has anybody made some great time related functions for TOS?
set chart to 1 minute.
use the seconds from time function , from 0. divide by 60 to get minutes, then divide by 60 to get hours.
remove the hours digits , to the left of decimal point. then multiply by 60 to get minutes.
you didn't say why you want minutes. do you want to display them in a label?
or do you just need to know what bar the condition happened on?
set chart to 1 minute.
use the seconds from time function , from 0. divide by 60 to get minutes, then divide by 60 to get hours.
remove the hours digits , to the left of decimal point. then multiply by 60 to get minutes.
you didn't say why you want minutes. do you want to display them in a label?
or do you just need to know what bar the condition happened on?
I'm working off a 2m chart but would like to know when the current 5m bar closes. (00, 05, 10, 15, 20, etc) Problem is that it takes three 2 minute bars to cover one 5 minute bar, essentially a minute late.
More context:
Code:
def bullish_5m_atr_cross = atr_close_5m[2] <= atr_ts_5m[2] and atr_close_5m[1] > atr_ts_5m[1];
In english:
New bar opens
One bar ago the close is above ATR Trailing stop
Two bars ago the close was below ATR Trailing stop
We have a cross.
On a 2m chart, this condition can be true for up to 3 bars while the 2m chart references the 5m values. I just want to capture the first instance that it becomes true, draw a vertical line and move on. Currently it will draw 3 vertical lines on the 2m chart.
My thinking [could be crazy] is if I can test for the 05, 10, 15, etc. minute, I can draw the line and ignore drawing it if the minute is 02, 04, 06, etc.
I'm working off a 2m chart but would like to know when the current 5m bar closes. (00, 05, 10, 15, 20, etc) Problem is that it takes three 2 minute bars to cover one 5 minute bar, essentially a minute late.
More context:
Code:
def bullish_5m_atr_cross = atr_close_5m[2] <= atr_ts_5m[2] and atr_close_5m[1] > atr_ts_5m[1];
In english:
New bar opens
One bar ago the close is above ATR Trailing stop
Two bars ago the close was below ATR Trailing stop
We have a cross.
On a 2m chart, this condition can be true for up to 3 bars while the 2m chart references the 5m values. I just want to capture the first instance that it becomes true, draw a vertical line and move on. Currently it will draw 3 vertical lines on the 2m chart.
My thinking [could be crazy] is if I can test for the 05, 10, 15, etc. minute, I can draw the line and ignore drawing it if the minute is 02, 04, 06, etc.
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.
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.