YD_Volume_Alert
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Yonsei_dent
//                                   
//  \\  //   ⇗⩸⇖   ||   ||  ⇗⁼⁼⁼⁼⁼   ∥⁼⁼⁼⁼  ⁼⁼₪⁼⁼         ₪₪⁼⁼⁼⁼⇘                            
//   \\//   ∥  ∥  ||\\ ||  ⇘‗‗‗‗‗   ∥‗‗‗‗    ‖           ||    ∥  ⇗⁼⁼⁼⇘  ∥⇗⁼⁼⁼⇘  ‗‗‖‗‗
//    ‖‖    ∥  ∥  || \\||        ⇘  ∥        ‖           ||    ∥  ‖⇘₌₌⇗  ∥    ∥   ‖
//    ‖‖     ⇘⩸⇙   ||   ||   ‗‗‗‗‗⇗  ∥‗‗‗‗  ‗‗‖‗‗   ‗‗‗   ||‗‗‗‗⇗   ⇘‗‗‗   ∥    ∥   ‖‗‗⇗  ©©
//
//@version=5
indicator("YD_Volume_Alert", overlay = true)

// 증가 Percent #1
upgroup1   = 'Increased #1'
Uppercent1 = input.int(200, step=10, minval=10, title='Increased Percentage 1 (%)', group = upgroup1) 
text1      = input.bool(true, 'Text     ­', inline = '1-1', group = upgroup1)
textpick1  = input.string('Increased Volume', '', options = ['Increased Volume', 'Increased', 'Increased #1'], inline = '1-1', group = upgroup1)
textcol1   = input.color(color.blue, '', inline = '1-1', group = upgroup1)
shape1     = input.bool(true, 'Shape   ', inline = '1-2', group = upgroup1)
shapepick1 = input.string('Triangle', '', options = ['Triangle', 'Arrow', 'Circle', 'Cross'], inline = '1-2', group = upgroup1)
shapecol1  = input.color(color.green, ' ', inline = '1-2', group = upgroup1)
shapesize1 = input.string('Tiny', '', options = ['Tiny', 'Small', 'Normal','Large', 'Huge', 'Auto'], inline = '1-2', group = upgroup1)
beartip    = "음봉은 봉 위에 마커 표시"
bearbool1  = input.bool(true, 'Bearish Candle : Mark above the candlestick', tooltip = beartip, group = upgroup1)

// 증가 Percent #2
upgroup2   = 'Increased #2'
Uppercent2 = input.int(500, step=10, minval=10, title="Increased Percentage 2 (%)", group = upgroup2)
text2      = input.bool(true, 'Text     ­­­', inline = '2-1', group = upgroup2)
textpick2  = input.string('Hugely increased Volume', '', options = ['Hugely increased Volume', 'Hugely Increased', 'Increased #2'], inline = '2-1', group = upgroup2)
textcol2   = input.color(color.blue, '', inline = '2-1', group = upgroup2)
shape2     = input.bool(true, 'Shape   ', inline = '2-2', group = upgroup2)
shapepick2 = input.string('Triangle', '', options = ['Triangle', 'Arrow', 'Circle', 'Cross'], inline = '2-2', group = upgroup2)
shapecol2  = input.color(color.red, ' ', inline = '2-2', group = upgroup2)
shapesize2 = input.string('Small', '', options = ['Tiny', 'Small', 'Normal','Large', 'Huge', 'Auto'], inline = '2-2', group = upgroup2)
bearbool2  = input.bool(true, 'Bearish Candle : Mark above the candlestick', tooltip = beartip, group = upgroup2)

// 증가분
is_increased_1 = (Uppercent1 * .01) * volume[1]
is_increased_2 = (Uppercent2 * .01) * volume[1]

// 그리기
switchshape1(x) =>
    if bearbool1 and close < open
        switch x
            'Triangle' => label.style_triangledown
            'Arrow'    => label.style_arrowdown
            'Circle'   => label.style_circle
            'Cross'    => label.style_cross
    else if bearbool1 == false or close >= open
        switch x
            'Triangle' => label.style_triangleup
            'Arrow'    => label.style_arrowup
            'Circle'   => label.style_circle
            'Cross'    => label.style_cross

switchshape2(x) =>
    if bearbool2 and close < open
        switch x
            'Triangle' => label.style_triangledown
            'Arrow'    => label.style_arrowdown
            'Circle'   => label.style_circle
            'Cross'    => label.style_cross
    else if bearbool2 == false or close >= open
        switch x
            'Triangle' => label.style_triangleup
            'Arrow'    => label.style_arrowup
            'Circle'   => label.style_circle
            'Cross'    => label.style_cross

switchsize(x) =>
    switch x
        'Tiny'   => size.tiny
        'Small'  => size.small
        'Normal' => size.normal
        'Large'  => size.large
        'Huge'   => size.huge
        'Auto'   => size.auto

if (volume >= is_increased_1) and (volume < is_increased_2) and shape1
    label.new(
         x=bar_index, y=bar_index, text = text1?textpick1:na, 
         yloc = bearbool1 and close<open?yloc.abovebar: yloc.belowbar, 
         color = shapecol1, textcolor = textcol1, 
         style = switchshape1(shapepick1), 
         size = switchsize(shapesize1)
         )
else if shape1 ==false
    na

if (volume >= is_increased_2) and shape2
    label.new(
         x=bar_index, y=bar_index, text = text2?textpick2:na, 
         yloc = bearbool2 and close<open?yloc.abovebar: yloc.belowbar, 
         color = shapecol2, textcolor = textcol2, 
         style = switchshape2(shapepick2), 
         size = switchsize(shapesize2)
         )
else if shape2 ==false
    na

// 알람생성
if (volume > is_increased_1) and (volume < is_increased_2)
    alert(""+str.tostring(syminfo.tickerid)+"'s volume : "+str.tostring(Uppercent1)+"% increased.")
else if (volume >= is_increased_2)
    alert(""+str.tostring(syminfo.tickerid)+"'s volume : "+str.tostring(Uppercent2)+"% increased.")