Adding alert to the Two Leg Pullback Counter


Tags:
Category:
0
0

I have a study that shows pullbacks off swing highs and lows.  It counts the pullbacks based on a formula and prints a count on the chart at the pullback.  The counter works correctly and the pullback number is correct.  The bubbles print in color to demonstrate pullback cycles.

The issue is, I want an alert when a pullback is printed and I would like to have the screen flash at the same time.  The alert and flash are not working.

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on February 25, 2022 1:34 pm
669 views
0
Thank you Pete, you're a genius. 😁
( at February 25, 2022 2:57 pm)
0
Private answer

I updated the title of your question to include one of the most important details, which is the description of what this chart study does. I also moved your question out of the "Alerts and Notifications" topic and into the "Chart Studies" topic since you are working with a chart study.

This code is reading one bar into the future in order to position the plots and chart bubbles. Which means the signals you are trying to use for your chart alerts will never appear on the last bar on the chart. They will only appear on the next to the last bar on the chart. And they are subject to vanish from the chart if the conditions change before the last bar on the chart closes. (this means you will have some alerts which fail to lock in)

Now that we understand how the code is working, we can apply a modification to get the alerts to work correctly. In order for your alert to function you must apply an index to the variable name so that is it looking at the previous bar instead of the current bar. Your current alert statements look like this:

Alert(BullRetrace, "BULL SWING", Alert.TICK, Sound.Ring);
Alert(BearRetrace, "BEAR SWING", Alert.TICK, Sound.Ring);

The only way to get these alerts working for this specific chart study is to apply the index to the variables as shown below:

Alert(BullRetrace[1], "BULL SWING", Alert.TICK, Sound.Ring);
Alert(BearRetrace[1], "BEAR SWING", Alert.TICK, Sound.Ring);

The same issue is preventing your chart background statement from working correctly. Now that you understand how to adjust the alerts statements to work with this code you should be able to workout the chart background color statement in like manner.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 25, 2022 2:49 pm