High/Low/Open/Close Daily, Weekly, Monthly Line
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goofoffgoose
//@version=5

// For My pal Jittery
// 
// This indicator draws a line on the Daily, Weekly, and Monthly bar at the High, Low, Open and Close of each bar as price 
//      tends to react when revisiting these areas. 
// Each set of bars has an optional identifying label with its own color set that can be shown with or without the lines 
//      price value, and has drop down menues for size and style of each set of labels. 
// Each set of lines has inputs for line/text color, line width and style. 
// I recommend going into Chart Settings/Status Line and turning off indicator arguments OR moving the script to the top 
//      of the indicator list to avoid obstructed chart view with this indicators arguments. When script allows, I will update it to hide them.
//New and Improved menu with vertical and horizontal offsets

indicator("High/Low/Open/Close Daily, Weekly, Monthly Line", shorttitle= "D/W/M HLOC", overlay=true)

t = ticker.new(syminfo.prefix, syminfo.ticker)
///////// Label input options and colors //////////

////// Daily line and label options ////

// Show Lines and colors
show_dhloc = input.bool(defval=true, title="Show Daily Lines?", group="Daily High, Low, Open and Close Lines", inline="Daily Line")

show_dh = input.bool(defval=true, title="-", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")
dhcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")

show_dl = input.bool(defval=true, title="-",  group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")
dlcolor = input(color.rgb(246, 135, 135, 30), title="Low",  group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")

show_do = input.bool(defval=true, title="-",  group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")
docolor = input(color.rgb(120, 167, 241, 30), title="Open",  group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")

show_dc = input.bool(defval=true, title="-",  group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")
dccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line")

// Line style and size
dLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Daily High, Low, Open and Close Lines", inline="Daily Line Style")

dLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", 
     options=["solid (─)", "dotted (┈)", "dashed (╌)",
     "arrow left (←)", "arrow right (→)", "arrows both (↔)"],
     group="Daily High, Low, Open and Close Lines", inline="Daily Line Style")

dLineStyle = (dLineStyleOption == "dotted (┈)") ? line.style_dotted :
     (dLineStyleOption == "dashed (╌)") ? line.style_dashed :
     (dLineStyleOption == "arrow left (←)") ? line.style_arrow_left :
     (dLineStyleOption == "arrow right (→)") ? line.style_arrow_right :
     (dLineStyleOption == "arrows both (↔)") ? line.style_arrow_both :
         line.style_solid


// Daily label options

// Show labels and colors
show_dhlocLabel = input(defval=true, title="Show Daily Labels?", group="Daily Label Options", inline="Daily")
show_dVal = input.bool(defval=true, title="Show Daily Line Value?", group="Daily Label Options", inline="Daily")


dHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="daily label colors")
dLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color", inline="daily label colors")
dOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="daily label colors")
dCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="daily label colors")

//  Size and style drop down
dSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Daily options")
dStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)",
         "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline="Daily options")
     

dLabelStyle = (dStyleOption == "Triangle up (▲)") ? label.style_triangleup :
     (dStyleOption == "Triangle down (▼)") ? label.style_triangledown :
     (dStyleOption == "Label up (⬆)") ? label.style_label_up :
     (dStyleOption == "Label down (⬇)") ? label.style_label_down :
     (dStyleOption == "Plus (+)") ? label.style_cross:
     (dStyleOption == "Text Outline") ? label.style_text_outline:
     (dStyleOption == "None") ? label.style_none :
         label.style_label_down
         
dLabelSize = (dSizeOption == "Huge") ? size.huge :
     (dSizeOption == "Large") ? size.large :
     (dSizeOption == "Small") ? size.small :
     (dSizeOption == "Tiny") ? size.tiny :
     (dSizeOption == "Auto") ? size.auto :
         size.normal
         
dLblHOffset = input.int(20, title="Horizontal Offset  ",    inline="Daily offsets")
dLblVOffset = input(3.05,   title=  " Vertical Offset ",    inline="Daily offsets")


////// Weekly line and label options ////

// Show Lines and colors
show_whloc = input.bool(defval=true, title="Show Weekly Lines?", group="Weekly High, Low, Open and Close Lines", inline="Weekly Line")

show_wh = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")
whcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")

show_wl = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")
wlcolor = input(color.rgb(246, 135, 135, 30), title="Low", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")

show_wo = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")
wocolor = input(color.rgb(120, 167, 241, 30), title="Open", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")

show_wc = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")
wccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line")

// Line style and size
wLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Weekly High, Low, Open and Close Lines", inline="Weekly Line Style")

wLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", 
     options=["solid (─)", "dotted (┈)", "dashed (╌)",
     "arrow left (←)", "arrow right (→)", "arrows both (↔)"],
     group="Weekly High, Low, Open and Close Lines", inline="Weekly Line Style")

wLineStyle = (wLineStyleOption == "dotted (┈)") ? line.style_dotted :
     (wLineStyleOption == "dashed (╌)") ? line.style_dashed :
     (wLineStyleOption == "arrow left (←)") ? line.style_arrow_left :
     (wLineStyleOption == "arrow right (→)") ? line.style_arrow_right :
     (wLineStyleOption == "arrows both (↔)") ? line.style_arrow_both :
         line.style_solid


// Weekly label options

// Show labels and colors
show_whlocLabel = input(defval=true, title="Show Weekly Labels?", group="Weekly Label Options", inline="Weekly")
show_wVal = input.bool(defval=true, title="Show Weekly Line Value?", group="Weekly Label Options", inline="Weekly")


wHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="weekly label colors")
wLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color",  inline="weekly label colors")
wOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="weekly label colors")
wCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="weekly label colors")

