Volume Avg indicator to show %?  [SOLVED]

Questions about MultiCharts and user contributed studies.
Jlonn
Posts: 6
Joined: 18 Nov 2013

Volume Avg indicator to show %?

Postby Jlonn » 18 Nov 2013

Hi guys.
Im looking for a way to alter the code for the indicator Volume Avg.
It performs as I want in the charts. But when added to the Watchlist/Scanner I want it to apear a bit different.

I want the indicator to show one column showing the difference between Vol and VolAvg in procentage. Ex. Vol is 340% larger then VolAvg. I want to create a list that I can sort showing the procentual difference between Vol and VolAvg.

The current code look like this:

Code: Select all

inputs:
AvgLength( 50 ),
AlertPct( 50 ),
UpColor( Cyan ),
DownColor( Red ) ;

variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 1 + AlertPct * .01 ),
var5( NumToStr( AlertPct, 2 ) ) ;

if BarType >= 2 and BarType < 5 then
begin
var0 = Volume ;
var1 = AverageFC( Volume, AvgLength ) ;
Plot1( var0, "Vol" ) ;
Plot2( var1, "VolAvg" ) ;

condition1 = var0 crosses over var1 * var4 ;
if condition1 then
Alert( "Volume breaking through " + var5 + "% above its avg" ) ;
end
else

begin
var2 = Ticks ;
var3 = AverageFC( Ticks, AvgLength ) ;
Plot1( var2, "Vol" ) ;
Plot2( var3, "VolAvg" ) ;

condition1 = var2 crosses over var3 * var4 ;
if condition1 then
Alert( "Volume breaking through " + var5 + "% above its avg" ) ;
end ;


if C > C[1] then
SetPlotColor( 1, UpColor )
else if C < C[1] then
SetPlotColor( 1, DownColor ) ;
The indicator looks like this at the moment:
Attachments
Volume Avg.PNG
Volume Avg Look like this at the moment but I want only one column comparing Vol and Vol Avg in procent
(14.31 KiB) Downloaded 682 times

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 67 times

Re: Volume Avg indicator to show %?  [SOLVED]

Postby Roman MultiCharts » 19 Nov 2013

Hello Jlonn,

I've modified your script and added the third column that shows % difference between the Vol and VolAvg. If Vol > VolAvg then a green precent value is shown. Red percent value will be shown when VolAvg > Vol.

I may suggest you to play around with the style of this indicator. Right click on any cell of this indicator --> Format study for All instruments --> Style tab.

I've set it in the following way:
Color --> Default (except VolAvg, I've made it yellow)
Align --> Center
Format --> Number
Decimals --> 0

It looks good for me. Check out the attachement.

Image

Code: Select all

inputs:
AvgLength( 50 ),
AlertPct( 50 ),
UpColor( Cyan ),
DownColor( Red ) ;

variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 1 + AlertPct * .01 ),
var5( NumToStr( AlertPct, 2 ) ) ;

if BarType >= 2 and BarType < 5 then
begin
var0 = Volume ;
var1 = AverageFC( Volume, AvgLength ) ;
if var0 > var1 and var1 > 0 then value1 = var0/(var1*0.01);
if var1 > var0 and var0 > 0 then value1 = var1/(var0*.01);


Plot1( var0, "Vol" ) ;
Plot2( var1, "VolAvg" ) ;
plot3( value1, "% difference");

condition1 = var0 crosses over var1 * var4 ;
if condition1 then
Alert( "Volume breaking through " + var5 + "% above its avg" ) ;
end
else

begin
var2 = Ticks ;
var3 = AverageFC( Ticks, AvgLength ) ;
if var2 > var3 and var3 > 0 then value2 = var2/(var3*0.01);
if var3 > var2 and var2 > 0 then value2 = var3/(var2*.01);


Plot1( var2, "Vol" ) ;
Plot2( var3, "VolAvg" ) ;
plot3( value2, "% difference");

condition1 = var2 crosses over var3 * var4 ;
if condition1 then
Alert( "Volume breaking through " + var5 + "% above its avg" ) ;
end ;

if var0 > var1 or var2 > var3 then begin
setplotcolor(3, green);
end else begin
setplotcolor(3, red);
end;


if C > C[1] then
SetPlotColor( 1, UpColor )
else if C < C[1] then
SetPlotColor( 1, DownColor ) ;
Attachments
Scanner Vol and VolAvg Difference in Percent.JPG
(42.25 KiB) Downloaded 802 times

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Volume Avg indicator to show %?

Postby MAtricks » 20 Nov 2013

Thanks Roman. Very helpful!

Jlonn
Posts: 6
Joined: 18 Nov 2013

Re: Volume Avg indicator to show %?

Postby Jlonn » 23 Nov 2013

Roman this AWESOME, Thanks alot.

BUT..
I cant seem to compile the indicator :(

Im getting this message:

------ Compiled with error(s): ------
Compile error
line 0, column 0


Hopefully a easy solution.

Thank you again for your support and effort, priceless.

/Jlonn

Jlonn
Posts: 6
Joined: 18 Nov 2013

Re: Volume Avg indicator to show %?

Postby Jlonn » 23 Nov 2013

Hi again Roman.

I got it to work, was not enough restarting MC, had to restart the computer as well :)

I am having a issu with sorting for the most % deviation. It wont really sort very well and I don´t get the largest deviation on top of the list.

Thanks
/ Jlonn

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 67 times

Re: Volume Avg indicator to show %?

Postby Roman MultiCharts » 25 Nov 2013

Hi Jlonn,

Could you please provide a screenshot of the scanner window with incorrect readings?

Thanks.


Return to “MultiCharts”