Login Page - Create Account

Support Board


Date/Time: Wed, 15 May 2024 14:49:07 +0000



[Programming Help] - Help With Indicator

View Count: 456

[2021-07-11 20:50:00]
silvereagle - Posts: 23
Hi Friends,

I was looking around but I did not find an indicator that does what I'm trying to accomplish. If it exists, please point me in the right direction. :) What I wanted was an indicator on my range chart that would color a bar based off whether or not it closed with in a certain time/seconds threshold. Essentially, if say the input was 180 seconds, and the bar only lasted 2 minutes (120 seconds), this candle could be set to a custom color. Does this already exist or are there easy enough code examples I could follow somewhere or perhaps a little psudo-code that could get me started? I really appreciate any and all help!

Thanks!
[2021-07-12 03:16:24]
Sawtooth - Posts: 3997
Try this:

Add the Bar Time Duration study. Hide the study.

Add the Color Bar Based On Alert Condition study.
Use a formula like this on its Alerts tab:
=ID1.SG1 * 86400 < 180
where the Bar Time Duration study is ID1.

The Bar Time Duration study outputs the bar's duration in Serial DateTime format, without the Date.
There are 86400 seconds in 24 hours.
When you multiply the Bar Time Duration's output by the number of seconds in 24 hours, it returns the duration of the bar in seconds.
Then compare it to your alert threshold in seconds.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account