Max - min - ML - top/bottom GP
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alexhyer13

//@version=5
indicator("Max/mins",overlay=true)

length=input.int(title="Length", defval=650)
lookback = input.int(title="Lookback", defval=640)

use_max = input.bool(title="Max", defval=1)
use_min = input.bool(title="Min", defval=1)
use_mid = input.bool(title="ML", defval=1)
use_top_gp = input.bool(title="Top GP", defval=0)
use_bot_gp = input.bool(title="Bottom GP", defval=0)

var cur_time = 0
var highest_time = 0
var lowest_time = 0
var float highest = close
var float lowest = close

cur_time:=cur_time+1

if (highest<high)
    highest:=high
    highest_time:=cur_time
if (cur_time-highest_time>=length)
    highest := ta.highest(lookback)

if (lowest>low)
    lowest:=low
    lowest_time:=cur_time
if (cur_time-lowest_time>=length)
    lowest := ta.lowest(lookback)

ml = (highest+lowest)/2
top_gp = ((highest-lowest)*0.66)+lowest
bottom_gp = ((highest-lowest)*0.34)+lowest

plot(use_max==1 ? highest : na,color=color.red)
plot(use_min==1 ? lowest : na,color=color.green)
plot(use_mid==1 ? ml : na,color=color.blue)
plot(use_top_gp==1 ? top_gp : na,color=color.yellow)
plot(use_bot_gp==1 ? bottom_gp : na,color=color.yellow)