Tallrye Alerts
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tallrye

//@version=5
indicator(title="Tallrye Exponential Moving Average", overlay=true)


//volumeFrom = volume

//volumeAverage = ta.ema(volumeFrom, 20)
//volumeCrossover = ta.crossover(volumeFrom, volumeAverage)
//signalOnVolume = if volumeCrossover == true
 //   input.int(1,title="signalOnVolumeTrue")
//else
 //   input.int(0,title="signalOnVolumeFalse")
   
   
// Input options
//renko_tickerid = ticker.renko(syminfo.tickerid, "ATR", 12)
//renko_close = request.security(renko_tickerid, timeframe.period, close)
averageData = input.source(close, title="Average Data Source")

fastLength = input.int(5, title="Fast Average Length")
slowLength = input.int(21, title="Slow Average Length")


// Calculate exponential moving averages
fastAverage = ta.ema(averageData, fastLength)
slowAverage = ta.ema(averageData, slowLength)


fastCrossover = ta.crossover(fastAverage, slowAverage)
reverseCrossover = ta.crossover(slowAverage, fastAverage)

//plot(fastAverage, color=color.navy, linewidth=2, title="Hizli EMA")
//plot(slowAverage, color=color.fuchsia, linewidth=2, title="Yavas EMA")
// Plot averages

signalOnFast = if fastCrossover == true
    input.int(1,title="SignalOnFastTrue")
else
    input.int(0,title="SignalOnFastFalse")
    
signalOnSlow = if reverseCrossover == true
    input.int(1,title="SignalOnSlowTrue")
else
    input.int(0,title="SignalOnSlowFalse")
    

    


//plot(signalOnVolume == 1 ? fastAverage : na, "Enough Volume", color=color.blue, linewidth=7)
//plotshape(signalOnVolume == 1 ? slowAverage : na, title="Enough Volume Begins", location=location.absolute, style=shape.circle, size=size.small, color=color.yellow)
//plot(signalOnFast == 1 ? fastAverage : na, "Buy Signal", color=color.blue, linewidth=7)
//plot(signalOnSlow == 1 ? slowAverage : na, "Sell Signal", color=color.red, linewidth=7)
plotshape(signalOnFast ? fastAverage : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.small, color=color.green)
plotshape(signalOnSlow ? slowAverage : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.small, color=color.red)


alertcondition(signalOnFast, title="Cagatay Buy", message="Cagatay Buy!")
alertcondition(signalOnSlow, title="Cagatay Sell", message="Cagatay Sell!")

// Show the moving average trend with a coloured background
backgroundColor = if fastCrossover == true
    color.new(color.fuchsia, 85)
else if reverseCrossover == true
    color.new(color.red, 80)
    
bgcolor(backgroundColor, title="EMA Background")













