[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




Hello Jayson,
 
you gave me good portion of homework for a 
sunday>G.
 
Please allow some time for a full understanding of 
what you wrote.
 
I sincerely wanted to thank you in the 
meantime.
 
I fell I still make MANY basic mistakes using 
AFL language and thus nearly everything in my code is screwed up, 
right?>GG<.
 
TTYL
 
Markus
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=jcasavant@xxxxxxxxxxxx 
  href="">Jayson 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, March 09, 2003 6:20 
AM
  Subject: RE: [amibroker] Canīt find the 
  cum value!!!!!!!!!!!!
  
  <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 
  face=Arial color=#0000ff size=2>Add a plot to 
  your code to see what I mean....
  
  <FONT 
  color=#0000ff> 
  Plot(<FONT 
  color=#000000>Close<FONT 
  face=Arial>,""<FONT 
  color=#282828>,<FONT 
  color=#000000>colorGreen<FONT 
  face=Arial>,<FONT 
  color=#000000>styleCandle<FONT face=Arial 
  color=#282828 size=2>);<FONT 
  face=Arial>
  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 
  face=Arial color=#0000ff 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> 
  <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 title=amibroker@xxxxxxxxxxxxxxx 
    href="">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 title=jcasavant@xxxxxxxxxxxx 
    href="">Jayson 
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Sent: Saturday, March 08, 2003 9:55 
    PM
    Subject: RE: [amibroker] Canīt find the 
    cum value!!!!!!!!!!!!
    <FONT face=Arial 
size=2>
    <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 
    face=Arial>Example: <FONT 
    color=#0000ff>
    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 
    face="Courier New" color=#6600aa>;// could be any value of your choice
    weeklyrange=(<FONT face="Courier New" 
    color=#0000ff>Ref(<FONT 
    face="Courier New" color=#0000ff>HHV<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#000000>High<FONT face="Courier New" 
    color=#6600aa>,swingsize),-<FONT face="Courier New" 
    color=#ff00ff>1)-<FONT 
    face="Courier New" color=#0000ff>Ref<FONT face="Courier New" 
    color=#6600aa>(LLV<FONT 
    face="Courier New" color=#6600aa>(<FONT face="Courier New" 
    color=#000000>Low<FONT face="Courier New" 
    color=#6600aa>,swingsize),-<FONT face="Courier New" 
    color=#ff00ff>1))*<FONT 
    face="Courier New" color=#ff00ff>0.1<FONT face="Courier New" 
    color=#6600aa>;
    Thresholddown=<FONT face="Courier New" 
    color=#0000ff>Ref(<FONT 
    face="Courier New" color=#0000ff>LLV<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#000000>Low<FONT face="Courier New" 
    color=#6600aa>,swingsize),-<FONT face="Courier New" 
    color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>)-weeklyrange;
    Thresholdup=Ref<FONT 
    face="Courier New" color=#6600aa>(<FONT face="Courier New" 
    color=#0000ff>HHV<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#000000>High<FONT face="Courier New" 
    color=#6600aa>,swingsize),-<FONT face="Courier New" 
    color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>)+weeklyrange;
    Linechangeup=<FONT face="Courier New" 
    color=#000000>High<FONT face="Courier New" 
    color=#6600aa>>Thresholdup;
    Linechangedown=<FONT face="Courier New" 
    color=#000000>Low<FONT face="Courier New" 
    color=#6600aa><thresholddown;
    z=Linechangedown;
    y=linechangeup;
    firstlinechangedown=<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#0000ff>ValueWhen<FONT face="Courier New" 
    color=#6600aa>(z,<FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),1<FONT 
    face="Courier New" color=#6600aa>));
    firstlinechangeup=<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#0000ff>ValueWhen<FONT face="Courier New" 
    color=#6600aa>(y,<FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),1<FONT 
    face="Courier New" color=#6600aa>));
    firstswingtop=<FONT face="Courier New" 
    color=#0000ff>Ref(<FONT 
    face="Courier New" color=#0000ff>HHV<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#000000>High<FONT face="Courier New" 
    color=#6600aa>,(firstlinechangedown-firstlinechangeup)+<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),-(<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(Cum<FONT 
    face="Courier New" color=#6600aa>(<FONT face="Courier New" 
    color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>))-firstlinechangedown));
    secondlinechangedown=<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#0000ff>ValueWhen(z 
    AND<FONT 
    face="Courier New" color=#6600aa> <FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>)<<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(firstlinechangeup),<FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),1<FONT 
    face="Courier New" color=#6600aa>));
    secondlinechangeup=<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#0000ff>ValueWhen(y 
    AND<FONT 
    face="Courier New" color=#6600aa> <FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>)<<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(secondlinechangedown),<FONT face="Courier New" 
    color=#0000ff>Cum(<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),1<FONT 
    face="Courier New" color=#6600aa>));
    firstswingbottom=<FONT face="Courier New" 
    color=#0000ff>Ref(<FONT 
    face="Courier New" color=#0000ff>LLV<FONT face="Courier New" 
    color=#6600aa>(<FONT face="Courier New" 
    color=#000000>Low<FONT face="Courier New" 
    color=#6600aa>,(firstlinechangeup-secondlinechangedown)+<FONT 
    face="Courier New" color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>),-(<FONT face="Courier New" 
    color=#0000ff>LastValue<FONT face="Courier New" 
    color=#6600aa>(Cum<FONT 
    face="Courier New" color=#6600aa>(<FONT face="Courier New" 
    color=#ff00ff>1<FONT face="Courier New" 
    color=#6600aa>))-firstlinechangeup));<FONT face="Courier New" 
    color=#6600aa>
    Filter<FONT face="Courier New" 
    color=#6600aa>=firstlinechangedown>firstlinechangeup <FONT 
    face="Courier New" color=#000000>AND<FONT face="Courier New" 
    color=#6600aa> MA<FONT 
    face="Courier New" color=#6600aa>(<FONT face="Courier New" 
    color=#000000>Volume<FONT face="Courier New" 
    color=#6600aa>,50<FONT 
    face="Courier New" color=#6600aa>)>=<FONT face="Courier New" 
    color=#ff00ff>20000<FONT face="Courier New" 
    color=#6600aa>;<FONT 
    face="Courier New" color=#0000ff>
    AddColumn(<FONT 
    face="Courier New" color=#0000ff>Cum<FONT face="Courier New" 
    color=#6600aa>(1<FONT 
    face="Courier New" color=#6600aa>), <FONT face="Courier New" 
    color=#ff00ff>"total bars"<FONT face="Courier New" 
    color=#6600aa>,1.0<FONT 
    face="Courier New" color=#6600aa>);<FONT face="Courier New" 
    color=#0000ff>
    AddColumn<FONT face="Courier New" 
    color=#6600aa>(firstswingtop,<FONT face="Courier New" 
    color=#ff00ff>"1. swing top"<FONT face="Courier New" 
    color=#6600aa>,1.2<FONT 
    face="Courier New" color=#6600aa>);<FONT face="Courier New" 
    color=#0000ff>
    AddColumn<FONT face="Courier New" 
    color=#6600aa>(firstlinechangeup,<FONT face="Courier New" 
    color=#ff00ff>"1dlcup"<FONT face="Courier New" 
    color=#6600aa>,1.1<FONT 
    face="Courier New" color=#6600aa>);<FONT face="Courier New" 
    color=#0000ff>
    AddColumn<FONT face="Courier New" 
    color=#6600aa>(firstlinechangedown,<FONT face="Courier New" 
    color=#ff00ff>"1dlcdown"<FONT face="Courier New" 
    color=#6600aa>,1.1<FONT 
    face="Courier New" color=#6600aa>);<FONT face="Courier New" 
    color=#0000ff>
    AddColumn<FONT face="Courier New" 
    color=#6600aa>(firstswingbottom,<FONT face="Courier New" 
    color=#ff00ff>"1. swing bottom"<FONT face="Courier New" 
    color=#6600aa>,1.2<FONT 
    face="Courier New" 
    color=#6600aa>);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. 
  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.