Spider Lines For Bitcoin (Daily And Weekly)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chinmaysk1

//@version=5
indicator("Daily and Weekly Spider Lines For Bitcoin", overlay=true)

if timeframe.isweekly

    // CANDLE POSITIONS
    yeartd = year(timenow)
    monthtd = month(timenow)
    daytd = dayofmonth(timenow)
    timestamp_today = timestamp("GMT",yeartd,monthtd,daytd,00,00,00)
    timestamp_july = timestamp("GMT",2019,07,01,00,00,00)
    days = (timestamp_today - timestamp_july) / (24 * 60 * 60 * 1000)
    weeks = days / 7
    connection_candle = weeks
    //connection_candle = input(135, title="If on weekly chart, number of weeks since 01 July 2019: ")
    candle0 = connection_candle + 32
    candle0_ = connection_candle + 33
    candle1 = connection_candle + 34
    candle2 = connection_candle + 36
    candle3 = connection_candle + 38
    candle4 = connection_candle + 40
    candle5 = connection_candle + 42
    candle6 = connection_candle + 44
    candle7 = connection_candle + 46
    candle8 = connection_candle + 48
    candle9 = connection_candle + 50
    candle10 = connection_candle + 52
    candle11 = connection_candle + 54
    candle12 = connection_candle + 56
    candle13 = connection_candle + 58
    candle14 = connection_candle + 60
    
    
    // RAYS
    
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle0], y1=high[candle0], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle0_], y1=high[candle0_], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle1], y1=high[candle1], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle2], y1=high[candle2], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle3], y1=high[candle3], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle4], y1=high[candle4], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle5], y1=high[candle5], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle6], y1=high[candle6], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle7], y1=high[candle7], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle8], y1=high[candle8], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle9], y1=high[candle9], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle10], y1=high[candle10], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle11], y1=high[candle11], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle12], y1=high[candle12], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle13], y1=high[candle13], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle14], y1=high[candle14], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        

if timeframe.isdaily

    // CANDLE POSITIONS
    yeartd = year(timenow)
    monthtd = month(timenow)
    daytd = dayofmonth(timenow)
    timestamp_today = timestamp("GMT",yeartd,monthtd,daytd,00,00,00)
    timestamp_july = timestamp("GMT",2019,07,01,00,00,00)
    days = (timestamp_today - timestamp_july) / (24 * 60 * 60 * 1000)
    connection_candle = days
    candle0 = connection_candle + 224
    candle0_ = connection_candle + 238
    candle1 = connection_candle + 252
    candle2 = connection_candle + 266
    candle3 = connection_candle + 280
    candle4 = connection_candle + 294
    candle5 = connection_candle + 308
    candle6 = connection_candle + 322
    candle7 = connection_candle + 336
    candle8 = connection_candle + 350
    candle9 = connection_candle + 364
    candle10 = connection_candle + 378
    candle11 = connection_candle + 392
    candle12 = connection_candle + 406
    candle13 = connection_candle + 420
    candle14 = connection_candle + 434
    
    
    // RAYS
    
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle0], y1=high[candle0], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle0_], y1=high[candle0_], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle1], y1=high[candle1], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle2], y1=high[candle2], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle3], y1=high[candle3], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle4], y1=high[candle4], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle5], y1=high[candle5], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle6], y1=high[candle6], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle7], y1=high[candle7], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle8], y1=high[candle8], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle9], y1=high[candle9], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle10], y1=high[candle10], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
    
    if barstate.islast
        ray = line.new(x1=bar_index[candle11], y1=high[candle11], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle12], y1=high[candle12], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle13], y1=high[candle13], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
        
    if barstate.islast
        ray = line.new(x1=bar_index[candle14], y1=high[candle14], x2=bar_index[connection_candle], y2=close[connection_candle])
        line.set_color(ray, color.white)
        line.set_extend(ray, extend.right)
        line.set_style(ray, line.style_dashed)
        line.set_width(ray, 1)
        line.delete(ray[1])
    

