Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 19:20:45 +0000



how to re-color every x bars?

View Count: 2569

[2017-11-09 20:55:55]
User859795 - Posts: 51
Hello,

Just a maybe-possible question: Like on a 15 min Candlestick bar chart, is there a way or study to color every 4th bars differently? So every 4th bar will has a different color?


Thank you,

Zolie
[2017-11-09 23:37:37]
Sawtooth - Posts: 3976
On a time based chart from 1 to 60 minutes, you could color the bar at the top of the hour by doing this:
Add the Color Bar Based On Alert Condition study, and put this formula on its Alerts tab:
=MROUND(BARTIME,1/1440)=MROUND(BARTIME,60/1440)
Date Time Of Last Edit: 2017-11-09 23:47:59
[2017-11-09 23:43:01]
Sierra Chart Engineering - Posts: 104368
Another study that makes this easier that can be used as part of the calculation is the Bar Numbering study.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2017-11-10 00:10:18]
Sawtooth - Posts: 3976
If you want to color every 15 minute bar a different color, repeating every 4 bars, do this:

Add the Bar Numbering study, and set the 'Number Every N Bars' to 1.

Add 4 instances of the Color Bar Based On Alert Condition study, and use these formulas in each respective Alerts tab:
=(ID1.SG1-0)/4-INT((ID1.SG1-0)/4)=0
=(ID1.SG1-1)/4-INT((ID1.SG1-1)/4)=0
=(ID1.SG1-2)/4-INT((ID1.SG1-2)/4)=0
=(ID1.SG1-3)/4-INT((ID1.SG1-3)/4)=0
where ID1 is the Bar Numbering study; edit as needed.

Set unique colors for each of the color bar studies.
[2017-11-10 00:17:24]
User859795 - Posts: 51
TOMGILB,

Thank you very much, it works as a charm!!!!!!


Zolie
[2020-11-26 16:29:47]
User459170 - Posts: 262
Tomgilb, Thanks so much. This is fantastic!
[2020-11-26 16:40:05]
Sawtooth - Posts: 3976
Is there a way to put an arrow on every nth bar?
Try this:

Add the Bar Numbering study, and set the 'Number Every N Bars' to 1, and Hide this study.

Add the Spreadsheet Formula study, use a formula like this in the Formula field, and Hide this study:
=FLOOR(ID1.SG1,10)
-where the Bar Numbering study is ID1; edit as needed.
This numbers every 10th bar; edit formula as needed.

Add the Color Bar Based On Alert Condition study, and use a formula like this on the Alerts tab:
=ID2.SG1<>ID2.SG1[-1]
-where the Spreadsheet Formula study is ID2; edit as needed.
To place an arrow instead of coloring the bar, follow these instructions:
Color Bar Based on Alert Condition: Drawing Arrows/Text or Other Styles at the High or Low of Bars
Date Time Of Last Edit: 2020-11-26 16:41:52
[2020-11-26 17:04:10]
User459170 - Posts: 262
Thanks so much again!

Your solution on post no. 2 works perfectly by placing a point on high or low. I was wondering if there's anyway to mark the close of the nth bar. Using the Mround code that you have given, it marks the start of the next 15 minute bar, is there a way to mark the end of the 15 minute bar. e.g. if the first bar starts 9.30, then your code marks the next bar at 9.45 which is the start of the next 15 min bar . Is there a way to identify the end of the 15 min bar?

Edited: Thanks Tomglib adding a -1/1440 solved the problem. Thanks a ton!
Date Time Of Last Edit: 2020-11-26 18:40:19
[2021-08-20 02:33:37]
User829162 - Posts: 31
On time based charts, I want to use Color Bar Based on Alert Condition Study at the "BOTTOM" of the Hour, example: 7:30, 8:30, 9:30 and so forth (5min or 15min chart)

I tried modifying the formulas in Post #2 and post #4 above, but was not successful

Changing the 60 to 30 Colors bars every 30 min,
=MROUND(BARTIME,1/1440)=MROUND(BARTIME,60/1440)

I tried using the Numbering Bar Study unsuccessfully.

I also changed Session Times to start on a 30min like Start Session 09:30.

What is required to ONLY Color Bars every Bottom of the Hour?

Thanks
[2021-08-20 03:51:02]
Sawtooth - Posts: 3976
What is required to ONLY Color Bars every Bottom of the Hour?
Use this formula:
=MROUND(BARTIME,1/1440)=MROUND(BARTIME,60/1440)

And:
On a 30 min chart, set the SG1 Displacement to +1
On a 15 min chart, set the SG1 Displacement to +2
On a 10 min chart, set the SG1 Displacement to +3
On a 5 min chart, set the SG1 Displacement to +6
On a 3 min chart, set the SG1 Displacement to +10
On a 2 min chart, set the SG1 Displacement to +15
On a 1 min chart, set the SG1 Displacement to +30
Date Time Of Last Edit: 2021-08-20 15:17:18
[2021-08-20 15:46:57]
User829162 - Posts: 31
Perfect, works real time. Thanks Tomgilb, much appreciated

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

Login

Login Page - Create Account