I believe that ValueWhen will do what you want, as shown below.

PrevClose = Ref(Close, -1);
Indices = BarIndex();

Rising = Close > PrevClose;
FailureBars = ValueWhen(NOT Rising, Indices);
ConsecutiveRise = Indices - FailureBars;

Colors = IIF(Rising, colorDarkGreen, IIF(Close < PrevClose, 
colorDarkRed, colorLightGrey));
Plot(ConsecutiveRise, "Consecutive Up Bars", Colors, styleLine | 
styleOwnScale);
Plot(Close, "Close", Colors, styleNoTitle | styleBar); 

Mike

--- In amibroker@yahoogroups.com, "Soham" <soham...@...> wrote:
>
> The issue is I want to handle the consecutive days.
> 
> For example, for those who have read Curtis Faith, I want to check 
if
> my market is trending and quite as opposed to trending and violent.
> That is having huge violent ups and downs.
> 
> In effect, I am trying to check, if its possible to use breakout 
rules
> in Indian markets.
> 
> I am stuck here:
> My code goes something like this:
> 
> LongTrigger= C>BBandTop(C,22,1.5);
> 
> if(LongTrigger==1)
> {
> //count the number of *consecutive* days when the closing prices
> exceed the previous close
> }
> Additionally I will include more studies, into this, as to when it
> indeed retraces, how much does it retrace.etc etc.
> I am not able to find a way to implement the internal pseudocode
> elegantly. Sum() and Cum() just counts the number of up down days in
> some period.Not consecutively.
> 
> Looking for some insight and help
> 
> Soham
> --- In amibroker@yahoogroups.com, "Soham" <sohamdas@> wrote:
> >
> > Hi guys,
> > 
> > Although I am familiar with AFL but strangely finding myself not 
able
> > to get my work done.
> > 
> > I am having a requirement to:
> > 
> > 1. Count the number of days,Close is above [or below] the 
bollinger band
> > 2. And count the number of days for which it has trended in the 
same
> > direction.
> > 
> > I would additionally love to see, a standard histogram of 
trending days.
> > 
> > Can you help me out?
> > 
> > 
> > Soham
> >
>


Reply via email to