Support Board
Date/Time: Thu, 21 Nov 2024 16:04:43 +0000
[Programming Help] - Colouring bars based on time
View Count: 189
[2024-11-03 18:51:03] |
User715695 - Posts: 7 |
Hello, Is it possible to color each line/candle based on the time it took to form ? I got as far as the "Color Bar Based On Alert Condition" study but can't figure out what the alert condition formula should be or what exact setting i got wrong. I've set the study to be based on a "Bar Time Duratin" study, input data to Duration and the alert condition to =sg1 < time( 0, 0, 10) with the hope to color every bar that took less than 10 sec to form. This just colors everything... help please ! |
[2024-11-03 22:36:23] |
User224654 - Posts: 18 |
Try this: =AND(BARTIME - BARTIME[1] < TIMEVALUE("00:00:10")) Since Sierra Chart does not provide a direct way to query the duration of a candle, it would be necessary to estimate the duration indirectly via the time interval of the candles. Explanation: BARTIME specifies the start time of the current candle. BARTIME[1] is the start time of the previous candle. The expression BARTIME - BARTIME[1] < TIMEVALUE("00:00:10") checks whether the time difference is less than 10 seconds. |
[2024-11-04 14:20:28] |
Sawtooth - Posts: 4118 |
Try this: =ID1.SG1<10/86400 where ID1 is the Bar Time Duration study. Spreadsheet Example Formulas and Usage: Formula Equivalents of Serial Date Time Values |
[2024-11-04 20:36:16] |
User715695 - Posts: 7 |
=ID1.SG1<10/86400 Worked like a charm but another problem popped up.. https://www.sierrachart.com/image.php?Image=1730751711601.png Basically its playing connect the dots. Any ideas why ? |
[2024-11-04 21:37:52] |
Sawtooth - Posts: 4118 |
Basically its playing connect the dots. Any ideas why ?
=ID1.SG1<10/86400 will only return True or False, not a value.If you are trying to color the Bar Time Duration bars in Region 5, follow these instructions: Color Bar Based on Alert Condition: Coloring Subgraphs of Other Studies |
[2024-11-04 21:56:33] |
User715695 - Posts: 7 |
I'm trying to color the main graph in region 1. It does that (the purple line) but it also connects the previous sub 10 sec line with the next.... even though there are 5 lines (above 10 sec) between them. Candlesticks work fine .... it seems to be something with the line graph draw type. |
[2024-11-04 22:22:55] |
Sawtooth - Posts: 4118 |
Basically, the only draw styles you can use with a T/F result in Region 1 are: - Color Bar - Background - Background Transparent - Point on High - Point on Low Why do you want to use the Line draw style? What are you trying to do? Date Time Of Last Edit: 2024-11-04 22:24:24
|
[2024-11-05 12:31:14] |
User715695 - Posts: 7 |
I just want to colour each bar in the main price graph a certain colour based on the time it took to form. under 10 sec coloured red , between 10 and 20 orange etc etc The line is just personal preference. |
[2024-11-05 14:40:06] |
Sawtooth - Posts: 4118 |
When you say Line is your personal preference, do you mean a Dash? If you want to use Draw Styles other than the ones in post#7, you can place them at a bar's price. Use an instance of the Spreadsheet Formula study for each color. Add the Spreadsheet Formula study - Set the Chart Region to 1 - Set 'Draw Zero Values' to No - Use formulas like these in its Formula field: =IF(ID1.SG1<10/86400,L-TICKSIZE,0) =IF(AND(ID1.SG1>=10/86400,ID1.SG1<20/86400),L-TICKSIZE,0) these will place the marker 1 tick below the Low of the bar, when TRUE. Note: you still won't want to use the Line draw style. |
[2024-11-05 14:46:44] |
John - SC Support - Posts: 36185 |
Try using the Draw Style of "Line - Skip Zeros": Chart Studies: Line - Skip Zeros (ACSIL: DRAWSTYLE_LINE_SKIP_ZEROS) For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-11-05 20:52:22] |
User715695 - Posts: 7 |
Try using the Draw Style of "Line - Skip Zeros":
This doesn't work. It just stops showing anything. When you say Line is your personal preference, do you mean a Dash?
I mean "line on close" graph draw type. For some reason this chart graph draw type and the "color bar" draw style in the study subgraph just don't work together properly. Candles, renko , mountains etc seem to work fine. Ill just stick with my line and background coloring i guess. Any chance i can make this =ID1.SG1<10/86400 so it's a range between 10 and 20 sec ? |
[2024-11-05 21:55:41] |
Sawtooth - Posts: 4118 |
Any chance i can make this =ID1.SG1<10/86400 so it's a range between 10 and 20 sec ?
=AND(ID1.SG1>=10/86400,ID1.SG1<20/86400)
Date Time Of Last Edit: 2024-11-05 22:47:14
|
To post a message in this thread, you need to log in with your Sierra Chart account: