Alert after current bar closes above or below hlc3 of previous bar


Category:
0
0

Hi Pete,

I need help to fix the code to get the arrows and sound alert only after the completion of the candle only.

plot buySignal = close > hlc3 [1];
buySignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buySignal.SetDefaultColor(Color.CYAN);
buySignal.SetLineWeight(3);
plot sellSignal = close < hlc3 [1];
sellSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellSignal.SetDefaultColor(Color.MAGENTA);
sellSignal.SetLineWeight(3);
Alert(buySignal, “Buy Signal”, Alert.BAR, Sound.RING);
Alert(sellSignal, “Sell Signal”, Alert.BAR, Sound.RING);

Thank you,

Shaishav

Marked as spam
Posted by (Questions: 49, Answers: 62)
Asked on January 18, 2020 3:11 pm
224 views
0
Private answer

I had to fix the title you entered for this question. What you entered was all one continous word without any spaces.

BuySellSignalBasedOnCloseReferenceToHLC3ofThePreviousCandle

It was completely illegible.

In order to trigger your alert only after the signal bar has closed you need to use the index of [1] to force the code to look at the previous bar to see if the signal was true. There is no way to set an alert to trigger when the bar closes. You have to trigger the alert when the next bar opens.

Here are the two lines of code for your alerts, modified to alert only after the signal bar has closed and a new bar has opened:

Alert(buySignal[1], “Buy Signal”, Alert.BAR, Sound.RING);
Alert(sellSignal[1], “Sell Signal”, Alert.BAR, Sound.RING);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 18, 2020 4:12 pm
0
Thank You Pete and sorry for the title without spaces.
( at January 18, 2020 4:17 pm)