PureBytes Links
Trading Reference Links
|
Ara,
In fact using AND/OR with numerics is perfectly valid
provided you know what you are doing.
Non-zero numerics are treated as TRUE. Zero =
False
for example this nice statement prevents from division by zero
in case when either a or b is zero
(in other words it allows division only when a AND b are NOT
zero).
if ( a AND b ) x = y / (a * b);
This is much nicer than long form:
if( a != 0 AND b != 0 ) x = y/( a * b );
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Ara Kaloustian
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, May 07, 2003 9:15
PM
Subject: Re: [amibroker] if - else
Thanks to all who responded.
The corrected line below (from Tomasz ) cleared the problem. Was
using OR with numerics..
if ( sc == colorYellow
OR sc == colorGold OR
sc == colorRed )
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Tomasz Janeczko
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, May 07, 2003 11:51
AM
Subject: Re: [amibroker] if -
else
Ara,
Please read the READ ME.
The syntax of if is described in detail
there.
You have many errors in the
code:
- extra semicolon (after if)
- umatched/missing braces
- invalid use of OR operator (OR-ing numeric values
instead of booleans)
- invalid condition in if() statement
When AmiBroker displays SYNTAX ERROR message it means that
there *IS*
a syntax error, so you should re-read the read me, fix and
try again.
And repeat the procedure until you fix all your coding
mistakes.
You should write:
sc = SelectedValue(PlotColor);
if ( sc ==
colorYellow OR sc ==
colorGold OR sc == colorRed <FONT
face="Courier New">)
{
PlotShapes<FONT
size=2>(IIf(Plot_High,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,0);
PlotShapes<FONT
size=2>(IIf(Plot_Low,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,0);
PlotShapes<FONT
size=2>(IIf(Plot_HDS,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,0);
}
else
{
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Short_Signal,shapeDownArrow,shapeNone<FONT
face="Courier New">),Plotcolor,<FONT
color=#ff00ff>0,Stoc,<FONT
color=#ff00ff>0);
}
Now the code although syntactically correct but may
have logic problems connected
with the fact that you forget the fact that PlotShapes
plots all shapes at once.
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Ara Kaloustian
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, May 07, 2003 7:53
PM
Subject: Re: [amibroker] if -
else
Tomasz,
I still get the same error....
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Tomasz
Janeczko
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, May 07, 2003 10:47
AM
Subject: Re: [amibroker] if -
else
Ara,
You should place closing brace } before and after
'else':
if (<FONT
color=#0000ff>SelectedValue(Plotcolor) ==
colorYellow OR
colorGold OR
colorRed);
{
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_High,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0);
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_Low,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0);
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_HDS,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0);
}
else
{
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Short_Signal,shapeDownArrow,shapeNone<FONT
face="Courier New">),Plotcolor,<FONT
color=#ff00ff>0,Stoc,<FONT
color=#ff00ff>0);<FONT face="Courier New"
size=2>
}<FONT face="Courier New"
size=2>
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Ara
Kaloustian
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">Amibroker
Sent: Wednesday, May 07, 2003
7:38 PM
Subject: [amibroker] if -
else
Having problem with if - else
structure...
The code below works if I comment out the
"else" section and following line, otherwise I get error 23 (syntax
error) pointing at "else".
Anyone see the problem?
Thanks
Ara
if (<FONT
color=#0000ff>SelectedValue(Plotcolor) ==
colorYellow OR
colorGold OR
colorRed);
{
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_High,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0);
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_Low,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0);
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Plot_HDS,shapeDownArrow,shapeNone),
Plotcolor,0,Stoc,<FONT
color=#ff00ff>0); <FONT color=#008000
size=2>
else
PlotShapes<FONT
size=2>(<FONT
color=#0000ff>IIf(Short_Signal,shapeDownArrow,shapeNone<FONT
face="Courier New">),Plotcolor,<FONT
color=#ff00ff>0,Stoc,<FONT
color=#ff00ff>0);<FONT face="Courier New"
size=2>
}<FONT face="Courier New"
size=2>
<FONT face="Courier New"
size=1>
<FONT face=Arial
size=2>
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. 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. 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.
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.
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
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.
|