Login Page - Create Account

Support Board


Date/Time: Sun, 07 Aug 2022 16:00:25 +0000



How to create alert for a a two bar formation?

View Count: 48

[2022-08-05 20:19:44]
dberliner - Posts: 11
Hello,

I have a certain study which creates bars blue and red (and other colors) as shown in the image attached.


I would like to create an alert condition for an instance when a blue bar is created AND a red bar is created IMMEDIATELY after that in the NEXT bar (or vice versa). If a red bar would be created 2 bars after the initial blue bar than the condition for the alert would be void. I want to refrain from having an alert for any separate color on its own.

Is that possible to create with some IF command ? I couldn't figure this out.

THank you!
imageScreenshot 2022-08-05 131448.png / V - Attached On 2022-08-05 20:16:32 UTC - Size: 507 B - 14 views
[2022-08-05 20:26:49]
John - SC Support - Posts: 17794
To begin with you need to start with an AND statement:

AND(Condition1, Conditiion2)

Where Condition 1 is the condition that creates a Blue Bar and Condition 2 is the condition that creates a Red bar (you can not test against the color of the bar, you need to use the actual condition that determines the coloring). Refer to the following:
Study/Chart Alerts And Scanning: OR and AND Functions
Study/Chart Alerts And Scanning: Writing Formulas Based On Color Settings

For the Blue bar you will also need to check the data for the previous bar. To do this, you need to add a [-1] to the subgraphs that you are testing against. For instance if the bar is blue when the Close is below 4200, then you would enter a condition of C[-1] < 4200. Refer to the following:
Study/Chart Alerts And Scanning: Referencing Data Other Than on the Last Bar/Column In the Chart

And finally, from what you state, you would want to enable the option for Evaluate on Bar Close, such that the Red bar has completed building when the test is made. Refer to the following:
Study/Chart Alerts And Scanning: Evaluate on Bar Close
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2022-08-05 21:37:16]
dberliner - Posts: 11
Thank you, John! I was able to create this!

However, I have a follow up question:

What is the syntax to create a range of say [-1] to [-4], as an example, meaning the current bar triggering based on the previous condition fulfilled in ANY of them. I.e the blue bar appeared in any of the 4 previous bars, and now we have a red bar = alert triggered.

The documentation under "Referencing Data Other Than on the Last Bar/Column In the Chart" seems to refer to an EXACT offset, or maybe I'm misunderstanding it... ?
Date Time Of Last Edit: 2022-08-05 21:42:58
[2022-08-05 21:54:57]
John - SC Support - Posts: 17794
You would have to use an OR function in combination with the offsets. So you would have the following for the Close of the bar less than 4200 in any of the previous 4 bars:
=OR(C[-4] < 4200, C[-3] < 4200, C[-2] < 4200, C[-1] < 4200)

You can next AND and ORs, so you could have the following:
=AND(OR(C[-4] < 4200, C[-3] < 4200, C[-2] < 4200, C[-1] < 4200), Condition 2)

Which would be true if any of the previous 4 bars closed less than 4200 and Condition 2 is true.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing

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

Login

Login Page - Create Account