PureBytes Links
Trading Reference Links
|
Hi markus
this formula shows one way in which you can use the actual
barssince count value from one condition to the next.
this is not an example of what you asked , but it may help you to
learn.
the best way to learn what certain functions do is to use it in the
AA in the explorer and ADD columns of the variables to see what its
doing.
The question you asked does not need to use the barssince function
to count the bars from a cond to the next.
What this formula below does , is find the lowestvalue from a
previous condition to todays condition, e.g. from the previous XX to
todays XX, so its not the actual previous true condition value, it s
the lowest value in between them.
it also finds the previous highest value from a previous cond to
todays true cond, e.g.yy to yy. highest value in between.
what i dont understand is that if i tried to use the highestsince
or lowestsince function in the way i thought it was to be used it
would not be the value i was looking for, so i used the barssince
value as the ref value( see variable line oo and oo2 in the code
below.)
you can plot it in the indicator builder or run an exploration .
the yellow lines are the previous lowest value true cond ,but
plotted at todays true cond,
the blue is the previous highest value true cond but plotted today.
sorry about the messy variable arrangement
Days=2;
zz1=IIf(L==LLV(Low,Days),1,0);//l
Yy1=IIf(H==HHV(High,Days),1,0);//h
Cc=ValueWhen(zz1==1,L,1);//l
dd=ValueWhen(yy1==1,H,1);//h
zz=IIf(L<Ref(Cc,-1),1,0);//l
yy=IIf(H>Ref(dd,-1),1,0);//h
z1=zz==1;
//BarsSince(z==0);
y1=yy==1;
//BarsSince(y==0);
Cc=ValueWhen(z1,L,1);
dd=ValueWhen(y1,H,1);
ff=ExRem(z1==1,y1==1);//l
Hh=ExRem(y1==1,z1==1);//h
Hh1=ExRem(Hh,ff);//l
ff1=ExRem(ff,Hh);//h
kk=ValueWhen(Hh1,L,1);//l
Ll=ValueWhen(ff1,H,1);//h
previouslow=ff1==1;
ii=ValueWhen(previouslow,L,1);
mm=BarsSince(previouslow==1)==1;
Oo=IIf(previouslow,LowestSince(Ref(previouslow,-mm) ,L,2),0);
LLL=ValueWhen(Oo,Oo,1);
previoushigh=hh1==1;
ii2=ValueWhen(previoushigh,H,1);
mm2=BarsSince(previoushigh==1)==1;
Oo2=IIf(previoushigh,HighestSince(Ref(previoushigh,-mm2) ,H,2),0);
LLL2=ValueWhen(Oo2,Oo2,1);
mmm=IIf(Hh1,6,IIf(ff1,7,1));
Plot(C,"",mmm,64);//l
Plot(C ,"",1,64);//l
Plot(LLL ,"",7,4);//l
Plot(LLL2 ,"",6,4);//l
AddColumn(zz,"zz");
AddColumn(yy,"yy");
AddColumn(Hh1,"hh1");
AddColumn(ff1,"ff1");
AddColumn(kk,"kk");
AddColumn(Ll,"ll");
AddColumn(mm,"mm");
Filter=1;
Buy=hh1==1 AND kk<Lll;
Sell=Ll;
Filter=1;
Buy=IIf(kk<Lll2,hh1==1,0);
;
Sell=IIf(Ll<Lll2,ff1==1,0) ;
cheers: john.
--- In amibroker@xxxx, "IVA GmbH" <funnybiz@xxxx> wrote:
> Folks,
>
> would someone help me with this:
>
> I need to calculate how many time periods have been passed since
>
> zz and yy
>
> whereby
>
> z=iif(low<Ref(llv(low,5), -1),1,0)
> zz=valuewhen(z==1,low,1)
>
> and
>
> y=iif (high>Ref(hhv(high,5), -1),1,0)
> yy=valuewhen(y==1,high,1)
>
> ???????????????
>
> I thought of
>
> barssince (y==1) - barssince (zz==1) but that dosnīt return the
desired result.
>
> Thanks a lot!!
>
> Markus
|