[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cum or Sum



PureBytes Links

Trading Reference Links

Bernard,
C<Ref(C,-4) gives ==1 when C is smaller than Ref(C,-4) and gives ==0 
when not.
CUM(C < Ref(C,-4)) gives the sum of all 1 from the beginning of your 
data, since
  
CUM : SYNTAX cum( ARRAY ) 
RETURNS ARRAY 
FUNCTION Calculates a cumulative sum of the ARRAY from the first 
period in the chart 

SUM needs a period, since

SUM : SYNTAX sum( ARRAY, periods ) 
RETURNS ARRAY 
FUNCTION Calculates a cumulative sum of the ARRAY for the specified 
number of lookback periods (including today). 

Example: 
CD=SUM(C < Ref(C,-4),30);
will add all 1 occurred the last 30 days.
Take care of Ref(C,4), it looks 4 days forward in the future.
If you want 4 days ago, use only Ref(c,-4).
Hope this help.
Dimitris Tsokakis

--- In amibroker@xxxx, Bernard Bourée <bernard@xxxx> wrote:
> Hello
> 
> I'm trying to code some lines in order to find
> how many consecutive bars where closing prices are lower than 4 
bars ago.
> 
> Should I code CD = SUM(C < Ref(C, 4)
> or CD = CUM(C < Ref(C,-4) ?
> 
> Thanks
> 
> 
> Bernard Bourée
> bernard@xxxx