Crypto Force Index
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Francesco_Guidotti

//@version=5
indicator("Crypto Force Index", overlay=true, shorttitle="CFI")

// Inputs
rsiSourceInput = input(close, "Source", group = "Configurazione RSI")
rsiPeriodInput = input(14, "Length", group = "Configurazione RSI")

signalInputRsi40_50 = input(false, "Segnale attivo se: RSI <= 50 and RSI >= 40", group = "Debolezza")
signalInputRsi40_30 = input(false, "Segnale attivo se: RSI <= 40 and RSI >= 30", group = "Debolezza")
signalInputRsi30_20 = input(true, "Segnale attivo se: RSI <= 30 and RSI >= 20", group = "Debolezza")
signalInputRsi20_10 = input(true, "Segnale attivo se: RSI <= 20 and RSI >= 10", group = "Debolezza")
signalInputRsi10_0 = input(true, "Segnale attivo se: RSI <= 10 and RSI >= 0", group = "Debolezza")

signalInputRsi50_60 = input(false, "Segnale attivo se: RSI >= 50 and RSI <= 60", group = "Forza")
signalInputRsi60_70 = input(false, "Segnale attivo se: RSI >= 60 and RSI <= 70", group = "Forza")
signalInputRsi70_80 = input(false, "Segnale attivo se: RSI >= 70 and RSI <= 80", group = "Forza")
signalInputRsi80_90 = input(true, "Segnale attivo se: RSI >= 80 and RSI <= 90", group = "Forza")
signalInputRsi90_100 = input(true, "Segnale attivo se: RSI >= 90 and RSI <= 100", group = "Forza")

// Configuration
rsi = ta.rsi(rsiSourceInput, rsiPeriodInput)
location = location.bottom
size = size.tiny
color = color.green
signal = false
percentualeRata = "0%"

// Iper venduto
if rsi <= 50 and rsi >= 40
    color := color.new(color.red, 80)
    signal := signalInputRsi40_50
    percentualeRata := "100%"
else if rsi <= 40 and rsi >= 30
    color := color.new(color.red, 60)
    signal := signalInputRsi40_30
    percentualeRata := "100%"
else if rsi <= 30 and rsi >= 20
    color := color.new(color.red, 40)
    signal := signalInputRsi30_20
    percentualeRata := "100%"
else if rsi <= 20 and rsi >= 10
    color := color.new(color.red, 20)
    signal := signalInputRsi20_10
    percentualeRata := "100%"
else if rsi <= 10 and rsi >= 0
    color := color.new(color.red, 0)
    signal := signalInputRsi10_0
    percentualeRata := "100%"

// Iper comprato
else if rsi >= 50 and rsi <= 60
    color := color.new(color.green, 80)
    signal := signalInputRsi50_60
else if rsi >= 60 and rsi <= 70
    color := color.new(color.green, 60)
    signal := signalInputRsi60_70
else if rsi >= 70 and rsi <= 80
    color := color.new(color.green, 40)
    signal := signalInputRsi70_80
else if rsi >= 80 and rsi <= 90
    color := color.new(color.green, 20)
    signal := signalInputRsi80_90
else if rsi >= 90 and rsi <= 100
    color := color.new(color.green, 0)
    signal := signalInputRsi90_100


// Plots
bgcolor(color.new(color, 95))
plotshape(rsi, style=shape.square, location=location, color=color, size=size)
plotshape(signal, style=shape.circle, location=location.belowbar, color=color, size=size)
if signal
    label.new(bar_index, high, text=percentualeRata, style=label.style_none)
    


