Multiple Standard Momentum
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DOC-STRATEGY
//██████╗░░█████╗░░█████╗░ ░██████╗████████╗██████╗░░█████╗░████████╗███████╗░██████╗░██╗░░░██╗
//██╔══██╗██╔══██╗██╔══██╗ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██╔════╝░╚██╗░██╔╝
//██║░░██║██║░░██║██║░░╚═╝ ╚█████╗░░░░██║░░░██████╔╝███████║░░░██║░░░█████╗░░██║░░██╗░░╚████╔╝░
//██║░░██║██║░░██║██║░░██╗ ░╚═══██╗░░░██║░░░██╔══██╗██╔══██║░░░██║░░░██╔══╝░░██║░░╚██╗░░╚██╔╝░░
//██████╔╝╚█████╔╝╚█████╔╝ ██████╔╝░░░██║░░░██║░░██║██║░░██║░░░██║░░░███████╗╚██████╔╝░░░██║░░░
//╚═════╝░░╚════╝░░╚════╝░ ╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░╚══════╝░╚═════╝░░░░╚═╝░░░
//𓂀𝔻𝕆ℂ 𝕊𝕋ℝ𝔸𝕋𝔼𝔾𝕐𓂀
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//@version=5
indicator('Multiple Standard Momentum', shorttitle='Multiple Standard Momentum', timeframe='')

//Maximum Moving Averages/////////////////////////////////////////////////////////////////////////////////////////////////////

DOC_Strategy = "Configurable: Multiple Standard Momentum"
Momentum(source, length, type) =>
     type == "Momentum"          ? ta.mom(source, length)    : 

     na
    
//Momentum 1//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom1_type    = input.string("Momentum"  , ""     ,                inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom1_source  = input.source(close  , ""     ,                     inline="Momentum",                       group=DOC_Strategy)
mom1_length  = input.int   (14   , ""     ,                       inline="Momentum", minval=2,             group=DOC_Strategy)
mom1_color   = input.color (color.rgb(1, 255, 170), ""     ,    inline="Momentum",                       group=DOC_Strategy)
mom1_color2  = input.color (color.rgb(255, 0, 144), ""     ,    inline="Momentum",                       group=DOC_Strategy)
mom1 = Momentum(mom1_source, mom1_length, mom1_type)
mom1_colorOK = mom1 >=0 ? mom1_color : mom1_color2
plot(mom1, color = mom1_colorOK, title="Momentum № I 𓂀", linewidth=2, display=display.all)

//Momentum 2//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom2_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom2_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom2_length  = input.int   (12   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom2_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom2_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom2 = Momentum(mom2_source, mom2_length, mom2_type)
mom2_colorOK = mom2 >=0 ? mom2_color : mom2_color2
plot(mom2, color = mom2_colorOK, title="Momentum № II 𓂀", linewidth=1, display=display.none)

//Momentum 3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom3_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom3_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom3_length  = input.int   (10   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom3_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom3_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom3 = Momentum(mom3_source, mom3_length, mom3_type)
mom3_colorOK = mom3 >=0 ? mom3_color : mom3_color2
plot(mom3, color = mom3_colorOK, title="Momentum № III 𓂀", linewidth=1, display=display.none)

//Momentum 4//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom4_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom4_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom4_length  = input.int   ( 8   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom4_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom4_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom4 = Momentum(mom4_source, mom4_length, mom4_type)
mom4_colorOK = mom4 >=0 ? mom4_color : mom4_color2
plot(mom4, color = mom4_colorOK, title="Momentum № IV 𓂀", linewidth=1, display=display.none)

//Momentum 5//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom5_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom5_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom5_length  = input.int   ( 6   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom5_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom5_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom5 = Momentum(mom5_source, mom5_length, mom5_type)
mom5_colorOK = mom5 >=0 ? mom5_color : mom5_color2
plot(mom5, color = mom5_colorOK, title="Momentum № V 𓂀", linewidth=1, display=display.none)

//Momentum 6//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom6_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom6_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom6_length  = input.int   ( 4   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom6_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom6_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom6 = Momentum(mom6_source, mom6_length, mom6_type)
mom6_colorOK = mom6 >= 0 ? mom6_color : mom6_color2
plot(mom6, color = mom6_colorOK, title="Momentum № VI 𓂀", linewidth=1, display=display.none)

//Momentum 7//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom7_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom7_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom7_length  = input.int   ( 2   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom7_color   = input.color (color.rgb(1, 255, 170, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom7_color2  = input.color (color.rgb(255, 0, 144, 70), ""     , inline="Momentum",                       group=DOC_Strategy)
mom7 = Momentum(mom7_source, mom7_length, mom7_type)
mom7_colorOK = mom7 >= 0 ? mom7_color : mom7_color2
plot(mom7, color = mom7_colorOK, title="Momentum № VII 𓂀", linewidth=1, display=display.none)

//Momentum Area///////////////////////////////////////////////////////////////////////////////////////////////////////////////

