NexusFi: Find Your Edge


Home Menu

 





RVOL code for TS


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one olobay with 4 posts (3 thanks)
    2. looks_two mashtee2003 with 2 posts (1 thanks)
    3. looks_3 w4rri0r with 2 posts (0 thanks)
    4. looks_4 ABCTG with 1 posts (0 thanks)
    1. trending_up 6,042 views
    2. thumb_up 4 thanks given
    3. group 9 followers
    1. forum 12 posts
    2. attach_file 2 attachments




 
 

RVOL code for TS

 
 mashtee2003 
Newport Beach,CA,USA
 
Experience: Advanced
Platform: TOS
Broker: TD
Trading: Daytrader
Posts: 10 since Aug 2011
Thanks Given: 9
Thanks Received: 2

Hi All,
Does anyone have the code for RVOL in TS?
Thanks so much in advance,
Peyt

Started this thread

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Exit Strategy
NinjaTrader
Futures True Range Report
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
ZombieSqueeze
Platforms and Indicators
 
 
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011


mashtee2003 View Post
Hi All,
Does anyone have the code for RVOL in TS?
Thanks so much in advance,
Peyt

 
Code
// __RACumVol - Average Cumulative Volume at this time for the last X days. 
// Must be used on minute-type intraday charts 
	 
Inputs:  
 DaysToAvg(20); 
 
Variables:  
    BarInDay(0), 
	BarsToday(0), 
	CumVolToday(0), 
	DayNumber(-99), 
	BarsPerDay(26),  
	TotCumVol(0), 
	AvgCumVol(0), 
	VolPercentile(0); 
 
 
// Declare the array.  Rows = number of days to average; columns = number of bars per day. 
// Add one to rows to avoid using row 0. 
IF BarType = 1 then 
BEGIN 
	value1 = TimeToMinutes(SessionEndTime(0,1)) - TimeToMinutes(SessionStartTime(0,1)); 
	value1 = value1/BarInterval; 
	 
	If FracPortion(value1) = 0 then 
		BarsPerDay = value1 
	else 
		BarsPerDay = value1 + 1 - FracPortion(value1); 
 
Arrays: VolArray[22,466] (0); // Note max bars of 405 ( 1 minute 9:30 - 16:15 ) 
 
If Date<>Date[1] THEN  
BEGIN	 
 
    //If we've passed day 20, then move everybody back a seat. 
	// All of day 2's data in the array goes into day 1, day 3 into day 2, etc, up through 21 into day 20.	 
	IF DayNumber+1 > DaysToAvg +1 THEN  
	BEGIN 
		For Value1=1 to DaysToAvg Begin; {Outer loop - one for each day, 1-20 + current day }	        
           For Value2 = 1 to BarsPerDay Begin; {Inner Loop - one for each bar in a day, 1-26} 
              VolArray[Value1,Value2] = Volarray[Value1+1 ,Value2]; 
	   	   End; 
		End; 
 
	END;	 
 
    // Start/Increment Day Counter.  It never goes above 21. 
	IF Daynumber = -99 THEN DayNumber = 1 {Start of first full day on the chart} 
	ELSE DayNumber = MinList(DayNumber+1,DaysToAvg+1) ;        {Start of a subsequent day, never goes above 21}	 
 
	// Reset cumulative daily bar and volume counters, since on first bar of a new day. 
	CumVolToday = 0; 
	BarsToday = 0;	 
	 
	// Clear out array row number (days to average + 1) for today's data. Previously moved it into day 20 in the array. 
    IF DayNumber >= DaysToAvg  + 1 THEN  
		For Value2 = 1 to BarsPerDay Begin 
			VolArray[DaysToAvg  + 1, Value2] = 0; 
		End;		 
END; {tasks for first bar of each day} 
 
IF Daynumber <> -99 THEN  
BEGIN	 
 
	// Increment bar and volume counters. 
	BarsToday = BarsToday + 1; 
	CumVolToday = CumVolToday + Volume; 
 
	// Store today's cumulative volume into the array, in the column for this bar. 
	VolArray[DayNumber, BarsToday] = CumVolToday; 
END; 
 
// Now calculate the 20-day cumulative average volume through this bar, if we have enough data. 
If Daynumber > DaysToAvg THEN  
BEGIN 
		TotCumVol = 0; 
	    // Add up the cumulative volume through this time for each of the past 20 days. 
		For Value3 = 1 To DaysToAvg Begin 
			TotCumVol = TotCumVol + VolArray[Value3, BarsToday]; 
		End;		 
		// And divide it by the number of days to get the average cumulative daily volume through this time of day. 
		AvgCumVol = IntPortion(TotCumVol / DaysToAvg); 
		// Now compare today's ccumulative volume to the average. 
	    VolPercentile = IFF(AvgCumVol > 0, CumVolToday *100 / AvgCumVol, 0); 
	     
	    Plot1(VolPercentile-100,"VPctAvg");  
	    Plot2(0,"100%");  
END; 
END;

 
 mashtee2003 
Newport Beach,CA,USA
 
Experience: Advanced
Platform: TOS
Broker: TD
Trading: Daytrader
Posts: 10 since Aug 2011
Thanks Given: 9
Thanks Received: 2



olobay View Post
 
Code
// __RACumVol - Average Cumulative Volume at this time for the last X days. 
// Must be used on minute-type intraday charts 
	 
Inputs:  
 DaysToAvg(20); 
 
Variables:  
    BarInDay(0), 
	BarsToday(0), 
	CumVolToday(0), 
	DayNumber(-99), 
	BarsPerDay(26),  
	TotCumVol(0), 
	AvgCumVol(0), 
	VolPercentile(0); 
 
 
