Levels Off Previous Day Close
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DominatorTrades

//@version=4
study("Levels Off Previous Day Close", overlay=true)

// Define Inputs
// What to calc inputs
var showInput90 = input(title="Show 90% Line", type=input.bool, defval=true, confirm=false)
var showInput120 = input(title="Show 120% Line ", type=input.bool, defval=true, confirm=false)
var showInput180 = input(title="Show 180% Line", type=input.bool, defval=true, confirm=false)
var showInput240 = input(title="Show 240% Line", type=input.bool, defval=false, confirm=false)
var showInput360 = input(title="Show 120% Line", type=input.bool, defval=false, confirm=false)

var Input90Text = input(title="90% Label Text", type=input.string, defval="90 ", confirm=false)
var Input120Text = input(title="120% Label Text", type=input.string, defval="120 ", confirm=false)
var Input180Text = input(title="180% Label Text", type=input.string, defval="180 ", confirm=false)
var Input240Text = input(title="240% Label Text", type=input.string, defval="240 ", confirm=false)
var Input360Text = input(title="360% Label Text", type=input.string, defval="360 ", confirm=false)

//Line Style Input
var styleOption = input(title="Line Style", type=input.string, 
     options=["solid (─)", "dotted (┈)", "dashed (╌)", 
     "arrow left (←)", "arrow right (→)", "arrows both (↔)"], 
     defval="solid (─)")
var lineStyle = styleOption == "dotted (┈)" ? line.style_dotted :
     styleOption == "dashed (╌)" ? line.style_dashed :
     styleOption == "arrow left (←)" ? line.style_arrow_left :
     styleOption == "arrow right (→)" ? line.style_arrow_right :
     styleOption == "arrows both (↔)" ? line.style_arrow_both :
         line.style_solid

var lineThickness = input(title="Line Thickness", type=input.integer, 
     options=[1,2,3,4], 
     defval=1)
     
var lineColor = input(title="Line Color", type=input.color,defval=color.gray)
var textColor = input(title="Text Color", type=input.color,defval=color.black)




// Define the prices
prev_daily_close = security(syminfo.tickerid, "D", close[0])
ninety = (prev_daily_close[1] * 1.90 )
oneTwenty = (prev_daily_close[1] * 2.20 )
oneEighty = (prev_daily_close[1] * 2.80 )
twoForty = (prev_daily_close[1] * 3.40 )
threeSixty = (prev_daily_close[1] * 3.60 )

// Set the Price Labels
var ninetyLabel = label.new(x=bar_index, y=ninety, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=ninetyLabel, text=Input90Text + tostring(ninety))
if(showInput90 )
    label.set_xy(ninetyLabel,bar_index,ninety), label.set_xy(ninetyLabel,bar_index,ninety)

var oneTwentyLabel = label.new(x=bar_index, y=oneTwenty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=oneTwentyLabel, text=Input120Text + tostring(oneTwenty))
if(showInput120 )
    label.set_xy(oneTwentyLabel,bar_index,oneTwenty)

var oneEightyLabel = label.new(x=bar_index, y=oneEighty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=oneEightyLabel, text=Input180Text + tostring(oneEighty))
if(showInput180 )
    label.set_xy(oneEightyLabel,bar_index,oneEighty)

var twoFortyLabel = label.new(x=bar_index, y=twoForty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=twoFortyLabel, text=Input240Text + tostring(twoForty))
if(showInput240 )
    label.set_xy(twoFortyLabel,bar_index,twoForty)

var threeSixtyLabel = label.new(x=bar_index, y=threeSixty, color=color.orange,textcolor=textColor,style=label.style_none)
label.set_text(id=threeSixtyLabel, text=Input360Text + tostring(threeSixty))
if(showInput360 )
    label.set_xy(threeSixtyLabel,bar_index,threeSixty)

line lnNinety = na
line lineOneTwenty = na
line lineOneEighty = na
line lineTwoForty = na
line lineThreeSixty = na


line.delete(lnNinety[1])
line.delete(lineOneTwenty[1])
line.delete(lineOneEighty[1])
line.delete(lineTwoForty[1])
line.delete(lineThreeSixty[1])

if(showInput90 )
    lnNinety := line.new( bar_index - 1, ninety, bar_index, ninety, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)

if(showInput120 )
    lineOneTwenty := line.new(bar_index - 1, oneTwenty, bar_index, oneTwenty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)

if(showInput180 )
    lineOneEighty := line.new(bar_index - 1, oneEighty, bar_index, oneEighty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)

if(showInput240 )
    lineTwoForty := line.new(bar_index - 1, twoForty, bar_index, twoForty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)

if(showInput360 )
    lineThreeSixty := line.new(bar_index - 1, threeSixty, bar_index, threeSixty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)