//  Size and style drop down
wSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Weekly options")
wStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)",
         "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline= "Weekly options")
     

wLabelStyle = (wStyleOption == "Triangle up (▲)") ? label.style_triangleup :
     (wStyleOption == "Triangle down (▼)") ? label.style_triangledown :
     (wStyleOption == "Label up (⬆)") ? label.style_label_up :
     (wStyleOption == "Label down (⬇)") ? label.style_label_down :
     (wStyleOption == "Plus (+)") ? label.style_cross:
     (wStyleOption == "Text Outline") ? label.style_text_outline:
     (wStyleOption == "None") ? label.style_none :
         label.style_label_down
         
wLabelSize = (wSizeOption == "Huge") ? size.huge :
     (wSizeOption == "Large") ? size.large :
     (wSizeOption == "Small") ? size.small :
     (wSizeOption == "Tiny") ? size.tiny :
     (wSizeOption == "Auto") ? size.auto :
         size.normal

wLblHOffset = input.int(40, title="Horizontal Offset  ",    inline="Weekly offsets")
wLblVOffset = input(3.05,   title=  " Vertical Offset ",    inline="Weekly offsets")

////// Monthly line and label options ////

// Show Lines and colors
show_mhloc = input.bool(defval=true, title="Show Monthly Lines?", group="Monthly High, Low, Open and Close Lines", inline="Monthly Line")

show_mh = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line")
mhcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Monthly High, Low, Open and Close Lines", inline="Select Line")

show_ml = input.bool(defval=true, title="-",group="Monthly High, Low, Open and Close Lines", inline="Select Line")
mlcolor = input(color.rgb(246, 135, 135, 30), title="Low", group="Monthly High, Low, Open and Close Lines", inline="Select Line")

show_mo = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line")
mocolor = input(color.rgb(120, 167, 241, 30), title="Open", group="Monthly High, Low, Open and Close Lines", inline="Select Line")

show_mc = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line")
mccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Monthly High, Low, Open and Close Lines", inline="Select Line")

// Line style and size
mLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Monthly High, Low, Open and Close Lines", inline="Monthly Line Style")

mLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", 
     options=["solid (─)", "dotted (┈)", "dashed (╌)",
     "arrow left (←)", "arrow right (→)", "arrows both (↔)"],
      group="Monthly High, Low, Open and Close Lines", inline="Monthly Line Style")

mLineStyle = (mLineStyleOption == "dotted (┈)") ? line.style_dotted :
     (mLineStyleOption == "dashed (╌)") ? line.style_dashed :
     (mLineStyleOption == "arrow left (←)") ? line.style_arrow_left :
     (mLineStyleOption == "arrow right (→)") ? line.style_arrow_right :
     (mLineStyleOption == "arrows both (↔)") ? line.style_arrow_both :
         line.style_solid

// Monthly label options

// Show labels and colors
show_mhlocLabel = input(defval=true, title="Show Monthly Labels?",    group="Monthly Label Options", inline="Monthly")
show_mVal = input.bool(defval=true, title="Show Monthly Line Value?", group="Monthly Label Options", inline="Monthly")


mHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="monthly label colors")
mLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color",  inline="monthly label colors")
mOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="monthly label colors")
mCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="monthly label colors")

//  Size and style drop down
mSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Monthly Options")
mStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)",
         "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline="Monthly Options")
     

