Coding Different Resolutions in the Same Scanner Window

Questions about MultiCharts and user contributed studies.
eztraderjr
Posts: 18
Joined: 02 Sep 2012
Has thanked: 5 times

Coding Different Resolutions in the Same Scanner Window

Postby eztraderjr » 17 Sep 2012

I have a scanner window and am trying to set up two indicators. Unfortunately, I would like these indicators to use different resolutions for their calculations and have not found how to define a different resolution in EasyLanguage.

Specifically, one indicator uses a 5 second resolution and I have set the resolution in the scanner window for 5 seconds. The second indicator is a simple daily volume and daily average volume. I can obtain the daily volume easily by using the quote field DailyVolume; however, quote fields cannot be accessed historically so I cannot obtain previous days volumes.

I tried to assign the BarType and BarInterval within the code, but this generates an error. I have also not found any reference to multiple time frame indicators within the same scanner window.

I am sure this is a relatively easy thing to do and any tips would be welcome.

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Coding Different Resolutions in the Same Scanner Window

Postby SP » 17 Sep 2012

You could use the _AvgWhenTrueV2 function posted here
viewtopic.php?f=1&t=10025&p=48287&hilit ... eV2#p48287

with this code. It plots the Average Daily Volume of the last DailyAvgVolLen days excluding todays volume. Make sure that you have loaded more than DailyAvgVolLen days back.

Code: Select all


inputs:
DailyAvgVolLen( 10 ) ;

variables:
SumDailyVolume( 0 ),
AvgDailyVolume( 0 ),
YesterdaysVolume ( 0 ) ;

// If the current bar is the first new bar of the day then
// reset the sum of the daily volume back to the first bar's
// volume (ticks), else add the current bar volume to the
// daily volume.
if Date <> Date[1] then
begin
YesterdaysVolume = SumDailyVolume [1];

// Use the _AvgWhenTruev2 function to calculate the average of the
// daily volume over the user specified DailyAvgVolLen days.
AvgDailyVolume = _AvgWhenTrueV2( True, SumDailyVolume, DailyAvgVolLen, 0, false ) ;

// Reset the sum of the daily volume to the day's first bar's volume
SumDailyVolume = Ticks ;

end
else
SumDailyVolume = SumDailyVolume + Ticks ;


// Todays Volume
Plot1 (SumDailyVolume , "DailyVolume");
// Yesterdays Volume
Plot2 (YesterdaysVolume ,"YesterdaysVolume ");
// Average Daily Volume
Plot3( AvgDailyVolume, "AvgDVol" ) ;

eztraderjr
Posts: 18
Joined: 02 Sep 2012
Has thanked: 5 times

Re: Coding Different Resolutions in the Same Scanner Window

Postby eztraderjr » 18 Sep 2012

Thanks SP. Have not had a chance to try this out yet since I am trying to earn a living in the trading world, but will work on this as time permits. Trying to learn easylanguage so that I can add some essential (to me) conveniences while still trading using a new platform is stretching me a bit so your assistance is definitely appreciated.

Too bad you cannot just change the resolution on a single indicator. Would have made life much easier.

ez


Return to “MultiCharts”