50 ema screen flash (need alert)

J

joshua74133

Member
VIP
Mobius made this, I LOVE IT. I use it to grab my attention. can someone help me add a alert to it? I would like to have the alert be custom sound so I can add a sound that I have saved to my computer rather then the chime, bell or ring that TOS has. thanks for any help

plot EMA50 = ExpAverage(close, 45);
def EMA200 = ExpAverage(close, 200);
AssignBackgroundColor(if close crosses EMA50
then color.red
else if close == EMA50
then color.red
else if close crosses above EMA200
then color.yellow
else if close == EMA200
then color.red
else color.current);
 
Brain Monkey

Brain Monkey

New member
Here is an alert I use for $TICK. I forget where I got it.
Code:
declare upper;

input TickSymb = "$TICK";
def TICKS = if !IsNaN(close(TickSymb)) then close(TickSymb) else TICKS[1];

# Alerts:

def alerttrigger = if (TICKS >= 1000 ) or (TICKS <= -1000) then 1 else 0; #replace the 1 with your definition

# BLOCK CODE BELOW
input alerttext = "OH SH*T!!!";
input UseAlerts = {false, default true};
input AlertType = {default "BAR", "ONCE", "TICK"};
def at = AlertType;
input AlertSound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
Alert(alerttrigger and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);
 
Billions

Billions

Active member
2019 Donor
VIP
Here is an alert I use for $TICK. I forget where I got it.
Code:
declare upper;

input TickSymb = "$TICK";
def TICKS = if !IsNaN(close(TickSymb)) then close(TickSymb) else TICKS[1];

# Alerts:

def alerttrigger = if (TICKS >= 1000 ) or (TICKS <= -1000) then 1 else 0; #replace the 1 with your definition

# BLOCK CODE BELOW
input alerttext = "OH SH*T!!!";
input UseAlerts = {false, default true};
input AlertType = {default "BAR", "ONCE", "TICK"};
def at = AlertType;
input AlertSound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
Alert(alerttrigger and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);
What does this do please explain
 
Brain Monkey

Brain Monkey

New member
I think I misunderstood his question. I thought he was looking for a template to add an alert to a specific condition. I now realize that he wants to add his own alert sound, which I don't know how to do. Should I take down my reply?
 
Billions

Billions

Active member
2019 Donor
VIP
No Im interested in what you added. What is it used for?
 
J

joshua74133

Member
VIP
I just want it the make a sound when the screen flashes
 
Dublin_Capital

Dublin_Capital

Member
If I am understanding your question, I think you just need to add these two lines of code at the bottom:

Code:
def CrossAlert = close crosses EMA50;
Alert(CrossAlert, "EMACross", Alert.BAR, Sound.RING);
 
Dublin_Capital

Dublin_Capital

Member
Make sure you input it correctly. I have gotten several alerts this morning.

Full Code:

Code:
plot EMA50 = ExpAverage(close, 45);
plot EMA200 = ExpAverage(close, 200);
AssignBackgroundColor(if close crosses EMA50
then color.red
else if close == EMA50
then color.red
else if close crosses above EMA200
then color.yellow
else if close == EMA200
then color.red
else color.current);

def CrossAlert = close crosses EMA50;
Alert(CrossAlert, "EMACross", Alert.BAR, Sound.RING);
 
Last edited:
J

joshua74133

Member
VIP
I tried to put a alert for the 190 but it doesn't seem to work
 
Dublin_Capital

Dublin_Capital

Member
Change your code to this, and then you can more easily adjust the inputs for the length of the fast / slow EMAs.

I made some changes to your original color scheme - you should now get a red screen when price crosses the EMAfast, and a yellow screen when price crosses the EMAslow.

Code:
input fast = 45;
input slow = 200;


plot EMAfast = ExpAverage(close, fast);
plot EMAslow = ExpAverage(close, slow);
AssignBackgroundColor(if close crosses EMAfast
then color.red
else if close == EMAfast
then color.red
else if close crosses EMAslow
then color.yellow
else if close == EMAslow
then color.yellow
else color.current);

def FastAlert = close crosses EMAfast;
Alert(FastAlert, "Fast EMA Cross", Alert.BAR, Sound.RING);

def SlowAlert = close crosses EMAslow;
Alert(SlowAlert, "Slow EMA Cross", Alert.BAR, Sound.RING);
 
Last edited:
J

joshua74133

Member
VIP
Thanks. I appreciate it. I'll put it in as soon as I get back home
 

Similar threads

Top