Support Board
Date/Time: Thu, 12 Dec 2024 20:51:09 +0000
[Programming Help] - Help with Conditional Candle Coloring Based on AV-BV Values Across Different Time Interval
View Count: 126
[2024-10-07 07:18:52] |
User133078 - Posts: 3 |
Hello everyone, I'm working on a script to color my 30-minute candles based on specific AV-BV criteria, but I'm encountering some issues. Here's what I'm trying to achieve: Between 3:30 PM and 4:00 PM: color the candle if AV-BV > 2600 Between 4:00 PM and 4:30 PM: color the candle if AV-BV > 2000 Between 4:30 PM and 5:00 PM: color the candle if AV-BV > 1500 And so on. The problem is that when I apply my formula, it also colors candles outside the defined time ranges, which is not what I want. Additionally, I've created a separate study for each different time interval, but I'm not sure if that's the right approach (see screenshot). Here’s the code I’m using: (LOOK SCREENSHOT) =IF((BARTIME >TIME(15,30,00)),(BARTIME<TIME(16,00,00)),(AV-BV>2600)) =IF((BARTIME >TIME(16,00,00)),(BARTIME<TIME(16,30,00)),(AV-BV>2100)) …etc Do you have any suggestions on how to ensure each time interval is correctly colored based on its specific AV-BV condition? And is using a separate study for each time interval the right way to go? Thanks in advance for your help! |
Capture.PNG / V - Attached On 2024-10-07 07:13:35 UTC - Size: 81.97 KB - 34 views Captssssure.PNG / V - Attached On 2024-10-07 07:13:46 UTC - Size: 151.93 KB - 35 views Attachment Deleted. |
[2024-10-07 15:14:22] |
John - SC Support - Posts: 36652 |
The use of the IF() statement in not appropriate for what you want to do. You need to use the AND() function. So your formula would look like the following: =AND(BARTIME > TIME(15,30,00), BARTIME < TIME(16,00,00), (AV - BV) > 2600) And you do need to have a separate "Color Bar Based on Alert Condition" for each coloring that you would want. For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-10-07 18:35:12] |
User133078 - Posts: 3 |
Thank you for your response! I tried using the AND() function as you suggested: =AND(BARTIME > TIME(15,30,00), BARTIME < TIME(16,00,00), (AV - BV) > 2600) However, when I use "=AND()", it doesn't color the candle. On the other hand, when I use "=IF()", it does work, although it's not entirely correct because it's affecting other time ranges as well. Do you know why using "=AND()" doesn't trigger the candle coloring, but "=IF()" does? Is there a difference in how these functions are interpreted by the tool? Thanks in advance for your help! |
Anddon'twork.PNG / V - Attached On 2024-10-07 18:34:37 UTC - Size: 151.23 KB - 26 views IFwork.PNG / V - Attached On 2024-10-07 18:34:42 UTC - Size: 158.98 KB - 26 views |
[2024-10-07 20:27:41] |
John - SC Support - Posts: 36652 |
The particular bar you are referencing in your image probably has a start time of 15:30:00. and according to your condition, the bar time needs to be greater than 15:30:00. To have this test for greater than or equal, you would change your condition to be the following: =AND(BARTIME >= TIME(15,30,00), BARTIME < TIME(16,00,00), (AV - BV) > 2600) For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-10-07 20:35:10] |
User133078 - Posts: 3 |
Thank you so much for your response! I made the change you suggested, and now it works perfectly. It was such a simple adjustment—I should have thought of that myself! Thanks again for your help! |
To post a message in this thread, you need to log in with your Sierra Chart account: