Adding an alert to study in thinkscript

C

cattle trader

New member
How can i add an alert to this

Code:
input typicalLength = 5;
input haLength = 8;
input paintBars = yes;

def haOpen = (ohlc4[1] + haOpen[1]) / 2;
def haClose = (ohlc4 + haOpen + Max(high, haOpen) + Min(low, haOpen)) / 4;

plot AvgTyp = ExpAverage(hlc3, typicalLength);
plot AvgHAC = ExpAverage(haClose, haLength);


AvgTyp.SetDefaultColor(GetColor(1));
AvgHAC.SetDefaultColor(GetColor(2));
 
P

Pensar

Active member
VIP
@cattle trader Something like this?
Code:
Alert(AvgTyp crosses above AvgHAC, "Cross Up", alert.bar, sound.chimes);
Alert(AvgTyp crosses below AvgHAC, "Cross Down", alert.bar, sound.chimes);
 
C

cattle trader

New member
That didnt work, maybe im doing something wrong
 
Last edited by a moderator:
C

cattle trader

New member
input typicalLength = 5;
input haLength = 8;
input paintBars = yes;

def haOpen = (ohlc4[1] + haOpen[1]) / 2;
def haClose = (ohlc4 + haOpen + Max(high, haOpen) + Min(low, haOpen)) / 4;

plot AvgTyp = ExpAverage(hlc3, typicalLength);
plot AvgHAC = ExpAverage(haClose, haLength);


AvgTyp.SetDefaultColor(GetColor(1));
AvgHAC.SetDefaultColor(GetColor(2));
Alert(AvgTyp crosses above AvgHAC, "Cross Up", alert.bar, sound.chimes);
Alert(AvgTyp crosses below AvgHAC, "Cross Down", alert.bar, sound.chimes);
 
P

Pensar

Active member
VIP
@cattle trader Looks correct. Would you mind clarifying what didnt work?
 
P

Pensar

Active member
VIP
@cattle trader The alerts would be working correctly then. I dont know about SMS or email msgs, never use them. But maybe check your application settings to see if you have alerts turned on? Perhaps @BenTen knows more.

 
BenTen

BenTen

Administrative
Staff
VIP
@cattle trader @Pensar Alerts implemented through the indicator's source code will not give you the option for text messages. You will only get notified via a sound alert (ex: chime). You would need to go to the MarketWatch tab and set up another alert there.

Note: not all indicators will be supported through MarketWatch.
 
Thread starter Similar threads Forum Replies Date
R Adding color to a Chart Label Questions 4
B Adding parameters to candle formations Questions 0
AD² Dynamically Adding cloud to horizontal priceline Questions 2
Y How to automate adding alerts? Questions 0
M Adding price labels Questions 10

Similar threads

Top