Titans Empirical Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mmmarsh

//@version=5
indicator("Empirical Levels", overlay=true, max_lines_count=500, max_boxes_count=500)

//Select timeframe
TFLong=string(input.timeframe('D',title='Longer Time Frame'))
TFMedium=string(input.timeframe('240',title='Medium Time Frame'))

//Select pivot sensitivity
PivotSenseLong=input.int(9,'Sensitivity Longer TF')
PivotSenseMedium=input.int(9,'Sensitivity Medium TF')

//Generate data series for longer timeframe
O_Long=request.security(syminfo.ticker,TFLong,open)
C_Long=request.security(syminfo.ticker,TFLong,close)
H_Long=request.security(syminfo.ticker,TFLong,high)
L_Long=request.security(syminfo.ticker,TFLong,low)

//Generate data series for medium timeframe
O_Medium=request.security(syminfo.ticker,TFMedium,open)
C_Medium=request.security(syminfo.ticker,TFMedium,close)
H_Medium=request.security(syminfo.ticker,TFMedium,high)
L_Medium=request.security(syminfo.ticker,TFMedium,low)

//Find pivot high
PivotHighLong=ta.pivothigh(H_Long,PivotSenseLong,PivotSenseLong)
PivotHighMedium=ta.pivothigh(H_Medium,PivotSenseMedium,PivotSenseMedium)

//Find pivot low
PivotLowLong=ta.pivotlow(L_Long,PivotSenseLong,PivotSenseLong)
PivotLowMedium=ta.pivotlow(L_Medium,PivotSenseMedium,PivotSenseMedium)

line.new(bar_index - 1, PivotHighLong, bar_index + 200, PivotHighLong, color=color.new(color.blue,50), width=2)
line.new(bar_index - 1, PivotHighMedium, bar_index + 200, PivotHighMedium, color=color.new(color.orange,50), width=2)
line.new(bar_index - 1, PivotLowLong, bar_index + 200, PivotLowLong, color=color.new(color.blue,50), width=2)
line.new(bar_index - 1, PivotLowMedium, bar_index + 200, PivotLowMedium, color=color.new(color.orange,50), width=2)
