Support Board
Date/Time: Sun, 19 Jan 2025 03:13:07 +0000
[Programming Help] - Slope of a line
View Count: 2460
[2018-03-21 11:57:55] |
User976133 - Posts: 38 |
I have added an indicator to my chart based on a higher time frame and have it set to color based on the slope of the line created. Is it possible to reference that line in an alert so that it alerts when it changes from red to green? How would you address the color of the line? Thanks for any insights |
[2018-03-21 12:33:27] |
User701453 - Posts: 176 |
Yes, very easy to do. If red is your color for down. IndicatorName.SG1 < 0 If green is your color for up. IndicatorName.SG1 >0 |
[2018-03-21 12:59:08] |
User976133 - Posts: 38 |
Did not do what I was hoping. It is the MACD difference. Setting MACD.SG3<0 works if it is below zero, but I am looking for an up or downtrend. It needs to see it is trending down, regardless of relation to zero. |
[2018-03-21 13:06:52] |
Xfanman1 - Posts: 320 |
refer to it in relation to the previous bar. ID5.SG1>ID5.SG1[-1] MACD Slope > MACD Slope of Prior Bar. You can set both conditions if you want slope above 0 AND greater than the prior bar to indicate it's a positive slope. Scott |
[2018-03-21 13:07:51] |
User701453 - Posts: 176 |
This is how I check to see if a current line is less the previous line value if going down. IndicatorName.SG1 < IndicatorName.SG1[-1] However, if that doesn't work to your requirements. You can take a look at SC documentation for additional assistance. Study/Chart Alerts And Scanning: Alert Formula Examples |
[2018-03-21 13:20:26] |
User976133 - Posts: 38 |
It is closer, but still not what I hoped for. Since it refers to a different (higher) time range, it only draws once at the change. Using a color background to test, it looks like a picket fence. Using it in a formula only works at the moment the background refreshes. Irt misses the "white" spaces in the picket fence. So, it only works partially. |
[2018-03-21 13:44:29] |
User701453 - Posts: 176 |
Ok, "Since it refers to a different (higher) time range" is an important detail you left out. If the alert is working the way you want it on the "higher" time. Then use a study/price overly to place the color background over to your lower time frame. Study/Price Overlay Study: Overlaying Results from Color Bar/Background Based on Alert Condition Study |
[2018-03-21 13:46:34] |
Xfanman1 - Posts: 320 |
Or in addition to the comment by the poster above you could use the Study Angle study to measure the angle of the MACD Slope and reference that in your alert. Study Angle Scott Date Time Of Last Edit: 2018-03-21 13:47:33
|
To post a message in this thread, you need to log in with your Sierra Chart account: