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

Re: Anthony - Calculating bars between two arguments



PureBytes Links

Trading Reference Links

Your post showed me how to test on what one had previously programmed (I always tried to put together the whole thing in ONE piece only to find out thereafter that I had committed and error ;-o).

Attached you will find Dimitris reply to my problem and why IIF and then Valuethen is not really needed if not even detrimental to the working of the code!

Iīd still be interested in why you used Cum(1) in zz as you did:

x=Cum(1);

z=IIf(Low<Ref(LLV(Low,5), -1),1,0);
zz=ValueWhen(z,x);

Isnīt x the value that will be assigned to zz when z is true (for the first time) in our case? If so, zz will in my understanding be assigned the total number of bars (incidentally:since the beginning of trading that symbolor since the first bar LOADED in the chart??)?

You have helped me a great deal!

Markus


- - - - - - - - - - - - - - - - 
Markus,

When you are using the Explore function, you need the( Filter= )
statement.

As for Cum(1);
I believe Cum(1) returns: 1+1+1+1+1+1+1+1+1+1+1+1+1+.........etc.
starting from the first Bar or Day in the Ticker database.

Cum(2) doubles the output. ....etc. For example, try the explore below,
and change Cum(1) to Cum(2).
****************************************************
Load this into AA, select n last quotations and n=1, click explore.

Filter=1;
AddColumn(Cum(1),"Total number of bars in database",1);//Or Days
AddColumn(Cum(1)/256,"Years of Data");
****************************************************
The output should be the total number of bars in the tickers database,
and we relate BARS to DAYS ( TIME ).

Therefore with the following statement:
zz=ValueWhen(z,x,1);
My value for zz is the Bar( or Date ) that z was true and the same for
yy=,
so if z was true on Bar 2000 or Day2000 ( zz ) and y was true on bar
2500 or Day2500 ( yy ) then Bars between z and y would be
abs(zz(2000)-yy(2500))=500 bars or days.


I hope I have given a clear understanding, If not let me know.

Anthony

------=_NextPart_001_01FE_01C2234F.E9A6B380
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4913.1100" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Goooood lesson, Anthony.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Your post showed me how to test on what one had 
previously programmed (I always tried to put together the whole thing in ONE 
piece only to find out thereafter that I had committed and error 
;-o).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Attached you will find Dimitris reply to my problem 
and why IIF and then Valuethen is not really needed if not even detrimentalto 
the working of the code!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Iīd still be interested in why you used Cum(1) in 
zz as you did:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#ff0000>x=Cum(1);</FONT><BR><BR>z=IIf(Low&lt;Ref(LLV(Low,5), 
-1),1,0);<BR>zz=ValueWhen(z,x);<BR></DIV>
<DIV><FONT face=Arial size=2>Isnīt x the value that will be assigned to zz when 
z is true (for the first time) in our case? If so, zz will in my understanding 
be assigned the total number of bars (incidentally:since the beginning of 
trading that symbol or since the first bar LOADED in the chart??)?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>You have helped me a great deal!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Markus</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>- - - - - - - - - - - - - - - - </FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face="Times New Roman" 
size=3>Markus,<BR><BR>When you are using the Explore function, you need the( 
Filter= )<BR>statement.<BR><BR>As for Cum(1);<BR>I believe Cum(1) returns: 
1+1+1+1+1+1+1+1+1+1+1+1+1+.........etc.<BR>starting from the first Bar or Day in 
the Ticker database.<BR><BR>Cum(2) doubles the output. ....etc. For example, try 
the explore below,<BR>and change Cum(1) to 
Cum(2).<BR>****************************************************<BR>Load this 
into AA, select n last quotations and n=1, click 
explore.<BR><BR>Filter=1;<BR>AddColumn(Cum(1),"Total number of bars in 
database",1);//Or Days<BR>AddColumn(Cum(1)/256,"Years of 
Data");<BR>****************************************************<BR>The output 
should be the total number of bars in the tickers database,<BR>and we relate 
BARS to DAYS ( TIME ).<BR><BR>Therefore with the following 
statement:<BR>zz=ValueWhen(z,x,1);<BR>My value for zz is the Bar( or Date 
)&nbsp; that z was true and the same for<BR>yy=,<BR>so if z was true on Bar 2000 
or Day2000 ( zz ) and y was true on bar<BR>2500 or Day2500 ( yy ) then Bars 
between z and y would be<BR>abs(zz(2000)-yy(2500))=500 bars or 
days.<BR><BR><BR>I hope I have given a clear understanding, If not let me 
know.<BR><BR>Anthony</FONT><BR></FONT></DIV></BODY></HTML>

------=_NextPart_001_01FE_01C2234F.E9A6B380--

--- Begin Message ---
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Calculating bars between two arguments
From: "dtsokakis" <TSOKAKIS@xxxx>
Date: Sun, 30 Jun 2002 11:10:08 -0000
Delivered-to: mailing list amibroker@xxxxxxxxxxxxxxx
In-reply-to: <002401c21fb2$aa29c8a0$bacd8050@xxxx>
List-unsubscribe: <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx>
Mailing-list: list amibroker@xxxxxxxxxxxxxxx; contact amibroker-owner@xxxxxxxxxxxxxxx
Reply-to: amibroker@xxxxxxxxxxxxxxx
User-agent: eGroups-EW/0.82
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/ 



--- End Message ---