NexusFi: Find Your Edge


Home Menu

 





RVOL Indicator ThinkScript help


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,286 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

RVOL Indicator ThinkScript help

  #1 (permalink)
 Ninman 
Ft Lauderdale/United States
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini ES
Posts: 4 since Jun 2018
Thanks Given: 1
Thanks Received: 0

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)

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Cheap historycal L1 data for stocks
Stocks and ETFs
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35


Ninman View Post
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)

Can you post what you have so far and/or what this does?

Follow me on Twitter Reply With Quote




Last Updated on September 24, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts