Counting problem

hello,

I have a code:

iloscBar=Param("iloscBar",14,1,100);

newDay=Ref(Day(),-1)!=Day();

for( i = 1; i <= iloscBar ; i++ )
{
        srednia = ValueWhen( newDay, V, i );
}

but i have problem and I don’t now wat to do to get a sume “srednia”.
Please help.

Moderator comment: Please respect the forum rules. Your post had invalid formatting and I had to correct it. Read “how to use this site” first and follow the rules.

dn = DateNum();

newDay = dn != Ref( dn, -1 );

csum = SumSince( newday, V ) + ValueWhen( newday, V );

Plot( csum, "Volume since Start of Day", colorGreen, styleHistogram, Null, Null, 0, 0, -60 );

1

or


iloscBar=Param("iloscBar",14,1,100);

dn = DateNum();

newDay = dn != Ref( dn, -1 );

csum = SumSince( newday, V ) + ValueWhen( newday, V );

Plot( IIf( BarsSince(newday) + 1 <= iloscBar, csum, Null ), "Volume since Start of Day", colorGreen, styleHistogram, Null, Null, 0, 0, -60 );
3 Likes

@Chupacabra I interpreted your question a little differently than @fxshrat so here is a 2nd possible solution. If you are looking for the Sum of Volumes over the last “iloscBar” number of bars then this will do it for you

iloscBar = Param( "iloscBar", 14, 1, 100 );

SumOfVolume = Sum( Volume, iloscBar );
1 Like

@fxshrat, @portfoliobuilder thanks for the answer, but I need sum volume only in first bar on a newday. “iloscBar” is the number of days back.

@Chupacabra,
And why don’t you say so in your first post then but rather leave much room for guessing?
Have you read here How to use this site ?

/// @link http://forum.amibroker.com/t/counting-problem/2500/5
SetBarsRequired( 10000, 10000 );

iloscBar = Param("iloscBar",14,1,100); 

dn = DateNum(); 
newDay = dn != Ref( dn, -1 ); 

spV = SparseCompress( newday, V );
	spsum = Sum( spV, iloscBar );
csum = SparseExpand( newday, spsum );

Plot( Valuewhen( newday, csum ), "Sum(Volume) at Starts of Day", colorGreen, styleHistogram, Null, Null, 0, 0, -60 );
3 Likes

@fxshrat Thanks and sorry for the unspecification.