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

RE: [amibroker] Re: Upgrading to realtime



PureBytes Links

Trading Reference Links

Glen,

for what it's worth I think my code does what you described.
The while part loops three times for each value of i so three 
comparisons will be done. 
First iteration:
x = C [ i - k ]  >C [ i -k -1 ];

i equals 3 and k goes from 0 to 2:

x = C [ 3 - 0 ]  >C [ 3 -0 -1 ];
x = C [ 3 - 1 ]  >C [ 3 -1 -1 ];
x = C [ 3 - 2 ]  >C [ 3 -2 -1 ]; 

Johan 


--- In amibroker@xxxxxxxxxxxxxxx, "Glen Haponek" <ghaponek@xxxx> 
wrote:
> 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];
>                                                    = C [ 3 ] > C [ 
2 ]; 
>                                                 y = 0 + 1 = 1
> 
> The second :                              x = C [ 4 - 1] > C [ 4 - 
1 - 1]
>                                                    = C [ 3 ] > C [ 
2 ];
>                                                  y = y + x = 1 + 1 
= 2
> 
> The third:                                  x = C [5 -2] > C [ 5 - 
2 - 1] ;
>                                                   = C [ 3 ] > C [ 
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];
>                           = C [3-0-0] > C [3 -0 -0 -1]
>                           = C [ 3 ] > C [ 2 ]
> 
> Second :         x = C [i-k-m] > C[i-k-n];
>                         = C [4 -1 -1] > C [ 4 - 1 - 1 -1]
>                         = C [ 2 ] > C [ 1 ]
> 
> Third :            x = C [i-k-m] > C[i-k-n];
>                        = C [ 5 -2 -2] > C [ 5 - 2 -2 -1]
>                        = 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           
>                       
>   ----- Original Message ----- 
>   From: johsun 
>   To: 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);
> 
>   Johan
> 
> 
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   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
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/amibroker/
>       
>     b.. To unsubscribe from this group, send an email to:
>     amibroker-unsubscribe@xxxxxxxxxxxxxxx
>       
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.



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:
     http://docs.yahoo.com/info/terms/