// Declare the array.  Rows = number of days to average; columns = number of bars per day. 
// Add one to rows to avoid using row 0. 
IF BarType = 1 then 
BEGIN 
	value1 = TimeToMinutes(SessionEndTime(0,1)) - TimeToMinutes(SessionStartTime(0,1)); 
	value1 = value1/BarInterval; 
	 
	If FracPortion(value1) = 0 then 
		BarsPerDay = value1 
	else 
		BarsPerDay = value1 + 1 - FracPortion(value1); 
 
Arrays: VolArray[22,466] (0); // Note max bars of 405 ( 1 minute 9:30 - 16:15 ) 
 
If Date<>Date[1] THEN  
BEGIN	 
 
    //If we've passed day 20, then move everybody back a seat. 
	// All of day 2's data in the array goes into day 1, day 3 into day 2, etc, up through 21 into day 20.	 
	IF DayNumber+1 > DaysToAvg +1 THEN  
	BEGIN 
		For Value1=1 to DaysToAvg Begin; {Outer loop - one for each day, 1-20 + current day }	        
           For Value2 = 1 to BarsPerDay Begin; {Inner Loop - one for each bar in a day, 1-26} 
              VolArray[Value1,Value2] = Volarray[Value1+1 ,Value2]; 
	   	   End; 
		End; 
 
	END;	 
 
    // Start/Increment Day Counter.  It never goes above 21. 
	IF Daynumber = -99 THEN DayNumber = 1 {Start of first full day on the chart} 
	ELSE DayNumber = MinList(DayNumber+1,DaysToAvg+1) ;        {Start of a subsequent day, never goes above 21}	 
 
	// Reset cumulative daily bar and volume counters, since on first bar of a new day. 
	CumVolToday = 0; 
	BarsToday = 0;	 
	 
	// Clear out array row number (days to average + 1) for today's data. Previously moved it into day 20 in the array. 
    IF DayNumber >= DaysToAvg  + 1 THEN  
		For Value2 = 1 to BarsPerDay Begin 
			VolArray[DaysToAvg  + 1, Value2] = 0; 
		End;		 
END; {tasks for first bar of each day} 
 
IF Daynumber <> -99 THEN  
BEGIN	 
 
	// Increment bar and volume counters. 
	BarsToday = BarsToday + 1; 
	CumVolToday = CumVolToday + Volume; 
 
	// Store today's cumulative volume into the array, in the column for this bar. 
	VolArray[DayNumber, BarsToday] = CumVolToday; 
END; 
 
// Now calculate the 20-day cumulative average volume through this bar, if we have enough data. 
If Daynumber > DaysToAvg THEN  
BEGIN 
		TotCumVol = 0; 
	    // Add up the cumulative volume through this time for each of the past 20 days. 
		For Value3 = 1 To DaysToAvg Begin 
			TotCumVol = TotCumVol + VolArray[Value3, BarsToday]; 
		End;		 
		// And divide it by the number of days to get the average cumulative daily volume through this time of day. 
		AvgCumVol = IntPortion(TotCumVol / DaysToAvg); 
		// Now compare today's ccumulative volume to the average. 
	    VolPercentile = IFF(AvgCumVol > 0, CumVolToday *100 / AvgCumVol, 0); 
	     
	    Plot1(VolPercentile-100,"VPctAvg");  
	    Plot2(0,"100%");  
END; 
END;

Thanks so much!

Started this thread
Thanked by:
 
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7

it doesn't plot anything on my charts

 
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011


w4rri0r View Post
it doesn't plot anything on my charts

Must be used on minute-type intraday charts.

 
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7


olobay View Post
Must be used on minute-type intraday charts.

that's what get with a 1 min bar chart

 
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011


w4rri0r View Post
that's what get with a 1 min bar chart

Make sure you have more days loaded on your chart than your days to average in the indicator.

 
 planetmoto 
freasno, ca usa
 
Experience: Advanced
Platform: ninja trader
Trading: forex
Posts: 104 since Apr 2013
Thanks Given: 51
Thanks Received: 85

I am getting the same error even though I have the days loaded set higher than avg calculation, still doesn't work. Tried 1min and 5min chart and different symbols, chart wont load any data at all. Totally blank????? Any help appreciated..

 
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

It works for me in Multicharts with the above code.


 
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


planetmoto,

from glancing at the code there are probably two common reason why the indicator might not display a result or raise an error message.
"Not displaying results" could be caused by too little data present on the chart and you should be able to overcome this by making sure that you have a few more days present on the chart than what you specified with the DaysToAvg input. The indicator will not display results on the initial DaysToAvg number of calculation days. A quick test if this is the problem could fpr example be to load 40 days back (this should rule out the possibility that the actual number of days on the chart is too low due to weekends/holidays) and use a DaysToAvg input of 20.

If the indicator raises an error message along the lines of "array bounds" (the actual error message will depend between TS and MC) this could be caused by the code trying to store values out of the bounds of the array.
The code "Arrays: VolArray[22,466] (0); // Note max bars of 405 ( 1 minute 9:30 - 16:15 ) " set's the array to a specific size. Applying the indicator to a 1 minute chart of the full session might cause the error simply because the array is too small to handle the amount of data. The same error message could be caused by using a DaysToAvg input above 22. The code appears to be designed to be used with the DaysToAvg not higher than 20 while being applied to the intraday floor session.

What symbol and chart settings did you apply the code to exactly and what inputs did you use?

Regards,

ABCTG


planetmoto View Post
I am getting the same error even though I have the days loaded set higher than avg calculation, still doesn't work. Tried 1min and 5min chart and different symbols, chart wont load any data at all. Totally blank????? Any help appreciated..


Follow me on Twitter

 



Last Updated on May 4, 2023


© 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