Correlation prix [SP500, TESLA, BTC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AmosTradingSystem
//I multiplied the tesla price 116x to see it on the BTC chart. in fact if we multiply the closing price of tesla by 116 times we will get the price of btc...
//...Same mathematical operation for SP500 which is on average 5.6 times lower than the price of BTC. By multiplying the closing price of Sp500 we will obtain a 
//...line that we can superimpose on the price of BTC.

//@version=5
indicator("Correlation prix [SP500, TESLA, BTC", shorttitle = "SP_TE_BTC", overlay = true)

SP500 = request.security("SPX", "60", close* 5.6)
Tesla = request.security("TSLA", "60", close* 114)

//The closing price of BTC
Btc   =  close
Btc1   = open
// This is the average of the price between SP500 and TESLA
SP_TE = (SP500 + Tesla) / 2 

//The average of the price between BTC and the previously calculated average between SP500 and Tesla
BTC_SP_TE= (Btc + SP_TE) /2



//plot(SP500, "SP500", color=color.new(color.blue,5), linewidth = 4)
//plot(Tesla, "tesla", color=color.rgb(204, 145, 35), linewidth = 4)
//plot(Btc,"BTC", color=color.white, linewidth = 2)

//This is the average drawing
//plot(SP_TE, "SP_TE", color =color.fuchsia, linewidth = 4)
//plot(BTC_SP_TE,"BTC_SP_TE", color=color.green, linewidth = 4)


color1 = BTC_SP_TE < Btc ? color.new(color.green,70) : color.new(color.fuchsia,70)

plot1=plot(Btc, color= color1, linewidth = 2)
plot2=plot(BTC_SP_TE, color= color1, linewidth = 2)

fill(plot1, plot2, color1)

plotchar(BTC_SP_TE < Btc and Btc > Btc1[10] and Btc1 > Btc[1], "Moyen BTC_SP_Te", "▲", location.belowbar, size = size.small)