mLabelStyle = (mStyleOption == "Triangle up (▲)") ? label.style_triangleup :
     (mStyleOption == "Triangle down (▼)") ? label.style_triangledown :
     (mStyleOption == "Label up (⬆)") ? label.style_label_up :
     (mStyleOption == "Label down (⬇)") ? label.style_label_down :
     (mStyleOption == "Plus (+)") ? label.style_cross:
     (mStyleOption == "Text Outline") ? label.style_text_outline:
     (mStyleOption == "None") ? label.style_none :
         label.style_label_down
         
mLabelSize = (mSizeOption == "Huge") ? size.huge :
     (mSizeOption == "Large") ? size.large :
     (mSizeOption == "Small") ? size.small :
     (mSizeOption == "Tiny") ? size.tiny :
     (mSizeOption == "Auto") ? size.auto :
         size.normal
         
mLblHOffset = input.int(50, title="Horizontal Offset  ",     inline="Monthly offsets")
mLblVOffset = input(3.05,   title=  " Vertical Offset ",    inline="Monthly offsets")

 
////////HLOC Lines and Label Plots///////


// Daily HLOC
// Call daily data

dhigh  = request.security(t, 'D', high[1]) 
dlow   = request.security(t, 'D', low[1]) 
dopen  = request.security(t, 'D', open[1])
dclose = request.security(t, 'D', close[1]) 



// Line Conditions

if (show_dhloc)
    if (show_dh)
        dh_line = line.new(x1=bar_index-1, y1=dhigh, color=dhcolor, x2=bar_index, y2=dhigh, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) 
        line.delete(dh_line[1])
    if (show_dl)   
        dl_line = line.new(x1=bar_index-1, y1=dlow, color=dlcolor, x2=bar_index, y2=dlow, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) 
        line.delete(dl_line[1])
    if (show_do)
        do_line = line.new(x1=bar_index-1, y1=dopen, color=docolor, x2=bar_index, y2=dopen, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) 
        line.delete(do_line[1])
    if (show_dc)
        dc_line = line.new(x1=bar_index-1, y1=dclose, color=dccolor, x2=bar_index, y2=dclose, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) 
        line.delete(dc_line[1]) 


// Daily Labels //

// Label Value String

dHigh = str.tostring(dhigh, format.mintick)
dhValNa = " "
string dhVal =  if show_dVal
    dHigh 
else 
    dhValNa
    
dLow = str.tostring(dlow, format.mintick)
dlValNa = " "
string dlVal =  if show_dVal
    dLow 
else 
    dlValNa
    
dOpen = str.tostring(dopen, format.mintick)
doValNa = " "
string doVal =  if show_dVal
    dOpen 
else 
    doValNa
    
dClose = str.tostring(dclose, format.mintick)
dcValNa = " "
string dcVal =  if show_dVal
    dClose 
else 
    dcValNa


// Label Conditions

if (show_dhlocLabel) and (show_dhloc)
    if (show_dh)
        dHighLabel = label.new(x=bar_index-1, y=dhigh, xloc=xloc.bar_index[0],
          color=(dHighLblClr), textcolor=dhcolor,
          style=dLabelStyle)
        label.set_text(id=dHighLabel, text=" Daily High "+ str.tostring(dhVal))
        label.set_size(dHighLabel,dLabelSize)
        label.set_y(dHighLabel, dhigh + dLblVOffset)
        label.set_x(dHighLabel, label.get_x(dHighLabel) + dLblHOffset)
        label.delete(dHighLabel[1]) 
    if (show_dl)
        dlowLabel = label.new(x=bar_index-1, y=dlow, xloc=xloc.bar_index[0],
          color=(dLowLblClr), textcolor=dlcolor,
          style=dLabelStyle)
        label.set_text(id=dlowLabel, text=" Daily Low "+ str.tostring(dlVal))
        label.set_size(dlowLabel,dLabelSize)
        label.set_y(dlowLabel, dlow - dLblVOffset)
        label.set_x(dlowLabel, label.get_x(dlowLabel) + dLblHOffset)
        label.delete(dlowLabel[1]) 
    if (show_do)
        dopenLabel = label.new(x=bar_index-1, y=dopen, xloc=xloc.bar_index[0],
          color=(dOpenLblClr), textcolor=docolor,
          style=dLabelStyle)
        label.set_text(id=dopenLabel, text=" Daily Open "+ str.tostring(doVal))
        label.set_size(dopenLabel,dLabelSize)
        label.set_y(dopenLabel, dopen + dLblVOffset)
        label.set_x(dopenLabel, label.get_x(dopenLabel) + dLblHOffset)
        label.delete(dopenLabel[1]) 
    if (show_dc)
        dcloseLabel = label.new(x=bar_index-1, y=dclose, xloc=xloc.bar_index[0],
          color=(dCloseLblClr), textcolor=dccolor,
          style=dLabelStyle)
        label.set_text(id=dcloseLabel, text=" Daily Close "+ str.tostring(dcVal))
        label.set_size(dcloseLabel,dLabelSize)
        label.set_y(dcloseLabel, dclose - dLblVOffset)
        label.set_x(dcloseLabel, label.get_x(dcloseLabel) + dLblHOffset)
        label.delete(dcloseLabel[1]) 

   
   
