Moving_average-10/5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © guptaanurag549

//@version=5
indicator("MovingAvg 10,5",overlay = true)
fast = input.int(5, minval= 4 , maxval= 50, title="fast sma")
slow = input.int(10, minval= 10 , maxval= 200, title="slow sma")
slow1 = input.int(44, minval= 10 , maxval= 200, title="slow sma2")
fastsma = ta.sma(close, fast)
slowsma = ta.sma(close, slow)
slowsma2 = ta.sma(close, slow1)

candle_filter= open >= close[1] or open <= close[1] and close > open[1]
candle_filter1= high >= slowsma and open <= slowsma

entry_long = ta.crossover(close, slowsma) or ta.crossover(close, fastsma) and (fastsma >= slowsma)
exit = ta.crossunder(close, fastsma)

//not use in ranging market and take a buy trade when moving average 5 is closer and cross above moving average 10 
//for exit candle close below MA5
plotshape(entry_long, title = "buy",style= shape.arrowup,text= "Buy", color=color.green,location= location.belowbar)
//plotchar(exit,char="E", color=color.red,location= location.abovebar)


//not use in ranging market and take a short trade when moving average 5 is closer and cross below moving average 10 
//for exit candle close above MA5
entry_long2 = ta.crossunder(close, slowsma) or ta.crossunder(close, fastsma) and (fastsma <= slowsma)
exit2 = ta.crossover(close, fastsma)

//alert
if entry_long
    alert("price ("+ str.tostring(close) + ") crossed over MA (" + str.tostring(entry_long) + ").", alert.freq_once_per_bar_close)
    
if entry_long2
    alert("price ("+ str.tostring(close) + ") crossed under MA (" + str.tostring(entry_long2) + ").", alert.freq_once_per_bar_close)


plotshape(entry_long2,title = "Short",style= shape.arrowdown,text= "Short", color=color.green,location= location.abovebar)
//plotchar(exit2,char="C", color=color.red,location= location.belowbar)

buy_44 = ta.crossover(close, slowsma2) 
plotshape(buy_44, title = "44-crossover",style= shape.arrowup,text= "44", color=color.teal,location= location.belowbar)

short_44 = ta.crossunder(close, slowsma2)
plotshape(short_44,title = "44-crossunder",style= shape.arrowdown,text= "44", color=color.teal,location= location.abovebar)

//plot(slowsma,  title = "MA10",color= color.green, linewidth = 2)
//plot(fastsma, title = "MA5",color= color.red, linewidth = 1)
plot(slowsma2, title = "MA44",color= color.teal, linewidth = 2)

plot1 = plot(slowsma,  title = "MA10",color= color.green, linewidth = 2)
plot2 = plot(fastsma, title = "MA5",color= color.red, linewidth = 1)
fill(plot1, plot2, color=color.new(color.green, 90))

alertcondition(entry_long or entry_long2, title="alert condition", message= "price crossed over MA")


