Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
// __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;
Is there a way to get this code to work on radar screen?