// Weekly HLOC

// Call weekly data
whigh  = request.security(t, 'W', high[1]) 
wlow   = request.security(t, 'W', low[1]) 
wopen  = request.security(t, 'W', open[1])
wclose = request.security(t, 'W', close[1]) 



// Line Condition

if (show_whloc)
    if (show_wh)
        wh_line = line.new(x1=bar_index-1, y1=whigh, color=whcolor, x2=bar_index, y2=whigh, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) 
        line.delete(wh_line[1])
    if (show_wl)
        wl_line = line.new(x1=bar_index-1, y1=wlow, color=wlcolor, x2=bar_index, y2=wlow, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth  , extend=extend.both) 
        line.delete(wl_line[1])
    if (show_wo)
        wo_line = line.new(x1=bar_index-1, y1=wopen, color=wocolor, x2=bar_index, y2=wopen, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) 
        line.delete(wo_line[1])
    if (show_wc)
        wc_line = line.new(x1=bar_index-1, y1=wclose, color=wccolor, x2=bar_index, y2=wclose, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) 
        line.delete(wc_line[1]) 
    
    
// Weekly Labels//

// Label Value String

wHigh = str.tostring(whigh, format.mintick)
whValNa = " "
string whVal =  if show_wVal
    wHigh 
else 
    whValNa
    
wLow = str.tostring(wlow, format.mintick)
wlValNa = " "
string wlVal =  if show_wVal
    wLow 
else 
    wlValNa
    
wOpen = str.tostring(wopen, format.mintick)
woValNa = " "
string woVal =  if show_wVal
    wOpen 
else 
    woValNa
    
wClose = str.tostring(wclose, format.mintick)
wcValNa = " "
string wcVal =  if show_wVal
    wClose 
else 
    wcValNa
 

// Label Conditions 
    
if (show_whlocLabel) and (show_whloc)

    if (show_wh)
        wHighLabel = label.new(x=bar_index-1, y=whigh, xloc=xloc.bar_index[0],
          color=(wHighLblClr), textcolor=whcolor,
          style=wLabelStyle)
        label.set_text(id=wHighLabel, text=" Weekly High "+ str.tostring(whVal))
        label.set_size(wHighLabel,wLabelSize)
        label.set_y(wHighLabel, whigh + wLblVOffset)
        label.set_x(wHighLabel, label.get_x(wHighLabel) + wLblHOffset)
        label.delete(wHighLabel[1]) 
    if (show_wl)
        wlowLabel = label.new(x=bar_index-1, y=wlow, xloc=xloc.bar_index[0],
          color=(wLowLblClr), textcolor=wlcolor,
          style=wLabelStyle)
        label.set_text(id=wlowLabel, text=" Weekly Low "+ str.tostring(wlVal))
        label.set_size(wlowLabel,wLabelSize)
        label.set_y(wlowLabel, wlow - wLblVOffset)
        label.set_x(wlowLabel, label.get_x(wlowLabel) + wLblHOffset)
        label.delete(wlowLabel[1]) 
    if (show_wo)
        wopenLabel = label.new(x=bar_index-1, y=wopen, xloc=xloc.bar_index[0],
          color=(wOpenLblClr), textcolor=wocolor,
          style=wLabelStyle)
        label.set_text(id=wopenLabel, text=" Weekly Open "+ str.tostring(woVal))
        label.set_size(wopenLabel,wLabelSize)
        label.set_y(wopenLabel, wopen + wLblVOffset)
        label.set_x(wopenLabel, label.get_x(wopenLabel) + wLblHOffset)
        label.delete(wopenLabel[1]) 
    if (show_wc)
        wcloseLabel = label.new(x=bar_index-1, y=wclose, xloc=xloc.bar_index[0],
          color=(wCloseLblClr), textcolor=wccolor,
          style=wLabelStyle)
        label.set_text(id=wcloseLabel, text=" Weekly Close "+ str.tostring(wcVal))
        label.set_size(wcloseLabel,wLabelSize)
        label.set_y(wcloseLabel, wclose - wLblVOffset)
        label.set_x(wcloseLabel, label.get_x(wcloseLabel) + wLblHOffset)
        label.delete(wcloseLabel[1]) 
    

