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

Re: [amibroker] Syntax-Error



PureBytes Links

Trading Reference Links

Hello,

These things are pretty basic:
1. CURLY BRACES { } must be used in for statement !!! 
2. You must NOT access array elements OUTSIDE 0...(BarCount -1) range
3. Status("firstvisiblebar") gives non-zero value ONLY IN INDICATOR BUILDER
and gives zero in AA window.
4. There is no need to use loop in this case as easier one line code can be written
as there is dedicated function HHVBars that does just that.

Your code as it is may access array elements with negative indexes
which do not exist.

Two solutions:
a) with loop (longer)

per=20; 
StartBar=Status("firstvisiblebar"); 
EndBar=StartBar-per; 
HiBar=0; 
for ( i = Min( startbar, BarCount -1 ); i >= endbar AND i > 0; i-- ) 
{ 
if (H[i-1]> H[i] AND  H[i-1]>HiBar ) 
HiBar=i; 
} 

b) without loop (shorter)

per=20; 
HiBar = LastValue( ValueWhen( Status("firstvisiblebarindex")==BarIndex(), HHVBars( H, per ) ) ); 

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "enzo" <herrfrechdax@xxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, October 16, 2004 12:49 AM
Subject: [amibroker] Syntax-Error


> 
> 
> Sorry, but I am almost getting mad. For at least one hour I am 
> trying this and that and all the time I have a syntax error with the 
> following code:
> (want to determine the number of the bar where the last high 
> occurred before the first visible)
> 
> per=20;
> StartBar=Status("firstvisiblebar");
> EndBar=StartBar-per;
> HiBar=0;
> for ( i = startbar; i >= endbar; i-- )
> (
> if (H[i-1]> H[i] AND  H[i-1]>HiBar )
> HiBar=i; 
> 
> )
> 
> 
> Thanx for the help.
> enzo
> 
> 
> 
> 
> 
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

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/