LNL Simple Hedging Tool
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// LNL Simple Hedging Tool
//
// Simple Hedging Tool was created for traders who struggle with hedging. This tool helps to spot the ideal moments to put the hedges on. There are two versions: "VIX" 
// is specifically for the VIX (Volatility Index), and "SPX" can be used on any stock since it is calculated from the SPX benchmark.
//
// Signals from this tool WILL NOT TELL YOU where to buy or sell! But rather when is a good time TO NOT buy or TO NOT sell.
// 
// Created by L&L Capital
// 

indicator("LNL Simple Hedging Tool",shorttitle = "Simple Hedging Tool", overlay = true)

// Inputs

string Type = input.string("SPX", "Type", options = ["VIX", "SPX"])

// Internals Calculations

[middle, upper, lower] = ta.bb(close,20,2)
Bband = low < lower
Bband2 = high > upper
VolSpd = request.security("USI:VOLD", "D", ta.sma(close,10))
Add = request.security("USI:ADD", "D", ta.sma(close,10))
BullishVolSpd = VolSpd < -210000000 
BearishVolSpd = VolSpd > 170000000
BullishAdd = Add < -650
BearishAdd = Add > 650

// VIX vs. SPX Switch

BullishSignal = if Type == "VIX"
    Bband
else if Type == "SPX"
    (BullishVolSpd or BullishAdd)
	
BearishSignal = if Type == "VIX"
    Bband2
else if Type == "SPX"
    (BearishVolSpd or BearishAdd)
	
// Plots

barcolor(BullishSignal ? color.yellow : BearishSignal ? color.aqua : na, title= 'Color Bars')

plotshape(BullishSignal,title='Hedge Shorts!',style=shape.triangleup,location=location.belowbar,color=(color.yellow),size=size.tiny)    

plotshape(BearishSignal,title='Hedge Longs!',style=shape.triangledown,location=location.abovebar,color=(color.aqua),size=size.tiny)  


