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

[amibroker] Re: AFL drives me nuts



PureBytes Links

Trading Reference Links

I took the (personal) challenge to rewrite the loop in your Digger 
code using AFL arrays, since they tend to be much more condensed and 
faster than explicit loops.  

I think I did this translation correctly, but I get a very different 
result, which makes me suspect there is something I am missing about 
how explicit loops are implemented, or how array calculations are 
implemented.   I really need to understand this, so someone please 
explain.  Thanks.

Oh, there was one possibly inconsistent expression concerning how 
the "Lower" condition is computed, but although it makes no 
difference in the explicit loop, it makes a huge difference in the 
array calcs.

Here it is:

Result1 = 0;
Result2 = 0;
Result3 = 0;

High1 = High;
High2 = Ref(High, -1);
Low1 = Low;
Low2 = Ref(Low, -1);

Higher = High1 > High2 AND Low1 >= Low2;

// The following seems more consistent with the Higher calculation.
//Lower = Low1 < Low2   AND High1 <= High2;

// The following seems consistent with the logic in the loop.
Lower = (Low1 < Low2[0] AND High1 < High2) OR 
	(Low1 < Low2    AND High1 == High2);

Result1 = Ref(Result1, -1) +
	Iif( Higher, Iif( Close > Open, 1.5, 1),
	 Iif( Lower, Iif( Close < Open, -1.5, 1),  0));

Result2 = Ref(Result2, -1) + 
	Iif( Higher, 1, 
	 Iif ( Lower, -1,  0 ));

Result3 = Result1 - Result2;


      Plot( result1, "Digger 1", colorGreen, 1);
      Plot( result2, "Digger 2", colorBlue, 1);
      Plot( result3, "Digger 3", colorRed, 1);


