EMA ON MA SET
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adishaz

//@version=5
indicator("EMA ON MA SET" ,shorttitle ='EMA ON MA', overlay = true)


emaFastPeriod = input.int(13, title='EMA Fast', group='EMA1')
ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "HMA" => ta.hma(source, length)


CALCemaFastPeriod = input.int(title = 'EMA Fast CALC', defval = 5, minval = 1, maxval = 1000,  group='EMA1')
typeMA = input.string(title = 'EMA Fast CALC type', defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group='EMA1')
CALCemaFastValue = ma(close,CALCemaFastPeriod, typeMA)

emaMediumPeriod = input.int(20, title='EMA Medium', group='EMA2')
ma1(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "HMA" => ta.hma(source, length)
CALCemaMediumPeriod = input.int(8, title='EMA Medium CALC', group='EMA2')
typeMA1 = input.string(title = 'EMA MEDIUM CALC type', defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group='EMA2')
CALCemaMediumValue = ma1(close,CALCemaMediumPeriod, typeMA1)

emaSlowPeriod = input.int(50, title='EMA Slow', group='EMA3')
ma2(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "HMA" => ta.hma(source, length)
CALCemaSlowPeriod = input.int(13, title='EMA Medium CALC', group='EMA3')
typeMA2 = input.string(title = 'EMA SLOW CALC type', defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group='EMA3')
CALCemaSlowValue = ma2(close,CALCemaSlowPeriod, typeMA2)


emaSslowPeriod = input.int(100, title='EMA Sslow', group='EMA4')
ma3(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "HMA" => ta.hma(source, length)
CALCemaSslowPeriod = input.int(20, title='EMA Sslow CALC', group='EMA4')
typeMA3 = input.string(title = 'EMA SLOW CALC type', defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group='EMA4')
CALCemaSslowValue = ma3(close,CALCemaSslowPeriod, typeMA3)


emaSsslowPeriod = input.int(200, title='EMA Ssslow', group='EMA5')
ma4(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
        "HMA" => ta.hma(source, length)
CALCemaSsslowPeriod = input.int(50,title='EMA Sslow CALC', group='EMA5')
typeMA4 = input.string(title = 'EMA SLOW CALC type', defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group='EMA5')
CALCemaSsslowValue = ma4(close,CALCemaSsslowPeriod, typeMA4)




//EMA
emaFastValue = ta.ema(CALCemaFastValue, emaFastPeriod)
emaMediumValue = ta.ema(CALCemaMediumValue, emaMediumPeriod)
emaSlowValue = ta.ema(CALCemaSlowValue, emaSlowPeriod)
emaSslowValue = ta.ema(CALCemaSslowValue, emaSslowPeriod)
emaSsslowValue = ta.ema(CALCemaSsslowValue, emaSsslowPeriod)



plot(emaFastValue, color=color.new(color.white, 0), linewidth=2, style=plot.style_line, title='EMA Fast')
plot(emaMediumValue, color=color.new(color.orange, 0), linewidth=2, style=plot.style_line, title='EMA Medium')
plot(emaSlowValue, color=color.new(color.purple, 0), linewidth=2, style=plot.style_line, title='EMA SLow')
plot(emaSslowValue, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, title='EMA SsLow')
plot(emaSsslowValue, color=color.new(color.red, 0), linewidth=2, style=plot.style_line, title='EMA SssLow')

CROSS1 = ta.crossover( emaFastValue, emaMediumValue) or ta.crossover( emaFastValue, emaSlowValue ) or ta.crossover( emaFastValue, emaSslowValue ) or ta.crossover( emaFastValue, emaSsslowValue )
CROSS11 = ta.crossunder( emaFastValue, emaMediumValue) or ta.crossunder( emaFastValue, emaSlowValue ) or ta.crossunder( emaFastValue, emaSslowValue ) or ta.crossunder( emaFastValue, emaSsslowValue )

plot(CROSS1 ? emaFastValue : na ,title='EMA1 GOLDENCROSS', color=color.silver, style = plot.style_circles, linewidth = 5)
plot(CROSS11 ? emaFastValue : na,title='EMA1 DEATHCROSS' , color=color.red, style = plot.style_cross, linewidth = 4)

CROSS2 =  ta.crossover( emaMediumValue, emaSlowValue ) or ta.crossover( emaMediumValue, emaSslowValue ) or ta.crossover( emaMediumValue, emaSsslowValue )
CROSS22 =  ta.crossunder( emaMediumValue, emaSlowValue ) or ta.crossunder( emaMediumValue, emaSslowValue ) or ta.crossunder( emaMediumValue, emaSsslowValue )

plot(CROSS2 ? emaMediumValue : na ,title='EMA2 GOLDENCROSS', color=color.silver, style = plot.style_circles, linewidth = 5)
plot(CROSS22 ? emaMediumValue : na,title='EMA2 DEATHCROSS' , color=color.red, style = plot.style_cross, linewidth = 4)

CROSS3 = ta.crossover( emaSlowValue, emaSslowValue ) or ta.crossover( emaSlowValue, emaSsslowValue )
CROSS33 = ta.crossunder( emaSlowValue, emaSslowValue ) or ta.crossunder( emaSlowValue, emaSsslowValue )

plot(CROSS3 ? emaSlowValue : na ,title='EMA3 GOLDENCROSS', color=color.silver, style = plot.style_circles, linewidth = 5)
plot(CROSS33 ? emaSlowValue : na,title='EMA3 DEATHCROSS' , color=color.red, style = plot.style_cross, linewidth = 4)

CROSS4 =  ta.crossover( emaSslowValue, emaSsslowValue )
CROSS44 =  ta.crossunder( emaSslowValue, emaSsslowValue )

plot(CROSS4 ? emaSslowValue : na,title='EMA4 GOLDENCROSS' , color=color.silver, style = plot.style_circles, linewidth = 5)
plot(CROSS44 ? emaSslowValue : na,title='EMA4 DEATHCROSS' , color=color.red, style = plot.style_cross, linewidth = 4)





