Anchored BTC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Dicargo_Beam

//@version=5
indicator("Anchored BTC",overlay=true)
xxx = input.bool(false,"' Times must be selected in Correlation Coefficient > 0.8 '")
xxxa = input.bool(false,"' it means you should select times that alt and btc is well coupled.'")
xxxx = input.bool(false,"' Time 1 and Time 2 must be Swing High or Swing Low '")
t1 = input.time(timestamp("07 Jul 2021 00:00 +1200"),"Time 1")
t2 = input.time(timestamp("21 Jul 2021 00:00 +1200"),"Time 2")

var x1 = 0.0 
var x2 = 0.0 
var y1 = 0.0 
var y2 = 0.0 


btc_close = request.security(input.symbol("BINANCE:BTCUSDT"),"",close)
if t1 == time 
    x1 := math.log10(close)
    x2 := math.log10(btc_close)
if t2 == time
    y1 := math.log10(close)
    y2 := math.log10(btc_close)
   



f = math.abs((x1-y1)/(x2-y2))

f2 = if time>=t2
    1

anchored_btc = 0.0
anchored_btc := if time==t2 
    close
else
    math.pow(10,math.log10(anchored_btc[1]) + ta.change(math.log10(btc_close)) * f * f2)
//

plot(anchored_btc)
col = if t1 <= time and t2 >= time
    color.new(color.yellow,90)
bgcolor(color=col)