--- In amibroker@xxxxxxxxxxxxxxx, Rush <rushingitagain@xxx> wrote:
>
> Digger was just an idea I had yesterday for an indicator that would 
show
> OB/OS. I ended up with this:
> 
>  
> 
> result1 = 0;
> 
>        result2 = 0;
> 
>        result3 = 0;
> 
>  
> 
>        for ( i = 1; i < BarCount; i++ ){
> 
>               High1 = High[i];
> 
>               High2 = High[i-1];
> 
>               Low1 = Low[i];
> 
>               Low2 = Low[i-1];
> 
>  
> 
>               if((High1 > High2 AND Low1 > Low2) OR (High1 > High2 
AND Low1
> == Low2)){
> 
>                      if(Close[i]>Open[i]){
> 
>                             result1[ i ] = result1[i - 1] + 1.5;
> 
>                      }else{
> 
>                            result1[ i ] = result1[i - 1] + 1;
> 
>                      }
> 
>                      result2[ i ] = result2[i - 1] + 1;
> 
>                      result3[ i ] = result1[ i ] - result2[ i ];
> 
>               }else if((Low1 < Low2[0] AND High1 < High2) OR (Low1 
< Low2
> AND High1 == High2)){
> 
>                      if(Close[i]<Open[i]){
> 
>                            result1[ i ] = result1[i - 1] - 1.5;
> 
>                      }else{
> 
>                            result1[ i ] = result1[i - 1] - 1;
> 
>                      }
> 
>                      result2[ i ] = result2[i - 1] - 1;
> 
>                      result3[ i ] = result1[ i ] - result2[ i ];
> 
>               }else{
> 
>                      result1[ i ] = result1[ i - 1];
> 
>                      result2[ i ] = result2[ i - 1];
> 
>                      result3[ i ] = result1[ i ] - result2[ i ];
> 
>               }
> 
>        }
> 
>  
> 
>        Plot( result1, "Digger 1", colorGreen, 1);
> 
>        Plot( result2, "Digger 2", colorBlue, 1);
> 
>        Plot( result3, "Digger 3", colorRed, 1);
> 
>  
> 
>  
> 
>  
> 
>  
> 
>   _____  
> 
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 
On Behalf
> Of Joe Landry
> Sent: 05 April 2006 15:54
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] AFL drives me nuts
> 
>  
> 
> Yup, i goes from 1 to 3593 on my system with the issue I had 
selected.  
> 
> //////////////////////////////////////////////////
> 
> result = 0; Null;
> 
> for ( i = 1; i < BarCount; i++ )
> 
> {
> 
> _TRACE("count" + i); 
> 
> ////////////////////////////////////////////////////////////
> 
> What's the significance of Digger?  I can see
> 
> it might measure thrust but it seems to track my price array of the 
issue
> under test.  Are there significant
> 
> levels that are triggers?
> 
> Best regards
> 
> Joe 
> 
> ----- Original Message ----- 
> 
> From: Joe Landry <mailto:jelandry@...>  
> 
> To: amibroker@xxxxxxxxxxxxxxx 
> 
> Sent: Wednesday, April 05, 2006 8:40 AM
> 
> Subject: Re: [amibroker] AFL drives me nuts
> 
>  
> 
> You'll need to down load a tool called Debugview and have it 
running while
> you execute your AFL with
> 
> _TRACE statement interlaced over your program at breakpoints, or 
what ever. 
> 
>   
> 
> See the reference program Pivot Finder by Mark.... I've found I 
have to be
> selective in what I print out. 
> 
> since if you put TRACE statement inside your "for loop" you'll get 
a few
> thousand bars of out put where you can see if 
> 
> i goes from 1 to Barcount. 
> 
>  
> 
> Hope this helps'
> 
> JOE 
> 
>  
> 
> 
> 
> _TRACE
> - print text to system debug viewer
> 
> Miscellaneous functions
> (AFL 2.4)
> 
>  
> 
> 
> SYNTAX 
> 
> _TRACE( 
> 
> 
> RETURNS
> 
> NOTHING 
> 
> 
> FUNCTION 
> 
> Write debug messages from AFL code to system debug viewer. (it calls
> internally OutputDebugString Win API function). To view debug 
messages you
> have to run DebugView freeware program from  
<http://www.sysinternals.com/>
> http://www.sysinternals.com 
> 
> 
> EXAMPLE
> 
> _TRACE("This is a test"); 
> 
> 
> SEE ALSO
> 
>  
> 
> 
> References: 
> 
> 
> The _TRACE function is used in the following formulas in AFL on-line
> library: 
> 
> *	Pivot Finder
> <http://www.amibroker.com/library/detail.php?id=359&hilite=_TRACE> 
> 
> 
> More information:
> 
> 
> ----- Original Message ----- 
> 
> From: Rush <mailto:rushingitagain@...>  
> 
> To: amibroker@xxxxxxxxxxxxxxx 
> 
> Sent: Wednesday, April 05, 2006 8:22 AM
> 
> Subject: RE: [amibroker] AFL drives me nuts
> 
>  
> 
> How do you do a trace?
> 
>  
> 
> 
>   _____  
> 
> 
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 
On Behalf
> Of Joe Landry
> Sent: 05 April 2006 15:03
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] AFL drives me nuts
> 
>  
> 
> Yes, it does look logical to me and if you change your starting 
result to
> zero ...result =0;  it generates and array, Whether that is correct 
or not,
> I have no way of knowing unless I debug/trace it. 
> 
> 
> Hope this helps
> 
> JOE 
> 
> ----- Original Message ----- 
> 
> From: Rush <mailto:rushingitagain@...>  
> 
> To: amibroker@xxxxxxxxxxxxxxx 
> 
> Sent: Wednesday, April 05, 2006 7:09 AM
> 
> Subject: [amibroker] AFL drives me nuts
> 
>  
> 
> This looks correct and logical to me, but it doesn't work.
> 
> result = Null;
> 
>         for ( i = 1; i < BarCount; i++ ){
> 
>                 High1 = High[i];
> 
>                 High2 = High[i-1];
> 
>                 Low1 = Low[i];
> 
>                 Low2 = Low[i-1];
> 
>                 if((High1 > High2 AND Low1 > Low2) OR (High1 > 
High2 AND
> Low1 == Low2)){
> 
>                         result[ i ] = result[i - 1] + 1;
> 
>                 }else if((Low1 < Low2 AND High1 < High2) OR (Low1 < 
Low2 AND
> High1 == High2)){
> 
>                         result[ i ] = result[i - 1] - 1;
> 
>                 }else{
> 
>                         result[ i ] = result[ i - 1];
> 
>                 }
> 
>         }
> 
>         Plot( result, "Digger", ParamColor( "Color", colorBlack ),
> ParamStyle("Style"));
> 
> Thanks
> 
>  
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> 
> 
> 
> 
> 
> 
>   _____  
> 
> 
> YAHOO! GROUPS LINKS 
> 
>  
> 
> *	 Visit your group "amibroker
> <http://groups.yahoo.com/group/amibroker> " on the web.
>   
> *	 To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
> <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe> 
>   
> *	 Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/>  Terms of Service. 
> 
>  
> 
> 
>   _____
>







Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/