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

Re: Calculating bars between two arguments



PureBytes Links

Trading Reference Links

Hi markus.

if you would like to find the highest value or lowest value try this.

this will plot the lowest value in betwen zz and xx.
so when xx is true,(the blue outlined bar) the yellow valueline on 
this day will be the lowest value from when the previous zz  
condition was true (the yellow outlined bar) to the xx condition. It 
will also include xx as the lowest value if xx happens to be the 
lowest value fromm zz.


It also finds the highest value fromm xx to zz.
so when zz is true (yellow outlined bar ) the blue valueline will 
hold the highest value in between xx to zz.

so when the outline of the bar is yellow ( zz cond true)look at the 
value of the blue line on this day, and it will be the highest value 
since the previos blue outlined bar.
it will not plot the line on the highest bar unless it actually 
occurs on the day that zz is true.(yellow outlined bar).
same rule for the lowest value but its the blue outlined bar (cond 
xx is true) then the value of the yellow line is the lowest value 
since the previous true zz cond .

I still dont understand why i had to exrem twice, so if you blank 
out these lines 
ff=ExRem(zz==1,yy==1);//l
Hh=ExRem(yy==1,zz==1);//h
Hh1=ExRem(Hh,ff);//l
ff1=ExRem(ff,Hh);//h

and replace it with this  
Hh1=ExRem(zz,yy);
ff1=ExRem(yy,zz);

it sometimes gets 2 xx or yy conditions in a row, but exreming it 
twice fixes this.


Days=2;
zz1=IIf(L==LLV(Low,Days),1,0);//l
Yy1=IIf(H==HHV(High,Days),1,0);//h
Cc=ValueWhen(zz1,L,1);//l
dd=ValueWhen(yy1,H,1);//h
zz=IIf(L<Ref(Cc,-1),1,0);//l
yy=IIf(H>Ref(dd,-1),1,0);//h

Cc=ValueWhen(zz,L,1);
dd=ValueWhen(yy,H,1);

