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

RE: [amibroker] Can´t find the cum value!!!!!!!!!!!!



PureBytes Links

Trading Reference Links




<SPAN 
class=814511101-09032003>Markus,
 
<SPAN 
class=814511101-09032003>Firstswingtop (and bot) calculates a value. A value 
that occurs on every single bar.  What you need is binary, something 
that is either 0 or one, True or False. In other words something that does not 
return a value for every single bar on the chart. <FONT 
color=#0000ff face=Arial size=2>Add a plot to 
your code to see what I mean....

<FONT 
color=#0000ff> 
Plot(<FONT 
color=#000000>Close<FONT 
color=#282828>,""<FONT 
color=#282828>,<FONT 
color=#000000>colorGreen<FONT 
face=Arial>,<FONT 
color=#000000>styleCandle<FONT color=#282828 face=Arial 
size=2>);
Plot(firstswingtop,<FONT 
color=#ff00ff>"Swing",<FONT 
color=#ff00ff>5,<FONT 
color=#ff00ff>2);
 
finding the cum 
value is of no use to you on these variables.
<SPAN 
class=814511101-09032003><FONT 
color=#0000ff face=Arial size=2><SPAN 
class=814511101-09032003>Example;
<SPAN 
class=814511101-09032003> 
<SPAN 
class=814511101-09032003>x=c>ref(c,-1) and 
c>ref(c,-2);
This 
statement is either true or false. Valuewhen(x,cum(1),1)   will tell 
you on what bar X was true.
<SPAN 
class=814511101-09032003> 
x= 
c+1;
This 
is a value. Each bar will return a value of close plus 1.
<SPAN 
class=814511101-09032003> 
On 
your chart you have a red line connecting your swing highs and lows. you could, 
for example,  find the turning point of that line....
<SPAN 
class=814511101-09032003> 
x=your 
line
<SPAN 
class=814511101-09032003>swingtop=ref(x,-2)<ref(x,-1) And 
x<ref(x,-1);
<SPAN 
class=814511101-09032003> 
here 
we see the pivot point. So Valuewhen(swingtop,cum(1),1) would identify the first 
bar after the turn.
<SPAN 
class=814511101-09032003> 
<SPAN 
class=814511101-09032003>Firstlinechangeup may offer you some info but not with 
lastvalue attached. Plot it as you currently have it coded.
<SPAN 
class=814511101-09032003> 
<SPAN 
class=814511101-09032003>plot(firstlinechangup,4,2);
<SPAN 
class=814511101-09032003> 
You 
see a line on every bar that is the same value (the last value!!). Now remove 
the lastvalue part for the variable and plot again.

note 
the stair step effect. Now lets plot just the point where the stair 
changes.......
<SPAN 
class=814511101-09032003> 
<FONT 
face=Arial>
Plot(firstlinechangeup<FONT 
color=#282828>>Ref<FONT 
color=#282828>(firstlinechangeup,-1<FONT 
color=#282828>),<FONT 
color=#ff00ff>"Swing",<FONT 
color=#ff00ff>5,<FONT 
color=#ff00ff>2|<FONT 
color=#000000>styleOwnScale<FONT 
color=#282828>);
Now we have a value 
that is either 0 or 1. When it is one we have a bar. This bar can be checked for 
it's cum(1) value. The same is true for firstlinecharngedown....  This 
variable may not be what you want but the concept should take you in the right 
direction.
 
Jayson 
<FONT face=Tahoma 
size=2>-----Original Message-----From: funnybiz@xxxxxx 
[mailto:funnybiz@xxxxxx]Sent: Saturday, March 08, 2003 7:19 
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] 
Canīt find the cum value!!!!!!!!!!!!
Jayson,
 
I donīt want to get the cum values for z and y. 
They are cum values in themselves.
 
Plus, I donīt want the # of bars which make up the 
distance between z and y. Rather, I want the cum value (i.e. bar number) when 
the swing top, labeled firstswingtop, and the swing bottom, firstswingbottom, 
occur.
 
Take for instance the chart of Comp-I.
 
There, firstwingtop (NOTE I changed the swingsize 
to 18 for better visibility) has a value of 1,467.35 and 
the firstswingbottom has a value of 1,327.19. And itīs THEIR cum value that I 
want not the ones of firstlinechangedown and firstlinechangeup.
 
Firstlinechangeup and firstlinechangedown are some 
sort of "assisting variables" which I need to determine first since a swing top 
is located in between. 
 
Take for instance the firstswingtop: it is the 
highest high between firstlinechangeup and firstlinechangedown, provided that 
firstlinechangedown comes first (seen from the end of the chart). 
 
Firstswingbottom is the lowest low between 
firstlinechangeup and SECONDlinechangedown. As you can see, 
firstswingbottom happens AFTER firstswingtop (again seen from the end of the 
chart). So it must have a lower cum value than firstswingtop.
 
As you can see, the tops and the bottoms occur 
alternately. The fact that firstswingtop occurs before firstswingbottom has to 
do with the fact that I required in my filter that firstlinechangedown must 
occur before firstlinechangeup.
 
Had it required the other way around, then 
firstswingbottom had occured before firstswingtop.
 
Do you now see which cum values Iīm after? My 
cum values might differ from yours since the first day loaded in the chart 
is 11/02/84.
 
Please ask back if I havenīt made myself clear 
enough!
 
Incidentally, I copied a post from me and TJīs 
reply from a while ago regarding the lastvalue issue if youīre 
interested.
 
Appreciate your help
 
Markus
 
- - - - - - -

Markus,
 
I have pointed you and other people tens of times to 
<A 
href="">http://www.amibroker.com/newsletter/09-2001.html<A 
href="">
where in "Understanding AmiBroker Formula Language" 
article it is explained
that (almost) AFL all functions operate on arrays and 
return array.
Array always contains multiple values - one for every bar of 
your data.
ValueWhen function is NO exception here.
 
Otherwise it would not work at all. Consider 
this:
 
ValueWhen( DayOfWeek() == 5, Close );
 
If this would give you only ONE value it would not allow you 
to do anything useful,
but since it gives you array - it allows you to plot Weekly 
(Friday) close:
 
graph0 = ValueWhen( DayOfWeek() == 5, Close );
 
Best 
regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  IVA GmbH 
  To: <A 
  href="" 
  title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, November 26, 2002 12:02 
  PM
  Subject: Re: [amibroker] TJ, your kind 
  offer - Thanks!
  
  TJ,
   
  many thanks for getting back on this admittedly 
  "weird" piece of work>g>.
   
  Iīve found out why my code didnīt work and wanted 
  to share this with you and the rest of the bb members:
   
  I mistakenly supposed that 
  Valuewhen(cond1,cum(),1) would give me a single output (though this would 
  seem logical) which I could then continue to use.
   
  As you know, I used the output above to compare 
  it with the cum() value of another condition to determine which one happened 
  first or thereafter by using:
   
  Valuewhen(cond2 and 
  cum<Valuewhen(cond1,cum(),1) ,cum(),1)
   
  This gave me no output (column in Exploration 
  remained blank)! Just when I used
   
  Valuewhen(cond2 and  cum<<FONT 
  color=#ff0000>LASTVALUE(Valuewhen(cond1,cum(),1))
   
  I could use it further.
   
  I donīt understand it, īcause Valuewhen(...) 
  gives you a single output to which AFL "should"<g> be able to compare 
  further conditions.
   
  Just wanted to bring this to your attention - 
  itīs cost me weeks to find this out by coincidence!
   
  But Iīve enjoyed all your kind contributions and 
  assisting comments and continue to learn from the helping hands of this 
  forum!
   
  Have a great day!
   
  Markus
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A href="" 
  title=jcasavant@xxxxxxxxxxxx>Jayson 
  To: <A 
  href="" 
  title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
  Sent: Saturday, March 08, 2003 9:55 
  PM
  Subject: RE: [amibroker] Canīt find the 
  cum value!!!!!!!!!!!!
  
  <SPAN 
  class=496454320-08032003>Markus,
  I am 
  not sure I understand. If you want the cum(1) value when a variable was True 
  then your first example should do it.
  <SPAN 
  class=496454320-08032003> 
  <FONT 
  size=2>Example: <FONT 
  size=2>
  AddColumn(<FONT 
  color=#0000ff>ValueWhen(z,<FONT 
  color=#0000ff>Cum(<FONT 
  color=#ff00ff>1),<FONT 
  color=#ff00ff>1)<FONT 
  color=#282828>,"barcount At Z"<FONT 
  color=#282828>);<FONT 
  color=#0000ff>
  AddColumn(<FONT 
  color=#0000ff>ValueWhen(y,<FONT 
  color=#0000ff>Cum(<FONT 
  color=#ff00ff>1),<FONT 
  color=#ff00ff>1),<FONT 
  color=#ff00ff>"barcount at Y");<FONT 
  color=#0000ff>
  AddColumn(<FONT 
  color=#0000ff>ValueWhen(<FONT 
  color=#282828>z,<FONT 
  color=#0000ff>Cum(<FONT 
  color=#ff00ff>1),<FONT 
  color=#ff00ff>1)<FONT 
  color=#282828>-ValueWhen<FONT 
  color=#282828>(y<FONT 
  color=#282828>,Cum<FONT 
  color=#282828>(1<FONT 
  color=#282828>),1<FONT 
  color=#282828>),"Bars in Swing"<FONT 
  color=#282828>);
   
  I 
  may be wrong but I wonder why you are using lastvalue for firstlinechangeup 
  and down. Would'nt you want simply the bar count as it 
  occurs?
   
  Jayson 
  <FONT face=Tahoma 
  size=2>-----Original Message-----From: funnybiz@xxxxxx 
  [mailto:funnybiz@xxxxxx]Sent: Saturday, March 08, 2003 1:14 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] 
  Canīt find the cum value!!!!!!!!!!!!
  Jayson, Anthony and others,
   
  I recently posted a question that I couldnīt find 
  a cum value for a high (or low) value I found with my code 
  (attached).
   
  This question is posing a problem I canīt resolve 
  on my own.
   
  If anybody has an idea, please feel free to step 
  in!
   
  The code comes below. It pinpoints the high ad 
  low values correctly. I now need their cum values.
   
  I tried for instance 
   
  Valuewhen(high=firstswingtop, 
  cum(1),1)   or
   
  Iif (cum(1)>firstlinechangeup and 
  cum(1)<firstlinechangedown and 
  high=hhv(high,firstlinechangeup-firstlinechangedown),cum(1),0)
   
  but neither works.
   
  Thanks for your help!
   
  Markus
   
  - - - - - - - - - 
   
  
  swingsize=5<FONT 
  color=#6600aa face="Courier New">;// could be any value of your choice
  weeklyrange=(Ref<FONT 
  color=#6600aa face="Courier New">(<FONT color=#0000ff 
  face="Courier New">HHV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">High<FONT color=#6600aa 
  face="Courier New">,swingsize),-<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">)-<FONT color=#0000ff 
  face="Courier New">Ref<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">LLV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">Low<FONT color=#6600aa 
  face="Courier New">,swingsize),-<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">))*<FONT color=#ff00ff 
  face="Courier New">0.1;
  Thresholddown=Ref<FONT 
  color=#6600aa face="Courier New">(<FONT color=#0000ff 
  face="Courier New">LLV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">Low<FONT color=#6600aa 
  face="Courier New">,swingsize),-<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">)-weeklyrange;
  Thresholdup=Ref<FONT 
  color=#6600aa face="Courier New">(<FONT color=#0000ff 
  face="Courier New">HHV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">High<FONT color=#6600aa 
  face="Courier New">,swingsize),-<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">)+weeklyrange;
  Linechangeup=<FONT color=#000000 
  face="Courier New">High<FONT color=#6600aa 
  face="Courier New">>Thresholdup;
  Linechangedown=<FONT color=#000000 
  face="Courier New">Low<FONT color=#6600aa 
  face="Courier New"><thresholddown;
  z=Linechangedown;
  y=linechangeup;
  firstlinechangedown=<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">ValueWhen<FONT color=#6600aa 
  face="Courier New">(z,<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),<FONT color=#ff00ff 
  face="Courier New">1));
  firstlinechangeup=<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">ValueWhen<FONT color=#6600aa 
  face="Courier New">(y,<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),<FONT color=#ff00ff 
  face="Courier New">1));
  firstswingtop=Ref<FONT 
  color=#6600aa face="Courier New">(<FONT color=#0000ff 
  face="Courier New">HHV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">High<FONT color=#6600aa 
  face="Courier New">,(firstlinechangedown-firstlinechangeup)+<FONT 
  color=#ff00ff face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),-(<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">))-firstlinechangedown));
  secondlinechangedown=<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">ValueWhen(z 
  AND<FONT 
  color=#6600aa face="Courier New"> <FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">)<<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(firstlinechangeup),<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),<FONT color=#ff00ff 
  face="Courier New">1));
  secondlinechangeup=<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">ValueWhen(y 
  AND<FONT 
  color=#6600aa face="Courier New"> <FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">)<<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(secondlinechangedown),<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),<FONT color=#ff00ff 
  face="Courier New">1));
  firstswingbottom=<FONT color=#0000ff 
  face="Courier New">Ref<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">LLV<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">Low<FONT color=#6600aa 
  face="Courier New">,(firstlinechangeup-secondlinechangedown)+<FONT 
  color=#ff00ff face="Courier New">1<FONT color=#6600aa 
  face="Courier New">),-(<FONT color=#0000ff 
  face="Courier New">LastValue<FONT color=#6600aa 
  face="Courier New">(<FONT color=#0000ff 
  face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1<FONT color=#6600aa 
  face="Courier New">))-firstlinechangeup));<FONT color=#6600aa 
  face="Courier New">
  Filter<FONT color=#6600aa 
  face="Courier New">=firstlinechangedown>firstlinechangeup <FONT 
  color=#000000 face="Courier New">AND<FONT color=#6600aa 
  face="Courier New"> <FONT color=#0000ff 
  face="Courier New">MA<FONT color=#6600aa 
  face="Courier New">(<FONT color=#000000 
  face="Courier New">Volume<FONT color=#6600aa 
  face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">50<FONT color=#6600aa 
  face="Courier New">)>=<FONT color=#ff00ff 
  face="Courier New">20000<FONT color=#6600aa 
  face="Courier New">;<FONT 
  color=#0000ff face="Courier New">
  AddColumn(<FONT 
  color=#0000ff face="Courier New">Cum<FONT color=#6600aa 
  face="Courier New">(<FONT color=#ff00ff 
  face="Courier New">1), 
  "total bars"<FONT 
  color=#6600aa face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">1.0<FONT color=#6600aa 
  face="Courier New">);
  AddColumn<FONT color=#6600aa 
  face="Courier New">(firstswingtop,<FONT color=#ff00ff 
  face="Courier New">"1. swing top"<FONT color=#6600aa 
  face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">1.2<FONT color=#6600aa 
  face="Courier New">);
  AddColumn<FONT color=#6600aa 
  face="Courier New">(firstlinechangeup,<FONT color=#ff00ff 
  face="Courier New">"1dlcup"<FONT color=#6600aa 
  face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">1.1<FONT color=#6600aa 
  face="Courier New">);
  AddColumn<FONT color=#6600aa 
  face="Courier New">(firstlinechangedown,<FONT color=#ff00ff 
  face="Courier New">"1dlcdown"<FONT color=#6600aa 
  face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">1.1<FONT color=#6600aa 
  face="Courier New">);
  AddColumn<FONT color=#6600aa 
  face="Courier New">(firstswingbottom,<FONT color=#ff00ff 
  face="Courier New">"1. swing bottom"<FONT color=#6600aa 
  face="Courier New">,<FONT color=#ff00ff 
  face="Courier New">1.2<FONT color=#6600aa 
  face="Courier New">);Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 
  Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 
Send 
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
suggest@xxxxxxxxxxxxx-----------------------------------------Post 
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.