Expected Move Plotter Intraday
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Steversteves

//@version=5
indicator("Expected Move Plotter Intraday", overlay = true)

// Reference Timeframes 

ticker = ticker.new(syminfo.prefix, syminfo.ticker, session.regular)
this_wopen = request.security(ticker, "60", open, lookahead=barmerge.lookahead_on)
this_mopen = request.security(ticker, "15", open, lookahead=barmerge.lookahead_on)
this_dopen = request.security(ticker, "30", open, lookahead=barmerge.lookahead_on)

last_dclose = request.security(ticker, "5", close[1], lookahead=barmerge.lookahead_on)
last_dhigh = request.security(ticker, "5", high[1], lookahead=barmerge.lookahead_on)
last_dlow = request.security(ticker, "5", low[1], lookahead=barmerge.lookahead_on)
today_close = request.security(ticker, "5", close, lookahead=barmerge.lookahead_on)

// Get Hourly Data
whigh1 = request.security(ticker, "60", high[1] - open[1], lookahead=barmerge.lookahead_on)
whigh2 = request.security(ticker, "60", high[2] - open[2], lookahead=barmerge.lookahead_on)
whigh3 = request.security(ticker, "60", high[3] - open[3], lookahead=barmerge.lookahead_on)
whigh4 = request.security(ticker, "60", high[4] - open[4], lookahead=barmerge.lookahead_on)
whigh5 = request.security(ticker, "60", high[5] - open[5], lookahead=barmerge.lookahead_on)

wlow1 = request.security(ticker, "60", open[1] - low[1], lookahead=barmerge.lookahead_on)
wlow2 = request.security(ticker, "60", open[2] - low[2], lookahead=barmerge.lookahead_on)
wlow3 = request.security(ticker, "60", open[3] - low[3], lookahead=barmerge.lookahead_on)
wlow4 = request.security(ticker, "60", open[4] - low[4], lookahead=barmerge.lookahead_on)
wlow5 = request.security(ticker, "60", open[5] - low[5], lookahead=barmerge.lookahead_on)

// Get 15 min data
mhigh1 = request.security(ticker, "15", high[1] - open[1], lookahead=barmerge.lookahead_on)
mhigh2 = request.security(ticker, "15", high[2] - open[2], lookahead=barmerge.lookahead_on)
mhigh3 = request.security(ticker, "15", high[3] - open[3], lookahead=barmerge.lookahead_on)
mhigh4 = request.security(ticker, "15", high[4] - open[4], lookahead=barmerge.lookahead_on)
mhigh5 = request.security(ticker, "15", high[5] - open[5], lookahead=barmerge.lookahead_on)

mlow1 = request.security(ticker, "15", open[1] - low[1], lookahead=barmerge.lookahead_on)
mlow2 = request.security(ticker, "15", open[2] - low[2], lookahead=barmerge.lookahead_on)
mlow3 = request.security(ticker, "15", open[3] - low[3], lookahead=barmerge.lookahead_on)
mlow4 = request.security(ticker, "15", open[4] - low[4], lookahead=barmerge.lookahead_on)
mlow5 = request.security(ticker, "15", open[5] - low[5], lookahead=barmerge.lookahead_on)

// Get 30 Data 

dhigh1 = request.security(ticker, "30", high[1] - open[1], lookahead=barmerge.lookahead_on)
dhigh2 = request.security(ticker, "30", high[2] - open[2], lookahead=barmerge.lookahead_on)
dhigh3 = request.security(ticker, "30", high[3] - open[3], lookahead=barmerge.lookahead_on)
dhigh4 = request.security(ticker, "30", high[4] - open[4], lookahead=barmerge.lookahead_on)
dhigh5 = request.security(ticker, "30", high[5] - open[5], lookahead=barmerge.lookahead_on)

dlow1 = request.security(ticker, "30", open[1] - low[1], lookahead=barmerge.lookahead_on)
dlow2 = request.security(ticker, "30", open[2] - low[2], lookahead=barmerge.lookahead_on)
dlow3 = request.security(ticker, "30", open[3] - low[3], lookahead=barmerge.lookahead_on)
dlow4 = request.security(ticker, "30", open[4] - low[4], lookahead=barmerge.lookahead_on)
dlow5 = request.security(ticker, "30", open[5] - low[5], lookahead=barmerge.lookahead_on)

// Hourly Lows

weekly_low_avg = (wlow1 + wlow2 + wlow3 + wlow4 + wlow5) / 5 

weekly_low_plot = this_wopen - weekly_low_avg 

plot(weekly_low_plot, "60 minute low", color=color.red)

// Hourly Highs

weekly_high_avg = (whigh1 + whigh2 + whigh3 + whigh4 + whigh5) / 5 

weekly_high_plot = this_wopen + weekly_high_avg 

plot(weekly_high_plot, "60 minute high", color=color.green)

//  15 nminute highs

monthly_high_avg = (mhigh1 + mhigh2 + mhigh3 + mhigh4 + mhigh5) / 5 

monthly_high_plot = this_mopen + monthly_high_avg 

filla = plot(monthly_high_plot, "15 minute high", color=color.green)

// 15 minute lows 

monthly_low_avg = (mlow1 + mlow2 + mlow3 + mlow4 + mlow5) / 5 

monthly_low_plot = this_mopen - monthly_low_avg

fillb = plot(monthly_low_plot, "15 minute low", color=color.red)

// 30 minute highs

daily_high_avg = (dhigh1 + dhigh2 + dhigh3 + dhigh4 + dhigh5) / 5 

daily_high_plot = this_dopen + daily_high_avg 


plot(daily_high_plot, "30 minute high", color=color.green)

// 30 minute low 

daily_low_avg = (dlow1 + dlow2 + dlow3 + dlow4 + dlow5) / 5 

daily_low_plot = this_dopen - daily_low_avg 

plot(daily_low_plot, "30 minute low", color=color.red)

// Sentiment 

pp = (last_dhigh + last_dlow + last_dclose) / 3 

bool bullish = today_close > pp 
bool bearish = today_close < pp 

color bullcolor = color.new(color.green, 85) 
color bearcolor = color.new(color.red, 85) 

color sent = bullish ? bullcolor : bearish ? bearcolor : na 

fill(filla, fillb, color=sent)