I am trying to edit this
RVOL script to fit thinkscript and am having trouble.... anyone who could help I would love!!!
//@version=3
study("RVOL - Final on 814 for 3m Candles ONLY")
//Trade Ideas
Relative Volume Indicator used to assist in alignment of the final ratio. Final adjustment used the square root function.
start_hr = input(9,"Session Start - Hour", minval = 0, maxval = 30) //
NASDAQ starts at 9:30 and ends at 16:00
start_min = input(30,"Session Start - Min", minval = 0, maxval = 59) //NSE - India starts at 9:15 and ends at 15:30
end_hr = input(16,"Session End - Hour", minval = 0, maxval = 30)
end_min = input(00,"Session End - Min", minval = 0, maxval = 59)
//Converts start & end time into fractional hour
start_time = (start_hr + (start_min/60))
end_time = (end_hr + (end_min/60))
total_min_in_session = (end_time - start_time)*60 //Total minutes in a trading day
bar_interval = 3 //Assigns timeframe value to bar_interval. e.g 5 min chart => 5, 1 H chart => 60
no_of_bars = 130 //((total_min_in_session/bar_interval)) //This gets no. of bars in an intraday session for given timeframe. e.g 5 min chart => 75, 30 min chart => 13
rvol_average = input(20,"RVOL Period", minval = 1, maxval = 20) //Calculates average volume of till that time volume of given number of sessions. Not quite sure what I said, ehh ?
//Getting the current bar number in the current session. For 5 min chart it should be between 1 to 75
fr_now = ((minute + bar_interval)/60) //Currentbar fraction hour
currentsession_bar_no = ((hour + fr_now) - start_time)*(60/bar_interval) //Currentbar number from start of the session e.g end of session bar numbber = 75, start of session bar number = 1
//RVOL Calculation
x = 130
//Sectional RVOL Calculation as per users choice
rvol_sectional = input(true, title = "RVOL Sectional", type = bool)
//Now updated script will divide session into available full hours of the trading day. e.g NSE in 6, NASDAQ in 6, LSE in 8 likewise
trday_sessions = floor(end_time - start_time)
rvol_from_session = input(1, title = "RVOL From Session", type = integer, minval = 1, maxval = 12) //You take bar start of that session
rvol_to_session = input(6, title = "RVOL To Session", type = integer, minval = 1, maxval = 12) //You take one bar below that session (Use Ceil function)
//This ensures the trading day is divided into full hour sessions
rvol_from_session := rvol_from_session <= trday_sessions ? rvol_from_session : trday_sessions
rvol_to_session := rvol_to_session <= trday_sessions ? rvol_to_session : trday_sessions
rvol_bar_start = floor(no_of_bars/trday_sessions)*(rvol_from_session - 1) + 1
rvol_bar_end = rvol_to_session == trday_sessions ? no_of_bars : floor(no_of_bars/trday_sessions)*(rvol_to_session)
calculate_sec_rvol = (rvol_sectional == true) and ((currentsession_bar_no >= rvol_bar_start) and (currentsession_bar_no <= rvol_bar_end)) ? 1 : 0
//..............................................................................
volsum_current_sec = 0.0
volsum_history_sec = 0.0
RVOL_sec = 0.0
if (calculate_sec_rvol == 1)
volsum_current_sec := (currentsession_bar_no == rvol_bar_start) ? volume : volsum_current_sec[1] + volume
//Clears volume sum history at the start of session
if (currentsession_bar_no == rvol_bar_start)
volsum_history_sec := 0
if (n >= x)
for i = 1 to rvol_average
volsum_history_sec := volsum_history_sec + volume[no_of_bars*i]
volsum_history_sec := (currentsession_bar_no == rvol_bar_start) ? volsum_history_sec : volsum_history_sec[1] + volsum_history_sec
RVOL_sec := volsum_current_sec/(volsum_history_sec/rvol_average)
//..............................................................................
if (currentsession_bar_no > rvol_bar_end)
RVOL_sec := 0
volsum_current = 0.0
volsum_history = 0.0
volsum_current := (minute == start_min and hour == start_hr) ? volume : volsum_current[1] + volume
//Clears volume sum history at the start of session
if (minute == start_min and hour == start_hr)
volsum_history := 0
if (n >= x)
for i = 1 to rvol_average
volsum_history := volsum_history + volume[no_of_bars*i]
volsum_history := (minute == start_min and hour == start_hr) ? volsum_history : volsum_history[1] + volsum_history
RVOL = volsum_current/(volsum_history/rvol_average)
rvol_trigger = input(2, "RVOL Trigger", type = float, minval = 0.2, maxval = 10, step = 0.1)
if rvol_sectional
RVOL := calculate_sec_rvol == 1 ? RVOL_sec : 0
if not(rvol_sectional)
RVOL := RVOL
// colors
col=na
if sqrt(RVOL)<.5
col:=red
if sqrt(RVOL)>=.5 and sqrt(RVOL)<.65
col:=orange
if sqrt(RVOL)>=.65 and sqrt(RVOL)<1
col:=#BBBE1B
if sqrt(RVOL)>=1 and sqrt(RVOL)<1.25
col:=#F9FD05
if sqrt(RVOL)>=1.25 and sqrt(RVOL)<1.5
col:=#3B9909
if sqrt(RVOL)>=1.5 and sqrt(RVOL)<2
col:=#7ADB46
if sqrt(RVOL)>=2
col:=lime
plot(sqrt(RVOL) , color=col, style = columns)
hline(.5, linestyle=dotted, linewidth=1, color=red)
hline(1.25, linestyle=dashed, linewidth=1, color=lime)