Pinescript code alert help

I’m trying to set up an alert on the following code to give me an alert on the color change.

//@version=4
study(“Adaptive Autonomous Recursive Moving Average”,shorttitle=“A2RMA”,overlay=true)
length = input(14),gamma = input(3.),src = input(close)
//----
er = abs(change(src,length))/sum(abs(change(src)),length)
ama(x)=>
a = 0.
a := er*x+(1-er)*nz(a[1],x)
//----
ma = 0.
d = cum(abs(src - nz(ma[1],src)))/bar_index * gamma
ma := ama(ama(src > nz(ma[1],src) + d ? src + d : src < nz(ma[1],src) - d ? src - d : nz(ma[1],src)))
//----
css = ma > ma[1] ? #2196f3 : ma < ma[1] ? #ff1100 : na
plot(ma,color=fixnan(css),linewidth=2,transp=0)

I know it should be alertcondition code in there but how do I go about setting this up. I tried using arrows but it gave me arrows on every bar on the color change. I just wanted an buy and sell alert for the color change. Thank you !