Can't get TradingView alerts to pop up with my strategy

1k views Asked by At

I can't for the life of me get my tradingview alerts to pop up even though my strategy is indicating a buy signal correctly. I need the alert to pop up so it can be read by the trading bot.

Current code:

// 1. Determine Long Trade Entry

enterLong = cross(low, TRbottom2)

alertcondition(enterLong, title='Position Opened', message="Test")

I'm not sure what I'm missing, I tried setting an alert on the chart but I don't get a drop down its just an alert on the indicator and it doesn't trigger.

Any help would be appreciated.

1

There are 1 answers

2
e2e4 On

Could be your TRbottom2 value never cross low value.

This one works:

//@version=4
study("Cross Alert Test", overlay = true)

float sma50 = sma(close, 50)
float sma20 = sma(close, 20)

plot(sma50, "SMA 50", color.red)
plot(sma20, "SMA 20", color.blue)

bool smaCross = cross(sma50, sma20)

bgcolor(smaCross ? color.green : na)

alertcondition(smaCross, "SMA 20 cross SMA 50", "Crossed!")