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

Re: [amibroker] for loop



PureBytes Links

Trading Reference Links




Hi, try this:
 
C[0] = 50;for(i = 1; i < BarCount; i++)  
C[i] = C[i-1] + C[i];
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=jcasavant@xxxxxxxxxxxx 
  href="">Jayson 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">1ami 
  Sent: Monday, April 28, 2003 4:12 
PM
  Subject: [amibroker] for loop
  
  Hi 
  Guys,
  <SPAN 
  class=966553613-28042003> 
  I am trying to 
  understand how to use the for loop. I try this....
  <SPAN 
  class=966553613-28042003> 
  <FONT 
  color=#000000>
  for( i = <FONT 
  color=#ff00ff>1; i < <FONT 
  color=#000000>BarCount<FONT 
  face=Arial size=2>; i++ )
  {
  
  <FONT 
  color=#000000>C[ i ] = <FONT 
  color=#000000>C<FONT 
  color=#282828>[ i-1 
  ]+C<FONT face=Arial 
  color=#282828 size=2>[i];
  }
  And I 
  think I get C=c+ref(c,-1); where I increment the close by adding yesterdays 
  close to todays and move forward doing so for each bar of the chart. Now if I 
  wanted to set the first bar to 50 I would think I could add an if statement 
  like this.....<SPAN 
  class=966553613-28042003>
  if (<FONT 
  color=#0000ff>Cum(<FONT 
  color=#ff00ff>1)==1<SPAN 
  class=966553613-28042003>)
  <FONT 
  color=#000000>C[ i ] = <FONT 
  color=#ff00ff>50<FONT face=Arial 
  size=2>;
  else<FONT 
  size=2>
  C[ i ] = 
  C[ i-<FONT 
  color=#ff00ff>1 ]+<FONT 
  color=#000000>C[i];
  but 
  this gives me an error telling me that if ,for,when requires a numeric or 
  Boolean statement. <FONT 
  face=Arial size=2> What I am trying to do is 
  set the first bar to 50 I then want the 2nd bar to be the first bar(50) + the 
  value of the second bar  then increment each bar forward by the previous 
  bar plus the current bar. I cannot seem to get my mind around 
  this.
  If any one can steer 
  me in the right direction I would appreciate 
  it<FONT face=Arial color=#0000ff 
  size=2>Jayson 
   






Yahoo! Groups Sponsor












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.