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

Re: [amibroker] Repetitive Statements with FOR (?)



PureBytes Links

Trading Reference Links




Hello,
 
Your code will plot single line.
 
I belive that Ken is after plotting MULTIPLE charts (but he 
did not describe his GOAL).
 
*IF* this is the case, Ken's problem can be solved this 
way:
 
 
for( i = 0; i < 19; i++ )
{
  color = <FONT 
face="Courier New">IIf<SPAN 
lang=en-us>(<SPAN 
lang=en-us>Ref<SPAN 
lang=en-us>(Tot,-i<FONT 
color=#000000>)<<FONT 
color=#ff00ff>3<FONT 
color=#000000>,<FONT 
color=#ff0000>colorRed<SPAN 
lang=en-us>,
<SPAN 
lang=en-us>          <SPAN 
lang=en-us>IIf<SPAN 
lang=en-us>(<SPAN 
lang=en-us>Ref<SPAN 
lang=en-us><FONT 
color=#000000>(Tot,-i<FONT 
color=#000000>)><FONT 
color=#ff00ff>3<FONT 
color=#000000><SPAN 
lang=en-us> AND<SPAN 
lang=en-us><FONT face="Courier New" color=#000000 
size=2> <FONT 
face="Courier New" color=#0000ff size=2>Ref<SPAN 
lang=en-us><FONT face="Courier New" color=#000000 
size=2>(Tot,-i <FONT face="Courier New" 
color=#000000 size=2><<SPAN 
lang=en-us>5<SPAN 
lang=en-us><FONT face="Courier New" color=#000000 
size=2>,<FONT 
face="Courier New" color=#ff0000 size=2>colorYellow<SPAN 
lang=en-us><FONT face="Courier New" color=#000000 
size=2>,<FONT 
face="Courier New" color=#ff0000 size=2>colorGreen<SPAN 
lang=en-us><FONT face="Courier New" color=#000000 
size=2>);
<FONT face="Courier New" 
size=2> 
 Plot( Ref( 
Tot, -i ), "Tot"+i, color );
<FONT face="Courier New" 
size=2>}
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  CS 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, November 11, 2003 10:19 
  AM
  Subject: Re: [amibroker] Repetitive 
  Statements with FOR (?)
  
  Ken,
   
  Something along the lines of...
   
  Tot=Cum<FONT 
  size=2>(1<FONT 
  size=2>) % 5 
  ;
  CLR=colorBlack<FONT 
  size=2>;
  for(i=<FONT 
  size=2>19;i<BarCount<FONT 
  size=2>;i++)
  {
       
  for(j=<FONT color=#800080 
  size=2>0;j<<FONT color=#800080 
  size=2>19;j++)
       {
       CLR[i] = <FONT color=#8b0000 
  size=2>IIf(Tot[i-j]<<FONT color=#800080 
  size=2>3,<FONT color=#ff0000 
  size=2>colorRed,<FONT color=#8b0000 
  size=2>IIf(Tot[i-j]><FONT color=#800080 
  size=2>3 <FONT color=#ff0000 
  size=2>AND Tot[i-j]<<FONT color=#800080 
  size=2>5,<FONT color=#ff0000 
  size=2>colorYellow,<FONT color=#ff0000 
  size=2>colorGreen));
       }
  }
  Plot<FONT face=Verdana 
  size=2>(C<FONT face=Verdana 
  size=2>,"test"<FONT face=Verdana 
  size=2>,CLR,128<FONT face=Verdana 
  size=2>);
  
  -CS 
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    Ken Close 

    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">AmiBroker List 
    Sent: Monday, November 10, 2003 7:33 
    PM
    Subject: [amibroker] Repetitive 
    Statements with FOR (?)
    
    As I venture 
    into the land of more "pure" programming constructs, I stumble.  Any 
    help?
    I have a 
    complex series of variables calculating values for today, yesterday, up to 
    Ref<FONT face="Courier New" 
    size=2>(<FONT face="Courier New" 
    size=2>xx,-20)
    Instead 
    of
    <FONT face="Courier New" color=#000000 
    size=2>A0 =<SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorRed<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot><SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2> 
    AND<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2> Tot<<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#ff00ff size=2>5<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorYellow<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorGreen<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>);
    <FONT face="Courier New" color=#000000 
    size=2>A1 =<SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>1<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorRed<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>1<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)><SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2> 
    AND<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2><SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>1<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>5<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorYellow<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorGreen<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>);
    <FONT face="Courier New" color=#000000 
    size=2>A2 =<SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>2<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorRed<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>2<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)><SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2> 
    AND<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2><SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>2<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>)<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>5<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorYellow<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorGreen<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>);
    <FONT face="Courier New" color=#000000 
    size=2>And repeat this 19 times,<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2> back 19 days;<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2><SPAN 
    lang=en-us> 
    <FONT face="Courier New" color=#000000 
    size=2>I wanted to try and use a For loop, and tried the following.  
    But I get all sorts of error messages, the most frequent of which 
    is 
    "Type Mismatch, number 
    expected but array found."
    <FONT face="Courier New" color=#800000 
    size=2>for<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(i=<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>0<SPAN 
    lang=en-us>; 
    i><SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>19<SPAN 
    lang=en-us>; 
    i++)
    <FONT face="Courier New" color=#000000 
    size=2>{
    <FONT face="Courier New" color=#000000 
    size=2>A[i]=<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-i)<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2><3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorRed<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>IIf<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(<SPAN 
    lang=en-us><FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-i)><SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>3<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2> 
    AND<SPAN 
    lang=en-us><FONT face="Courier New" 
    color=#000000 size=2><SPAN 
    lang=en-us> <FONT face="Courier New" color=#0000ff 
    size=2>Ref<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>(Tot,-i)<<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff00ff 
    size=2>5<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorYellow<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>,<SPAN 
    lang=en-us><FONT face="Courier New" color=#ff0000 
    size=2>colorGreen<SPAN 
    lang=en-us><FONT face="Courier New" color=#000000 
    size=2>);
    <FONT face="Courier New" color=#000000 
    size=2>}
    I tried 
    A+<FONT face="Courier New" 
    size=2>I and 
    that did not work either 
    <FONT face="Courier New" 
    size=2>"Error 
    3.
    Condition in 
    IF, WHILE, FOR statements
    has to be 
    Numeric or Boolean type.
    You can not 
    use array here,
    please use [] 
    (array subscript operator)
    to access 
    array elements<FONT face="Courier New" 
    size=2>"
    The "A"s are 
    arrays, so the A[i] seemed like the right way to go, but then the Type 
    Mismatch.
    I know the 
    answer is probably simple, but I can not see it.
    <FONT face="Courier New" 
    size=2>Help?
    <FONT face="Courier New" 
    size=2>KenSend 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.