// Monthly HLOC  //

// Call monthly data
mhigh  = request.security(t, 'M', high[1]) 
mlow   = request.security(t, 'M', low[1]) 
mopen  = request.security(t, 'M', open[1])
mclose = request.security(t, 'M', close[1]) 





// Line Condition
if (show_mhloc)
    if (show_mh)
        mh_line = line.new(x1=bar_index-1, y1=mhigh, color=mhcolor, x2=bar_index, y2=mhigh, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) 
        line.delete(mh_line[1])
    if (show_ml)
        ml_line = line.new(x1=bar_index-1, y1=mlow, color=mlcolor, x2=bar_index, y2=mlow, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) 
        line.delete(ml_line[1])
    if (show_mo)
        mo_line = line.new(x1=bar_index-1, y1=mopen, color=mocolor, x2=bar_index, y2=mopen, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) 
        line.delete(mo_line[1])
    if (show_mc)
        mc_line = line.new(x1=bar_index-1, y1=mclose, color=mccolor, x2=bar_index, y2=mclose, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) 
        line.delete(mc_line[1]) 


// Monthly Labels //

// Label Value String

mHigh = str.tostring(mhigh, format.mintick)
mhValNa = " "
string mhVal =  if show_mVal
    mHigh 
else 
    mhValNa
    
mLow = str.tostring(mlow, format.mintick)
mlValNa = " "
string mlVal =  if show_mVal
    mLow 
else 
    mlValNa
    
mOpen = str.tostring(mopen, format.mintick)
moValNa = " "
string moVal =  if show_mVal
    mOpen 
else 
    moValNa
    
mClose = str.tostring(mclose, format.mintick)
mcValNa = " "
string mcVal =  if show_mVal
    mClose 
else 
    mcValNa



// Label Condition
 
if (show_mhlocLabel) and (show_mhloc)
    if (show_mh)
        mHighLabel = label.new(x=bar_index-1, y=mhigh, xloc=xloc.bar_index[0],
          color=(mHighLblClr), textcolor=mhcolor,
          style=mLabelStyle)
        label.set_text(id=mHighLabel, text=" Monthly High "+ str.tostring(mhVal))
        label.set_size(mHighLabel,mLabelSize)
        label.set_y(mHighLabel, mhigh + mLblVOffset)
        label.set_x(mHighLabel, label.get_x(mHighLabel) + mLblHOffset)
        label.delete(mHighLabel[1]) 
    if (show_ml)
        mlowLabel = label.new(x=bar_index-1, y=mlow, xloc=xloc.bar_index[0],
          color=(mLowLblClr), textcolor=mlcolor,
          style=mLabelStyle)
        label.set_text(id=mlowLabel, text=" Monthly Low "+ str.tostring(mlVal))
        label.set_size(mlowLabel,mLabelSize)
        label.set_y(mlowLabel, mlow - mLblVOffset)
        label.set_x(mlowLabel, label.get_x(mlowLabel) + mLblHOffset)
        label.delete(mlowLabel[1]) 
    if (show_mo)
        mopenLabel = label.new(x=bar_index-1, y=mopen, xloc=xloc.bar_index[0],
          color=(mOpenLblClr), textcolor=mocolor,
          style=mLabelStyle)
        label.set_text(id=mopenLabel, text=" Monthly Open "+ str.tostring(moVal))
        label.set_size(mopenLabel,mLabelSize)
        label.set_y(mopenLabel, mopen + mLblVOffset)
        label.set_x(mopenLabel, label.get_x(mopenLabel) + mLblHOffset)
        label.delete(mopenLabel[1]) 
    if (show_mc)
        mcloseLabel = label.new(x=bar_index-1, y=mclose, xloc=xloc.bar_index[0],
          color=(mCloseLblClr), textcolor=mccolor,
          style=mLabelStyle)
        label.set_text(id=mcloseLabel, text=" Monthly Close "+ str.tostring(mcVal))
        label.set_size(mcloseLabel,mLabelSize)
        label.set_y(mcloseLabel, mclose - mLblVOffset)
        label.set_x(mcloseLabel, label.get_x(mcloseLabel) + mLblHOffset)
        label.delete(mcloseLabel[1]) 
