PureBytes Links
Trading Reference Links
|
Hello,
While IIF works on ARRAY,
if/else works on INDIVIDUAL number/boolean (element of the
array).
Therefore you should write either
a1 = IIF( C > Ref( C, -1 ), 1, 0 );
(or even: a1 = C > Ref( C, -1 );
or iterate:
for( i = 1; i < BarCount; i++ )
{
if ( Close[ i ] > Close[ i - 1 ]
)
a1[ i ] = 1;
else
a1[ i ] =
0;
}
It is important to understand that IIF is a FUNCTION that
works on arrays,
while if/else is control flow STATEMENT.
Function just evaluates all arguments and returns
value(s)
Control flow statement changes program flow.
This is fundamental difference.
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
<A title=jcasavant@xxxxxxxxxxxx
href="">Jayson
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Monday, April 14, 2003 7:55
AM
Subject: RE: [amibroker] AmiBroker 4.31.0
BETA Examples
<SPAN
class=934273705-14042003>Steve,
Your
example makes sense yet does not seem to work for me. Else seems to be ignored
. Using the IIF this would simply be ......
<SPAN
class=934273705-14042003>a1=iif(c>ref(c,-1),1,0); I am certainly
missing something here.... your input appreciated..
<SPAN
class=934273705-14042003>jayson
<SPAN
class=934273705-14042003>
<SPAN
class=934273705-14042003><FONT face=Arial color=#0000ff
size=2><IMG alt="" hspace=0
src="gif00199.gif" align=baseline
border=0>
<SPAN
class=934273705-14042003>
Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: Steve Dugas
[mailto:sjdugas@xxxxxxxxx]Sent: Sunday, April 13, 2003 11:25
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker]
AmiBroker 4.31.0 BETA Examples
Hi Ken,
I think the concept of loops and if-then-else is the same in
all languages. I imagine you could read up on it at many
websites (e.g. - MSDN scripting site). Once you grasp the concept, it is just
a matter of using AFL syntax. You would probably use it mostly for iterating
your arrays if you wanted to do that. Here is a simple pseudo-code - try
coding it in AFL:
For (SecondBar to LastBar)
If (Today's Close > Yesterday's
Close)
MyArray = 1
Else
MyArray = 0
Plot MyArray
Of course, please feel free to ask for help!
Steve
----- Original Message -----
<BLOCKQUOTE
>
<DIV
>From:
Tomasz Janeczko
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, April 13, 2003 10:39
AM
Subject: Re: [amibroker] AmiBroker
4.31.0 BETA Examples
Ken,
Very nice story :-)
As per your request, attached is a Parabolic SAR formula
that I have rewritten from JScript version
(<A
href=""><FONT
size=2>http://www.amibroker.com/library/detail.php?id=242<FONT
size=2>)
Best regards,Tomasz
Janeczkoamibroker.com
----- Original Message -----
From: "Ken Close" <<A
href="">closeks@xxxxxxxx<FONT
size=2>>
To: <<A
href=""><FONT
size=2>amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, April 13, 2003 4:05 PM
Subject: RE: [amibroker] AmiBroker 4.31.0 BETA
Examples
> Tomasz:>
> As always, you have good sound advice. However......>
> You say, "Here is a fast sports car, very versatile and
powerful. It> has 7 forward gears, but if you are a beginner,
do not worry....always> stay in maximum of 4th gear. Plenty of nice
driving is possible in 4th> gear. Wait until you become
more experienced before you try gears 5,> 6, and 7."> >
I say, "Thank you for providing such a nimble sports car, but I am in
a> race, and I do not think I can finish even 10th in this race,
until I> get out past 4th gear. If you or others would just
provide some more> examples of how to use 5th and 6th gear, then I
could more confidently> try them. Maybe even copy your use of them.
Then, probably, I will have> enough experience to try 7th gear on my
own."> > More examples is all I am asking for....my objective
is not to stay in> 4th gear.> > Thanks,>
> Ken> > -----Original Message-----> From:
Tomasz Janeczko [mailto:amibroker@xxxxxx] > Sent: Sunday, April 13,
2003 9:47 AM> To: <A
href=""><FONT
size=2>amibroker@xxxxxxxxxxxxxxx> Subject:
Re: [amibroker] AmiBroker 4.31.0 BETA Examples> > Ken,>
> > First, additional kudos to Tomasz for another step-jump in
capability> of> > Amibroker.> Thank you.>
> > Second, a caution, in marketing terms, of having capability
that is so> > hard to apply for "non-programmers", beginners, and
non-technical> types> > that the extra capability is viewed
not as an advantage or benefit,> but> > just the
opposite.> > The beginners don't really need to jump into deep
water right from> the start as AFL still supports "old-way" of
work.> > When you write> > TypicalPrice =
(H+L+C) /3;> > it still operates on H, L, C arrays and
produces array so no> looping is needed.> > New
features are added as 'extra' stuff and do not> change the way old
statements work.> > > I apologize - but may speak for many
hidden lurkers - that I have just> > mastered the idea that "every
AFL statement only executes once", but> now> > I must
scramble to reorient my brain for repeated iterations thru AFL> >
statements.> > See above - you don't need really to write
loops if you don't want them.> All previously written code will
execute the same way as before.> > Unless you use a while
and/or for loop nothing has really changed.> > So, you don't
really need to "re-orient your brain" :-)> > You can view new
features as a replacement of JScript/VBScript.> You may use these new
features only when you needed to use> scripting in previous
versions.> > Best regards,> Tomasz Janeczko>
amibroker.com> > > Send BUG REPORTS to <A
href=""><FONT
size=2>bugs@xxxxxxxxxxxxx> Send SUGGESTIONS
to <FONT
size=2>suggest@xxxxxxxxxxxxx>
-----------------------------------------> Post AmiQuote-related
messages ONLY to: <FONT
size=2>amiquote@xxxxxxxxxxxxxxx > (Web page:
<FONT
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT
size=2>)> --------------------------------------------> Check
group FAQ at:> <A
href=""><FONT
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
size=2> > > Your use of Yahoo! Groups is subject to>
<FONT
size=2>http://docs.yahoo.com/info/terms/ >
> > > > > ------------------------ Yahoo!
Groups Sponsor ---------------------~-->> Make Money Online
Auctions! Make $500.00 or We Will Give You Thirty Dollars for
Trying!> <A
href=""><FONT
size=2>http://us.click.yahoo.com/yMx78A/fNtFAA/i5gGAA/GHeqlB/TM<FONT
size=2>>
---------------------------------------------------------------------~->>
> Send BUG REPORTS to <A
href=""><FONT
size=2>bugs@xxxxxxxxxxxxx> Send SUGGESTIONS
to <FONT
size=2>suggest@xxxxxxxxxxxxx>
-----------------------------------------> Post AmiQuote-related
messages ONLY to: <FONT
size=2>amiquote@xxxxxxxxxxxxxxx > (Web page:
<FONT
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT
size=2>)> --------------------------------------------> Check
group FAQ at: <A
href=""><FONT
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
size=2> > > Your use of Yahoo! Groups is subject to <A
href=""><FONT
size=2>http://docs.yahoo.com/info/terms/ >
> > 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.
Attachment:
Description: ""
|