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

[amibroker] Re: Help with referencing previous prices



PureBytes Links

Trading Reference Links




Gary,
 
The credit goes to Johan, I would not have thought 
to do this in this manner.  I was stumped. 
 
Glen 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Gary 
  A. Serkhoshian 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, March 21, 2004 8:29 
PM
  Subject: Re: [amibroker] Re: Help with 
  referencing previous prices
  
  
  Glen,
   
  I just read through all the posts on this thread, and I'm not exactly 
  sure what you are after but from my impressions your solution is 
  straightforward.
   
  First, an explaination of the Error 3.  IF, For, While only allow 
  for numbers NOT arrays.  So, you can NOT do this:
   
  If (C > 5)
  {
       blah;
  }
   
  That is why you are getting an Error 3. You could, however, use the 
  LastValue function to convert an array to a number.  The problem is it 
  only returns the last value of the calculation.  
   
  You can do this:
   
  x = 1;
   
  If (x)
  {
      blahblah;
  }
   
  Tomasz has created this IIF function for these situations.
   
  IIF(Sum(C > Ref(C, -1), 3) == 3, 1, -1);
   
  Hope this helps as I'm not sure if you are trying to gate your code with 
  the condition (which IF will do barring the restriction to a number not an 
  array) or are just trying to generate some numbers from the results of 
  the condition (which IIF provides).
   
  Kind Regards,
  Gary
  Glen Haponek <ghaponek@xxxxxxx> wrote:
  <BLOCKQUOTE class=replbq 
  >
    
    

    Johan,
     
    So you are defining the relationship between 
    the three bars as a mathematical function of the element subscript, and the 
    condition is identified as true when the numeric value of y equals 3 ? 
    
     
    The first iteration through this is :  x = 
    C [ i - k ]  >C [ i -k -1 ];
                                                     
    x = C [ 3 - 0 ] > C [ 3 - 0 -1];
    <FONT face=Arial 
    size=2>                                                   
    = C [ 3 ] > C [ 2 ]; 
    <FONT face=Arial 
    size=2>                                                y 
    = 0 + 1 = 1
     
    The second 
    :                              
    x = C [ 4 - 1] > C [ 4 - 1 - 1]
    <FONT face=Arial 
    size=2>                                                   = 
    C [ 3 ] > C [ 2 ];
    <FONT face=Arial 
    size=2>                                                 
    y = y + x = 1 + 1 = 2
     
    The 
    third:                                  
    x = C [5 -2] > C [ 5 - 2 - 1] ;
    <FONT face=Arial 
    size=2>                                                  
    = C [ 3 ] > C [ 2] ;
    <FONT face=Arial 
    size=2>                                                 
    y = y + x = 2 + 1 = 3
     
    and Cond [ i ] or Cond [ 3 ] == 3, and is 
    true, except that it looks like only C [ 3 ] > C [ 2 ] has been 
    tested.
     
    Is this what you have performed here?  
    
     
    I initially described the relationship as 
    :  C [ 3 ] > C [ 2 ] and  C [ 2 ] > C [1 ] 
    and C [ 1 ] > C [ 0 ] , which isn't exactly what I think you have 
    done, but the specific price relationship wasn't the point of my 
    question.  Thank you for your insight in this.  
     
    If I my interpretation is correct, 
    what would be changed to perform the above? 
     
    Might this work?
     
    for ( i=3; i<BarCount ; i++){k = 0 
    ;y = 0 ;
    m = 0 ;
    while( k <= 2 
    ){x=C[i-k-m]>C[i-k-n-1];y=y+x;k++;
    m = m++;
    Cond[i]=y==3;}}
    First iteration :  x  = C 
    [i-k-m]>C[i-k-m-1];
    <FONT face=Arial 
    size=2>                          = 
    C [3-0-0] > C [3 -0 -0 -1]
    <FONT face=Arial 
    size=2>                          
    = C [ 3 ] > C [ 2 ]
     
    Second 
    :         x = C [i-k-m] > 
    C[i-k-n];
    <FONT face=Arial 
    size=2>                        = 
    C [4 -1 -1] > C [ 4 - 1 - 1 -1]
    <FONT face=Arial 
    size=2>                        
    = C [ 2 ] > C [ 1 ]
     
    Third 
    :            x = C 
    [i-k-m] > C[i-k-n];
    <FONT face=Arial 
    size=2>                       = 
    C [ 5 -2 -2] > C [ 5 - 2 -2 -1]
    <FONT face=Arial 
    size=2>                       
    = C [ 1 ] > C [ 0 ]
     
    If the initial relationship were : C [ 3 ] 
    > C [ 2 ]  and C [ 2 ] > C [ 1 ] and C [ 1 ] 
    < C [ 0 ] 
     
    How would this be addressed?  Wouldn't the 
    algorithm have to be split into 2 parts?
     
    Glen<FONT face=Arial 
    size=2>           
    
    <FONT 
    size=2>                      
    
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      johsun 
      
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">amibroker@xxxxxxxxxxxxxxx 
      
      Sent: Sunday, March 21, 2004 2:34 
      PM
      Subject: [amibroker] Re: Help with 
      referencing previous prices
      OK, guess I didn't read your message properly.Does 
      this help you in any 
      way:for(i=3;i<BarCount;i++){k=0;y=0;while(k<=2){x=C[i-k]>C[i-k-1];y=y+x;k++;Cond[i]=y==3;}}Plot(C,"",colorBlack,styleCandle);Plot(Cond,"",colorBlue,styleHistogram|styleOwnScale);JohanSend 
      BUG REPORTS to <A 
      href="">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 
      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 
      
  Do you Yahoo!?<A 
  href="">Yahoo! Finance Tax Center 
  - File online. File on time. 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 
  


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








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.