Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 01:28:52 +0000



[Programming Help] - Apparent issue with Swing H/L study & Alert Conditions

View Count: 406

[2021-07-25 21:49:12]
BenjaminR - Posts: 168
I have an alert condition w/ multiple conditions that works perfectly for 'long' signals; however, it doesn't function correctly at all for 'short' signals. There are no errors in the formula. I've spent hours trying to identify the problem, & it comes down to the Swing High/Low study. I have created a simplified chart & alert condition to illustrate the problem. I have attached a screenshot of a 1 min. chart, with a 10 Simple Moving Average, a Swing High/Low study, & two alert conditions- one for the low above the SMA at a swing low, & one for a high below the SMA at a swing high.

The color bar is blue for above, & pink for below. The blue bars in the attached chart image are enclosed in a rectangle, for easy identification. The green & red arrows are the Swing Highs & Swing Lows, respectively.

As you can see, when there the alert condition is true for the 'above' color bar study, only one bar is colored blue. When the alert condition is true for the 'below' color bar study, multiple bars are colored. On the study & chart where I am having a problem creating an accurate 'short' signal, I use arrows, & receive multiple arrows. This is simplified for the support ticket.

ID1.SG1 = 10 Simple Moving Average
ID2.SG1 = Swing High
ID2.SG2 = Swing Low

The alert conditions for below are:

AND(ID2.SG1<ID1.SG1,H<ID1.SG1)

The alert conditions for above are:

AND(ID2.SG2>ID1.SG1,L>ID1.SG1)

http://www.sierrachart.com/image.php?Image=1627249601211.png
Date Time Of Last Edit: 2021-07-25 21:50:57
[2021-07-25 23:30:40]
Sawtooth - Posts: 3976
The Swing High And Low study will output a zero at bars between those with an arrow, and a price value at bars with an arrow.
The 'above' formula is only true at an arrow because the Swing L is always >0 when the L is above the SMA, so the intermediate zeros don't affect the result.
The Swing H is zero between arrows so the 'below' formula is true every time the H is below the SMA, which is more often than at each arrow.

So that the 'below' alert only occurs at a Swing H arrow, add a condition to the 'below' formula that the Swing H must also be > zero:
=AND(ID2.SG1<ID1.SG1,H<ID1.SG1,ID2.SG1>0)

Suggestion:
When there is an alert issue that appears to make no sense, add the Spreadsheet Study study so that you can see exactly what the respective studies will output at each bar.
Each spreadsheet row is a chart bar, and the current bar is in row 3 with earlier bars in rows below.
Study outputs are in columns AA and above.
[2021-07-26 08:38:41]
BenjaminR - Posts: 168
Thank you, Tom! Issue resolved! The issue came up when I began to put it into a spreadsheet for trading system, & I removed ID2.SG1<>0, because it didn't make sense to me why I had put that in the formula a long time ago. I just recently decided to create some automatic trading systems using some signals I had made. Engineering must have helped me when I put the <>0 in for the same reason at the time. I got caught up with learning the spreadsheet for trading systems, & dealing with other issues, that I forgot that I had deleted that part, as I had copied the original chart with the signal from a different computer I had used at the time.

I was just now searching the forum for a different problem with a different signal (how to incorporate an alert to fire ONLY within X minutes of one of the conditions (an indicator) being true- but not after X minutes), & had just seen your name helping someone else, & it reminded me that someone had posted to this thread last night, per an email I saw. It was a surprise to discover it was the same person.

I want you to know your helpfulness is greatly appreciated!!! Sometimes the documentation isn't clear, or it takes so much time to fumble through troubleshooting an issue- your generosity in sharing knowledge is a blessing.

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

Login

Login Page - Create Account