mom8_type    = input.string("Momentum"  , ""     ,                 inline="Momentum", options=["Momentum"], group=DOC_Strategy)
mom8_source  = input.source(close  , ""     ,                      inline="Momentum",                       group=DOC_Strategy)
mom8_length  = input.int   (14   , ""     ,                        inline="Momentum", minval=2,             group=DOC_Strategy)
mom8_color   = input.color (color.rgb(1, 255, 170, 90), ""     , inline="Momentum",                       group=DOC_Strategy)
mom8_color2  = input.color (color.rgb(255, 0, 144, 90), ""     , inline="Momentum",                       group=DOC_Strategy)
mom8 = Momentum(mom8_source, mom8_length, mom8_type)
mom8_colorOK = mom8 >= 0 ? mom8_color : mom8_color2
plot(mom8, color = mom8_colorOK, title="Momentum Area 𓂀", linewidth=1, style=plot.style_areabr, display=display.all)


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Period to calculate main line value

Calculation_Period_For_Line = input.int(defval=10, title='Period to calculate the Trend Line', minval=1,                                                  group='Trend Line')
Line_ColorLB                = input.color (color.rgb(15, 200, 139), "Long/Buy"     ,                                                                    group='Trend Line')
Line_ColorSS                = input.color (color.rgb(202, 15, 121), "Short/Sell"   ,                                                                    group='Trend Line')
TFTL                        = input.timeframe('', title='Time Frame the Trend Line - Tickets (Minutes: 1=5, 3=15, 5=30, 15=60)',                          group='Trend Line')

o  = request.security (syminfo.tickerid, TFTL, open,  barmerge.gaps_off, barmerge.lookahead_on)
c  = request.security (syminfo.tickerid, TFTL, close, barmerge.gaps_off, barmerge.lookahead_on)
h  = request.security (syminfo.tickerid, TFTL, high,  barmerge.gaps_off, barmerge.lookahead_on)
l  = request.security (syminfo.tickerid, TFTL, low,   barmerge.gaps_off, barmerge.lookahead_on)



//Function to calculate line value////////////////////////////////////////////////////////////////////////////////////////////
Calculate_Line(Period) =>
    float highS = ta.highest(Period) or  h > c  ? h : na
    float lowS  = ta.lowest (Period) or  l < c ?  l : na

    int trend = 0
    trend := c > h[1] ? 1 : c < l[1] ? -1 : nz(trend[1])
    trend

//Function to draw line on chart//////////////////////////////////////////////////////////////////////////////////////////////
Draw_Line(Period, Main_Trend) =>
    float highS = ta.highest(Period) or  h > c ?  h : na
    float lowS  = ta.lowest (Period) or  l < c ?  l : na

    int trend = 0
    trend := c > h[1] ? 1 : c < l[1] ? -1 : nz(trend[1])
    Main_Trend == 1 ? trend == 1 ? Line_ColorLB : Line_ColorLB : Main_Trend == -1 ? trend == -1 ? Line_ColorSS : Line_ColorSS : na

//Calculate main line value///////////////////////////////////////////////////////////////////////////////////////////////////
Main_Trend = Calculate_Line(Calculation_Period_For_Line)

//Plot Line Zero//////////////////////////////////////////////////////////////////////////////////////////////////////////////

plot(   0, color=Draw_Line(Calculation_Period_For_Line - 9, Main_Trend), title="Zero Trend Line 𓂀",   style=plot.style_stepline, histbase=   0, linewidth=2)

//Activate Signals: Long/Buy or Short/Sell///////////////////////////////////////////////////////////////////////////////

Signal_Momentum = input(false, 'Momentum Signal - Long/Buy or Short/Sell = ▲/▼  ?', group='Signal: Long/Buy or Short/Sell')


//Cross in Long/Buy or Short/Sell////////////////////////////////////////////////////////////////////////////////////////

LB1 = ta.crossover (mom1,0)    //   Momentum 1
SS1 = ta.crossunder(mom1,0)    //   Momentum 1

//Alert Condition///////////////////////////////////////////////////////////////////////////////////////////////////////

alertcondition((LB1) ,         'Momentum: Long/Buy',                 'Momentum: Long/Buy')
alertcondition((SS1) ,         'Momentum: Short/Sell',               'Momentum: Short/Sell')
alertcondition((LB1) or (SS1), 'Momentum: Long/Buy or Short/Sell',   'Momentum: Long/Buy or Short/Sell')

//Signal Condition//////////////////////////////////////////////////////////////////////////////////////////////////////

plotshape(Signal_Momentum and (LB1) , title='Signal Momentum - Long/Buy',   text='▲', textcolor=color.new(#FFFFFF, 0), style=shape.labelup,     size=size.tiny, location=location.bottom, color=color.new(#0ebb9e, 0))
plotshape(Signal_Momentum and (SS1) , title='Signal Momentum - Short/Sell', text='▼', textcolor=color.new(#FFFFFF, 0), style=shape.labeldown,   size=size.tiny, location=location.top,    color=color.new(#cd0a68, 0))

//The End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////