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

Re: [amibroker] If Statement Problem



PureBytes Links

Trading Reference Links




Udo,
 
Arrays are NOT automatically filled with zero. The code I 
provided below assumed
that ltest array is filled BEFORE and only few array items 
should be changed leaving
previous values unchanged in remaining items.
 
As for initialization: you can initialize with any value using 
simple assignment:
 

ltest = 7; // will cause that all array items will have the 
value of 7 
for (i = <FONT face="Courier New" 
color=#ff00ff size=1>1; i < 
BarCount<FONT 
face="Courier New" size=1>; i++)
    
if (<FONT 
face="Courier New" color=#ff6820 size=1>high<FONT face="Courier New" 
size=1>[i] > <FONT face="Courier New" color=#ff6820 
size=1>high[i - <FONT 
face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
size=1>])
        ltest[i] = <FONT 
face="Courier New" color=#ff00ff size=1>3<FONT face="Courier New" 
size=1>; // change the value to 3 for selected items
<FONT face="Courier New" 
color=#ff6820 size=1>filter = 
1<FONT 
face="Courier New" size=1>;<FONT face="Courier New" color=#800080 
size=1>
AddColumn(ltest, <FONT 
face="Courier New" color=#0000ff size=1>"ltest"<FONT face="Courier New" 
size=1>);
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=Udo.Harke@xxxxxxxxxxx 
  href="">Udo.Harke@xxxxxxxxxxx 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, May 26, 2003 6:28 PM
  Subject: [amibroker] If Statement 
  Problem
  
  Tomasz,
   
  in C/C++ you would have to 
  initialize the array ltest[] by using an 
  additional else statement such as
  
  for (i = <FONT 
  face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
  size=1>; i < <FONT face="Courier New" color=#ff6820 
  size=1>BarCount; i++)
      
  if (<FONT 
  face="Courier New" color=#ff6820 size=1>high<FONT 
  face="Courier New" size=1>[i] > <FONT face="Courier New" 
  color=#ff6820 size=1>high[i - 
  1<FONT 
  face="Courier New" size=1>])
          ltest[i] = <FONT 
  face="Courier New" color=#ff00ff size=1>3<FONT face="Courier New" 
  size=1>;
      
  else
          ltest[i] = <FONT 
  face="Courier New" color=#ff00ff size=1>0<FONT face="Courier New" 
  size=1>;
  filter = <FONT 
  face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
  size=1>;
  AddColumn(ltest, <FONT 
  face="Courier New" color=#0000ff size=1>"ltest"<FONT face="Courier New" 
  size=1>);
  Question: when omitting 
  the else statement, does AmiBroker always initialize the array ltest[] 
  automatically to a numeric value of 0?
   
  Best regards,
   
  Udo
   
  -----Ursprüngliche Nachricht----- 
  <BLOCKQUOTE 
  >
    <DIV 
    >Von: 
    Tomasz Janeczko 
    
    An: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Gesendet: Sonntag, den 25. Mai 2003 
    22:44 Uhr
    Betreff: Re: [amibroker] If Statement 
    Problem
    
    Hello,
     
    Because if order flow control requires 
    SINGLE value to decide whenever
    take this path or not.
    You supply the array instead.
    Please read Tutorial: Understanding how AFL works section 
    of the User's Guide.
     
    Write
     
    ltest = IIF( H > Ref(H, -1 ), 3, 0 );
     
    or write:
     
    for( i = 1;  i < BarCount; i++ )
    {
     if( H[i] > H[ i - 1 ] ) <FONT 
    color=#0000ff>ltest[ i ] 
= 3; 
    } // No else statement 
    required?
     
    Best regards,Tomasz Janeczkoamibroker.com
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      <A title=stewart@xxxxxxxxxxxxxxxx 
      href="">Stewart 
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">amibroker@xxxxxxxxxxxxxxx 
      
      Sent: Sunday, May 25, 2003 11:32 
      PM
      Subject: [amibroker] If Statement 
      Problem
      
      Can anyone tell me why this doesn't 
      work?
       
      if (H>Ref(H,-1))
      
      {
      ltest = 3;
      }
      thanks,
      StewartSend BUG 
      REPORTS to <A 
      href="">bugs@xxxxxxxxxxxxxSend 
      SUGGESTIONS to <A 
      href="">suggest@xxxxxxxxxxxxx-----------------------------------------Post 
      AmiQuote-related messages ONLY to: <A 
      href="">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












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.