I have an indicator which sends alerts when buy and sell signals appear. The indicator itself is not repainting when the bar has closed, but it repaint on the current bar. My problem is that I need my indicator to send alerts every time the signal changes. If the bar opens with buy, and later changes to sell I get alerts. but I dont get alerts when it goes from buy to sell and then to buy again on the same bar. Should I change it to strategy or study? Or use alert()
instead of 'alertcondition()'
I dont want to trade on bar close
I really appreciate any inputs.
This is a part of my code:
alertcondition(goLong, title = "Long", message = "Buy")
alertcondition(goShort, title = "Short", message = "Sell")
I reaally appreciate if you could help me!
I have tried ChatGPT and different variations of this code:
var bool hasLongAlert = false
var bool hasShortAlert = false
if goLong
if not hasLongAlert
alert("Long", alert.freq_all)
hasLongAlert := true
if goShort
if not hasShortAlert
alert("Short", alert.freq_all)
hasShortAlert := true
if not goLong
hasLongAlert := false
if not goShort
hasShortAlert := false