Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 03:58:27 +0000



[Programming Help] - [User Discussion] help to highlight candle based on certain study conditions

View Count: 1025

[2021-08-19 14:10:13]
tuanluu20902 - Posts: 24
Currently, I have an alert based on conditions on several CCI studies, I am alerted whenever the CCI line crosses either below -200 or above 200, marking an extreme condition in the market.
My next step is I want to add an alert on the candle (could be another symbol or change the color of whatever candle it is) on the candle's close and the CCI crosses back into the normal range (between -100 and 100) after being in an extreme condition.
Any help would be greatly appreciated!
imageCCI Indicator Signal.PNG / V - Attached On 2021-08-19 14:07:52 UTC - Size: 57.98 KB - 233 views
imageCCIX Indicator.PNG / V - Attached On 2021-08-19 14:08:00 UTC - Size: 18.99 KB - 190 views
[2021-08-19 19:41:21]
Sawtooth - Posts: 3993
Try this:
=OR(
AND(ID17.SG1[-1]<=-100,ID17.SG1>-100),
AND(ID17.SG1[-1]>=100,ID17.SG1<100))
[2021-08-19 21:08:09]
User584084 - Posts: 241
Look at the "Color Bar Based on Alert Conditions" and "Color Background Based on Alert Conditions" Studies for coloring candles and coloring the candle background.

http://www.sierrachart.com/image.php?Image=1629407135556.png
[2021-08-20 01:13:03]
tuanluu20902 - Posts: 24
Try this:
=OR(
AND(ID17.SG1[-1]<=-100,ID17.SG1>-100),
AND(ID17.SG1[-1]>=100,ID17.SG1<100))
Hi Tom,
I think this really is in the right direction! However from your code, a signal is created whenever it has crossed outside of the -100 and 100 range then back inside, is it possible so that it only triggers when the indicator has gone into extremes? ie below -200 and above 200
[2021-08-20 03:32:20]
Sawtooth - Posts: 3993
is it possible so that it only triggers when the indicator has gone into extremes? ie below -200 and above 200

Currently, I have an alert based on conditions on several CCI studies, I am alerted whenever the CCI line crosses either below -200 or above 200, marking an extreme condition in the market.
I interpret this to mean that you have already created alerts for the extreme.
My next step is I want to add an alert on the candle (could be another symbol or change the color of whatever candle it is) on the candle's close and the CCI crosses back into the normal range (between -100 and 100) after being in an extreme condition.
I interpret this to mean that you want an example of how to alert when the CCI crosses back into the normal range, hence the formula I offered.

So I'm not sure what you want.
[2021-08-20 13:10:44]
tuanluu20902 - Posts: 24
I interpret this to mean that you want an example of how to alert when the CCI crosses back into the normal range, hence the formula I offered.

So I'm not sure what you want.

Hi Tom, I'm sorry if my question was not clear. The code you wrote for me alerts when price crosses above -100 from being under -100, and vice versa.
That is certainly part of what I want, however, I want to add a condition that so that the indicator only alerts me if the CCI has been under -200 and not just under -100.

For simplicity's sake I am going to talk about only 1 side for now
=AND(ID17.SG1<=-200) //this alerts me whenever the CCI line is under -200
=AND(ID17.SG1[-1]<=-100,ID17.SG1>-100) // this is what you wrote which alerts me when the CCI line crosses the -100 line back into normal range

now I just need to combine them so that it will only alert me on the -100 crosses ONLY IF it has been in an extreme condition (under -200)
Date Time Of Last Edit: 2021-08-20 13:21:25
imageCCI extreme crosses.png / V - Attached On 2021-08-20 13:10:39 UTC - Size: 95.31 KB - 209 views
[2021-08-20 13:43:53]
Sawtooth - Posts: 3993
now I just need to combine them so that it will only alert me on the -100 crosses ONLY IF it has been in an extreme condition (under -200)
For this, you'll need to create a persistent TRUE when the CCI is <-200, and release it when it goes >-100, then find the bar where this occurs. Try this:

1. Add the Spreadsheet Formula study, and Hide this study.
Use a formula like this in its Formula field:
=IF(ID5.SG1>-100,0,IF(ID5.SG1<-200,1,ID6.SG1[-1]))
where ID5 is the CCI study, and ID6 is the Spreadsheet Formula study.
This creates a persistent 1 when the CCI goes <-200, and releases it to 0 when the CCI goes >-100.

2. Add the Color Bar Based On Alert Condition study.
Use a formula like this on its Alerts tab:
=AND(ID6.SG1[-1]=1,ID6.SG1=0)
where ID6 is the Spreadsheet Formula study.
This finds the bar where the persistent 1 was released.
[2021-08-20 15:35:08]
tuanluu20902 - Posts: 24
1. Add the Spreadsheet Formula study, and Hide this study.
Use a formula like this in its Formula field:
=IF(ID5.SG1>-100,0,IF(ID5.SG1<-200,1,ID6.SG1[-1]))
where ID5 is the CCI study, and ID6 is the Spreadsheet Formula study.
This creates a persistent 1 when the CCI goes <-200, and releases it to 0 when the CCI goes >-100.

2. Add the Color Bar Based On Alert Condition study.
Use a formula like this on its Alerts tab:
=AND(ID6.SG1[-1]=1,ID6.SG1=0)
where ID6 is the Spreadsheet Formula study.
This finds the bar where the persistent 1 was released.
Thank you so much for your detailed instructions! It worked, very much appreciated for the help!

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

Login

Login Page - Create Account