ff=ExRem(zz==1,yy==1);//l
Hh=ExRem(yy==1,zz==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;
previoushigh=hh1==1;
ii=ValueWhen(previoushigh,H,1);
mm=BarsSince(previoushigh==1)==1;
Oo=IIf(previoushigh,LowestSince(Ref(previouslow,-mm) ,L,1),0);
LLL=ValueWhen(Oo,Oo,1);

previoushigh=hh1==1;
ii2=ValueWhen(previouslow,L,1);
mm2=BarsSince(previouslow==1)==1;
Oo2=IIf(previouslow,HighestSince(Ref(previoushigh,-mm2) ,H,1),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);//previous llv
Plot(LLL2 ,"",6,4);//previous hhv
AddColumn(zz,"zz");
AddColumn(yy,"yy");
AddColumn(Hh1,"hh1");
AddColumn(ff1,"ff1");
AddColumn(kk,"kk");
AddColumn(Ll,"ll");
AddColumn(mm,"mm");
AddColumn(L,"l");
AddColumn(H,"h");
AddColumn(Lll,"lll");
AddColumn(Lll2,"lll2");
Filter=1;
Buy= Cross(C,Lll);
Sell=Cross(Lll2,L) ;


cheers: john. 




--- In amibroker@xxxx, "IVA GmbH" <funnybiz@xxxx> wrote:
> Dimitris,
> 
> many thanks! Iīll try to implement all you showed me.
> 
> >>>>>>>>>One last thing (for the moment ;-o):
> Can draw the swings from the lows and highs directly in the
> chart instead of a separate indicator?<<<<<<<Yes you can.
> 
> 
> Could you give me a clue where to look that up??
> 
> Markus
> 
> 
> ----- Original Message -----
> From: "dtsokakis" <TSOKAKIS@xxxx>
> To: <amibroker@xxxx>
> Sent: Thursday, July 04, 2002 8:20 AM
> Subject: [amibroker] Re: Calculating bars between two arguments
> 
> 
> Markus,
> Nice questions.
> I think you should study AFL. From the beginning.
> It is powerfull enough to give answers even to these questions.
> And many many other you can imagine.
> The other AFL advantage :it is very fast. So, if you change your 
mind
> and you want to calculate something else and then something else, 
you
> can do it immediately.
> This is my ~ 1 year of experience.
> Dimitris Tsokakis
> --- In amibroker@xxxx, "IVA GmbH" <funnybiz@xxxx> wrote:
> > Dimitris,
> >
> > you hit the nail on its head pretty well.
> >
> > That was pretty much what I tried to accomplish. I might take it a
> little
> > further with your assistance later on.
> >
> > A few more questions if you allow:
> >
> > 1./ Why do you say below
> > zy=(BarsSince(y)>BarsSince(z))*(BarsSince(z));//bars from z to y
> > yz=(BarsSince(z)>BarsSince(y))*(BarsSince(y));//bars from y to z
> 
> To solve the question without problems and without more explanatory
> lines...
> 
> > Isnīt ZY=Barssince (y)- barssince (z)???? Analogue for YZ? Why ">"
> and "<",
> 
> You may try with barssince, if you prefer.
> You should know which y and which z, when you use barssince.
> 
> > please??
> >
> > 2./ Can draw the swings from the lows and highs directly in the
> chart
> > instead of a separate indicator?
> Yes you can.
> 
> >
> > 3./ what code would I have to use when -after having detected z 
and
> y- I
> > additionally wanted to check for the lowest low in between?
> See my H&S formula in AFL Library for similar question.
> Well,
> > Lowestsince might work. But if I wanted to detect the next
> > llv>Ref(llv(low,5),-1) before y (letīs call that one point x) and
> then check
> > if Y was the highest high between x and y, lowestsince wouldnīt
> work anymore
> > since it would relate to ALL quotes after sx, correct? Is there 
any
> cokkand
> > that checkest for the highest hifh or the lowest low for a desired
> period of
> > time instead of all following bars after a condition is met?
> 
> > Appreciate it, Dimitris!!!!
> >
> > Markus
> >
> > ----- Original Message -----
> > From: "dtsokakis" <TSOKAKIS@xxxx>
> > To: <amibroker@xxxx>
> > Sent: Sunday, June 30, 2002 1:10 PM
> > Subject: [amibroker] Re: Calculating bars between two arguments
> >
> >
> > Markus,
> > As I wrote in my previous reply, zz and yy, as defined through
> > Valuewhen function, are continuous Arrays, with values for every 
bar
> > and not only for the condition bars. Consequently you can not 
define
> > a time interval between yy and zz.
> > You just suppose and you are interested for yy and zz values on 
the
> > condition days.
> > So, I will keep your
> > "I basically tried to determine howe many bars (i.e. time 
interval)
> > would be
> > in between thos two conditions" to continue.
> > This is the time interval between y and z [or respectively z and 
y]
> > and we shall try to express it.
> > The next question is about multiple z or multiple y.
> > Like buy/sell, we usually have a series
> > 00z0zzz00yyy0yy000000zz0zzz0zz0000y.
> > Do we search the interval between the first z till the first y OR
> the
> > interval between the last z till the first y?
> > Let us solve the first z till the first y.
> > a. Begin with the two conditions
> > z=IIf(Low<Ref(LLV(Low,5), -1),1,0);
> > y=IIf (High>Ref(HHV(High,5), -1),1,0);
> > b. Write them without iif statement
> > z=Low<Ref(LLV(Low,5),-1);
> > y=High>Ref(HHV(High,5), -1);
> > It is the exactly the same, z is 1 when cond=true and 0 when 
false.
> > c. Remove excessive z or excessive y
> > z=ExRem(z,y);y=ExRem(y,z);
> > Now you may calculate the days from z to y or from y to z.
> > The full code is
> >
> > z=Low<Ref(LLV(Low,5),-1);//the z condition
> > y=High>Ref(HHV(High,5), -1);//the y condition
> > z=ExRem(z,y);y=ExRem(y,z);//remove excessive z or excessive y
> > Plot(20*z,"",1,2);//z condition graph, 20* is for scaling purposes
> > Plot(20*y,"",4,2);//y condition graph
> > zy=(BarsSince(y)>BarsSince(z))*(BarsSince(z));//bars from z to y
> > yz=(BarsSince(z)>BarsSince(y))*(BarsSince(y));//bars from y to z
> > Plot(zy,"",3,1);Plot(yz,"",2,1);
> >
> > The code calculates and plots the days [bars] from z to y and then
> > the bars from y to z and so on.
> > If you need something more, let me know.
> > Dimitris Tsokakis
> >
> > --- In amibroker@xxxx, "IVA GmbH" <funnybiz@xxxx> wrote:
> > > Dimitris,
> > >
> > > thanks for taking the time.
> > >
> > > I understand what you said about z and y. As far as zz and yy
> > goes, they
> > > are giving me a specific low and or high value, right? And thus,
> > why is the
> > > time interval between them "meaningless" (what do you mean by
> THAT,
> > > please?). The reason to split the forumula in z and zz is just 
for
> > easier
> > > reading. I could have put everything in one formula as I did
> below.
> > >
> > > I basically tried to determine howe many bars (i.e. time 
interval)
> > would be
> > > in between thos two conditions. I thought of datenum function 
but
> > realized
> > > that I could not use them for computation like datenum(yy) -
> datenum
> > (zz) to
> > > determine the time interval (number of days).
> > >
> > > I assume that barssince is as well not an ideal solution since 
you
> > see for
> > > zz that I want to check when the condition was true for the 
FIRST
> > time. This
> > > is someting barssince doesnīt provide. It could for instance
> happen
> > that
> > > z/zz happened AFTER y/yy (looking from retrospective). In this
> case
> > I want
> > > those signals to be skipped since this case doesnīt apply to the
> > pattern I
> > > try to detect.
> > >
> > > I cut and pasted the code below and got and error message (need 
to
> > define a
> > > filter variable). What is the problem here? I went one step
> further
> > and put
> > > the conditions for z and zz together like
> > > z=ValueWhen((IIf(Low<Ref(LLV(Low,5), -1),1,0)==1),Low,1) but 
again
> > got the
> > > same error. I canīt see my mistake! Everything seems to be 
logic??
> > >
> > > What information would you need to judge how to go, Dimitris?
> > >
> > > Many thanks!!!!!
> > >
> > > Markus
> > >
> > > ----- Original Message -----
> > > From: "dtsokakis" <TSOKAKIS@xxxx>
> > > To: <amibroker@xxxx>
> > > Sent: Saturday, June 29, 2002 9:17 PM
> > > Subject: [amibroker] Re: Calculating bars between two arguments
> > >
> > >
> > > Hi Markus,
> > > There is something to be explained here:
> > > z and y are conditions, their value is 0 or 1.
> > > zz and yy are continuous functions with various values.
> > > Perhaps you need the time interval from z to y [or from y to z].
> It
> > > has some meaning, because z and y are events.
> > > The time interval between zz and yy is meaningless.
> > > Try the
> > > z=IIf(Low<Ref(LLV(Low,5), -1),1,0);
> > > zz=ValueWhen(z==1,Low,1);
> > > y=IIf (High>Ref(HHV(High,5), -1),1,0);
> > > yy=ValueWhen(y==1,High,1);
> > > Plot(z,"",1,2);Plot(y,"",4,2);
> > > Plot(zz,"",5,1);Plot(yy,"",7,1);
> > > to see what I mean.
> > > Can you be more specific ?
> > > DT
> > > --- 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
> > >
> > >
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/