Standard Deviations Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ramstox

//@version=5
indicator("@SD LEVELS", overlay=true)
//
f = input.float(defval=0, title="Volatility", minval=0, maxval=100, step=1)
c = input.float(defval=0, title="Close Price", minval=0, maxval=1000000, step=1)
p = input.float(defval=7, title="Period", minval=0, maxval=1000000, step=1)
request.security(syminfo.tickerid, 'W', close[1]) 

Volatility = f/100
PERIOD = p
CLOSE = c 

r = Volatility * (math.sqrt(PERIOD)/math.sqrt(365)) * CLOSE

//Resistance
hline(CLOSE+(r*0.236), title="R1", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*0.382), title="R2", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*0.5), title="R3", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*0.618), title="R4", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*0.786), title="R5", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*1), title="R6", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*1.236), title="R7", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*1.382), title="R8", color=color.red, linestyle=hline.style_solid)
hline(CLOSE+(r*1.5), title="R9", color=color.red, linestyle=hline.style_solid)

// //Support
hline(CLOSE-(r*0.236), title="S1", color=color.green, linestyle=hline.style_solid)
hline(CLOSE-(r*0.382), title="S2", color=color.green, linestyle=hline.style_solid)
hline(CLOSE-(r*0.5), title="S3", color=color.green, linestyle=hline.style_solid)
hline(CLOSE-(r*0.618), title="S4", color=color.green, linestyle=hline.style_solid)
hline(CLOSE-(r*0.786), title="S5", color=color.green, linestyle=hline.style_solid)
hline(CLOSE-(r*1), title="S6", color=color.green, linestyle=hline.style_solid)


//
//for i=0 to 7
//sq = math.round(math.sqrt(CLOSE),0)

//Label for horizontal line
// myLabel = label.new(x=bar_index, y=high,
//       color=color.orange, textcolor=color.orange,
//       style=label.style_none)
// label.set_text(id=myLabel, text="("+ str.tostring(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(45.0/180.0),2),0))+")")
// label.set_xy(myLabel,bar_index[0]+5,math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(45.0/180.0),2),0))
// label.delete(myLabel[1])


//GANN LEVELS
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(45.0/180.0),2),0), title="GR1", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(90.0/180.0),2),0), title="GR2", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(135.0/180.0),2),0), title="GR3", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(180.0/180.0),2),0), title="GR4", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(225.0/180.0),2),0), title="GR5", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(270.0/180.0),2),0), title="GR6", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(315.0/180.0),2),0), title="GR7", color=color.purple, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)+(360.0/180.0),2),0), title="GR8", color=color.purple, linestyle=hline.style_solid)

// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(45.0/180.0),2),0), title="GS1", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(90.0/180.0),2),0), title="GS2", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(135.0/180.0),2),0), title="GS3", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(180.0/180.0),2),0), title="GS4", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(225.0/180.0),2),0), title="GS5", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(270.0/180.0),2),0), title="GS6", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(315.0/180.0),2),0), title="GS7", color=color.orange, linestyle=hline.style_solid)
// hline(math.round(math.pow(math.round(math.sqrt(CLOSE),0)-(360.0/180.0),2),0), title="GS8", color=color.orange, linestyle=hline.style_solid)
   
plot(close,display = display.none)