Alert Setting on Heikin-Ashi candles


0
0

Hi Mr. Hahn,

Could you share how to set alert be set when Hekin Ashi candles changes from green to red or red to green in day or week duration ?
Thank you,

Robert

Marked as spam
Posted by (Questions: 3, Answers: 3)
Asked on June 9, 2018 10:58 am
2812 views
0
Private answer

Here is the code to generate alerts and plot arrows on the chart when Heikin-Ashi changes color.

def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose > haOpen;
plot trendUp = haColor and !haColor[1];
trendUp.SetDefaultColor(Color.CYAN);
trendUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot trendDown = !haColor and haColor[1];
trendDown.SetDefaultColor(Color.MAGENTA);
trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Alert(trendUp, "Trend Up", Alert.BAR, Sound.RING);
Alert(trendDown, "Trend Down", Alert.BAR, Sound.RING);

Screenshot below shows this plotted on a daily chart. Change the chart to whatever time frame you want.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 9, 2018 11:23 am
0

Thank you! How would I apply this method on scan or email alerts? Thank you for your help in advance.

( at June 9, 2018 12:48 pm)
0

In order to modify this code to serve as a Study Filter in a Scan.
Replace the following lines:

plot trendUp = haColor and !haColor[1];
trendUp.SetDefaultColor(Color.CYAN);
trendUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot trendDown = !haColor and haColor[1];
trendDown.SetDefaultColor(Color.MAGENTA);
trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Alert(trendUp, “Trend Up”, Alert.BAR, Sound.RING);
Alert(trendDown, “Trend Down”, Alert.BAR, Sound.RING);

With these lines:
def trendUp = haColor and !haColor[1];
def trendDown = !haColor and haColor[1];
plot scan = trendUp;
#plot scan = trendDown;

( at June 9, 2018 1:19 pm)
0
Is there a script where it alerts me when the HA candle changes from red to green or vice versa? I'm looking for a 5 minute time frame, just a single bar change but it alerts me once the bar closes. I don't want two bars in a row just the one. Any help greatly appreciated thank you!
( at June 10, 2022 8:48 am)
0
Yep, you have described precisely what my original solution to this questions does. Right down to the very last detail. Did you try it out yet?
( at June 10, 2022 9:48 am)
0
It seems to work for only when it turns to a green bar from red. I copied only the first 6 lines and that worked. When I copy the whole thing it doesn't work and says exactly one plot expected. Do I need to change something to make it alert from green to red?
( at June 13, 2022 11:23 am)
0
The solution I provided in my Answer is for a chart study, not a scan. The error message: "only one plot expected" only happens when you try to apply the code from a chart study to either a Study Filter of a scan or a Study Alert. If you want to apply this to the Study Filter of a scan or a Study Alert in the MarketWatch tab you will need to use the code in the comment I provided on June 9 2019. Please take the time to read the entire post before trying to use the code. All of this was explained if you follow the comments which have been appended to my original "chart study" solution.
( at June 13, 2022 4:17 pm)
0
Is there a way for this alert to only trigger the candle change once the candle has actually closed?
( at August 18, 2022 12:16 pm)
0
Modify the last two lines of code from the chart study as follows: Alert(trendUp[1], "Trend Up", Alert.BAR, Sound.RING); Alert(trendDown[1], "Trend Down", Alert.BAR, Sound.RING);
( at August 18, 2022 1:25 pm)
0
Thanks for the quick response! It definitely alerts when the candle changes but it still doesn't wait for the first 5 min bar to close. Is this maybe just not an option? I'm basically trying not to get faked out and have alerts every other minute. For example for the EUR/USD pair I received 3 alerts in 4 minutes regarding the exact same triggers.
( at August 18, 2022 4:44 pm)
0
The default settings in that code will only allow the alert to trigger once per bar. If you are getting multiple alerts per bar the only possibility is that you have manually changed the settings for the alert. I just tested this myself and the default settings are alerting only once per bar and only after the signal bar has closed and the new bar opens. Everything seems to be working correctly during my test.
( at August 19, 2022 2:49 pm)
0
Are you able to send me the exact code so I can copy and paste. I can tell I'm really close to getting it to work. I wouldn't even know what setting I would have manually changed.Is the FX price type you are using the "last" price or "mark" maybe?
( at August 22, 2022 8:31 am)
0
There is nothing more required then changing the last two lines of code just as I explained in my comment on 8/18/22. If that does not work, I have nothing more to suggest. I just tested it on a live chart of EUR/USD on a one minute chart and it works correctly. Sorry, but I have nothing more to suggest.
( at August 22, 2022 8:47 am)
0
Nevermind I got it, thanks for all your help with this!
( at August 22, 2022 9:45 am)