Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 04:26:50 +0000



[Programming Help] - building an alert

View Count: 1730

[2018-10-15 12:40:28]
Glenn Infinity - Posts: 103
. I am looking to build an alert for NQ. In this case I want an alert, which would be a short set-up, when the price moves thru the 200(EMA), 120(EMA), 21(Simple) and 15(EMA), on the same price bar, and when those 4 MAs are relatively close together and all red. I use these moving averages with a different slope for
up(blue) and down(red). That is set up by using the Auto-Coloring tab in the subgraphs section under Studies and using the dropdown menu "Based on Slope." Using that tab does not split the Subgraph - which would be Labeled SG1. In this way the logic I am looking for would not work because I can't set the condition to the red downward slope setting.
[2018-10-15 16:45:46]
John - SC Support - Posts: 31098
In order to check for the slope, you would just need to compare the current bar value against the previous bar value and see if it is less than the previous for a down-slope (or higher for an up-slope). Then you need to just check for a crossover of the bar with each of the Moving Averages. Here is an example alert assuming 200(EMA) is ID1.SG1, 120(EMA) is ID2.SG1, 21(Simple) is ID3.SG1 and 15(EMA) is ID4.SG1 and that we are looking for a down slope:

= AND (ID1.SG1 < ID1.SG1[-1], ID2.SG1 < ID2.SG1[-1], ID3.SG1 < ID3.SG1[-1], ID4.SG1 < ID4.SG1[-1], CROSSOVER(C, ID1.SG1), CROSSOVER(C, ID2.SG1), CROSSOVER(C, ID3.SG1), CROSSOVER(C, ID4.SG1))


You can get fancier with the CROSSOVER and use CROSSFROMBELOW or CROSSFROMABOVE instead if you need the bar to be moving in a specific direction.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2018-10-16 13:04:19]
Glenn Infinity - Posts: 103
this was set up per described and it worked, thank you. The only issue is that it is working from yesterday, but is not working on the same chart for past data, the criteria were met on the 12th but the alert did not trigger. Is there something that I need to do to have it show on past dates?
[2018-10-16 13:39:19]
John - SC Support - Posts: 31098
It depends on where the Alert is being set. If it is on a general Study, then it will only work forward from the current bar. If it is part of the Trading System Based on Alert Condition or the Color Bar Based on Alert Condition then those have special controls for calculating previous bars (they have the input Number of Bars to Calculate).

If you are just wanting to test and make sure that the alert is working correctly for all situations, then I like to use the Spreadsheet Formula study. Just be sure to add it to the end of the list of studies, and then copy and paste the alert into the Formula Input. It will have a 1 where the Alert is true and a 0 everywhere else. So they will just show as spikes in the graph of this study.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2018-10-16 17:41:27]
Glenn Infinity - Posts: 103
sorry, apparently it only worked for the 1 session it was enabled in, did not work last night, would the above still apply?
[2018-10-16 19:59:27]
John - SC Support - Posts: 31098
Yes, you can use the above information to troubleshoot where the issue may be.

Note that this thread is now set to Programming Help, as we are beyond the scope of the Sierra Chart support for these kind of issues.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2018-10-16 21:47:14]
Sawtooth - Posts: 3976
Is there something that I need to do to have it show on past dates?

Add the Color Bar Based On Alert Condition study, and put the formula from post #2 in its Alerts tab.
This will color every bar where the conditions are TRUE at the bar close.

and when those 4 MAs are relatively close together
The formula in post #2 does not specifically include this criteria.

Also, the formula in post #2 does not account for any flat (equal value) segments of the MAs that are colored the same as the previous segment. For that, you'd need to use a spreadsheet study using this formula example for each MA:
Spreadsheet Example Formulas and Usage: Formula that Matches the Slope Coloring of a Study Subgraph Line

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

Login

Login Page - Create Account