PureBytes Links
Trading Reference Links
|
Hello,
Actually there are THREE solutions, two equivalent and third
one (Ara's) which just evaluates last bar instead of array.
SOLUTION 1: working on ARRAYS and using
IIFS:
range=<FONT
color=#000000>C/<FONT
color=#ff00ff>2; cond = (<FONT
color=#000000>H-<FONT
color=#000000>C < .1*range) Value1
= IIf( cond, <FONT
color=#000000>H, Value1 ); <FONT
color=#008000>// note that "else" condition assumes assigning the same value
-> no change, <FONT
color=#000000> <FONT
color=#008000>// but for that to work you would need to initialize value1...
earlier Value2 = <FONT
color=#0000ff>IIf( cond, <FONT
color=#000000>L, Value2 ); Value3 =
IIf( cond, <FONT
color=#ff00ff>2 * <FONT
color=#000000>C, Value3 ); Value4 =
IIf( cond, <FONT
color=#ff00ff>2 * <FONT
color=#000000>O, Value4 );
SOLUTION 2: Equivalent to above but
using looping. Please note that native AFL loops are FAST (20x faster than
JScript)
<FONT
color=#800000>for( i = <FONT
color=#ff00ff>0; i < <FONT
color=#000000>BarCount; i++ ) {
range=C[
i ]/2; <FONT
color=#800000> if( <FONT
color=#000000>H[ i ] - <FONT
color=#000000>C[ i ] < <FONT
color=#ff00ff>0.1*range ) {
Value1[ i ] = H<FONT
color=#000000>[ i ]; Value2[ i ] = <FONT
color=#000000>L[ i ]; Value3[
i ] = 2 * <FONT
color=#000000>C[ i ]; Value4[
i ] = 2 * <FONT
color=#000000>O[ i ]; } }
SOLUTION 3.
Suggested by Ara, but not equivalent to above solutions since conditional
expression evaluates ONLY one, the very last bar:
<FONT face=Arial
size=2> <FONT
face="Courier New">range=<FONT
color=#0000ff>LastValue(<FONT
color=#000000>C/<FONT
color=#ff00ff>2);
if
(LastValue(<FONT
color=#000000>H-<FONT
color=#000000>C<FONT
color=#000000>) < .1*range) { Value1 = <FONT
color=#000000>H<FONT
color=#000000>; Value2 = <FONT
color=#000000>L<FONT
color=#000000>; Value3 = 2<FONT
color=#000000> * C<FONT
face="Courier New">; Value4 = <FONT
color=#ff00ff>2 * <FONT
color=#000000>O<FONT
face="Courier New">; }
<FONT
color=#000000>
Of course LastValue can be replaced with SelectedValue
function if you prefer to calculate it depending
on selected value (marked vertical
bar) instead.<FONT
color=#282828>
Best regards,Tomasz
Janeczkoamibroker.com
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
Jayson
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, April 20, 2004 6:07
PM
Subject: RE: [amibroker] If Then...
<FONT face=Arial color=#0000ff
size=2>TJ,
<FONT face=Arial color=#0000ff
size=2>thanks for reminding me. The solution it seems is to either use
lastvalue as Ara suggested or to loop through the array using
For....
Regards,Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: Tomasz Janeczko
[mailto:amibroker@xxxxxx]Sent: Tuesday, April 20, 2004 11:46
AMTo: <A
href="">amibroker@xxxxxxxxxxxxxxxSubject:
Re: [amibroker] If Then...
Hello,
This is because Close is an ARRAY in AFL (it is treated as
scalar in tradestation because tradestation runs your code MANY times (for
each bar),
instead of once like AMiBRoker).
I explained this in the past:
<A
href="">http://groups.yahoo.com/group/amibroker/message/37908
Best regards,Tomasz
Janeczkoamibroker.com
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
<A title=jcasavant@xxxxxxxxxxx
href="">Jayson
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, April 20, 2004 5:15
PM
Subject: RE: [amibroker] If
Then...
<FONT face=Arial color=#0000ff
size=2>Ara,
<FONT face=Arial color=#0000ff
size=2>I thought that should work as well....
<FONT face=Arial color=#0000ff
size=2>
<FONT
face=Arial color=#0000ff>
range=<FONT
size=2>C<FONT
face=Arial>/<FONT
size=2>2<FONT face=Arial
color=#0000ff>;
if<FONT
color=#0000ff> (H<FONT
size=2>-C<FONT
color=#282828> <
.1*range)
{
Value1 =<FONT
face=Arial color=#0000ff size=2>H<FONT
face=Arial color=#0000ff size=2>;
Value2 = <FONT
face=Arial color=#0000ff size=2>L<FONT
face=Arial color=#0000ff size=2>;
Value3 = <FONT
face=Arial>2 *
C<FONT face=Arial
color=#0000ff size=2>;
Value4 = <FONT
face=Arial>2 *
O<FONT face=Arial
color=#0000ff size=2>;
}
<FONT face=Arial
color=#0000ff size=2>I get the error indicating IF needs to be numeric or
boolean.<FONT face="Times New Roman"
color=#000000>..
<FONT
size=2>Regards,Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: Ara Kaloustian
[mailto:ara1@xxxxxxxxxx]Sent: Tuesday, April 20, 2004 10:50
AMTo: <A
href="">amibroker@xxxxxxxxxxxxxxxSubject:
Re: [amibroker] If Then...Same way... slighly
different syntaxif (condition){Value1 = xx;Value2
=yy;}----- Original Message ----- From: "bealer_bob"
<rhunt@xxxxxxxxxxxxxxx>To:
<amibroker@xxxxxxxxxxxxxxx>Sent: Tuesday, April 20, 2004 7:37
AMSubject: [amibroker] If Then...> I want to be able
to set a whole series of values if a particular> condition is
true. It appears that the IFF function will set only one> value.
I could create a whole series of IFF statements, but I would>
rather set all values with one statement.>> In
Tradestation Easy Language it would look like this:>> If
H-C < .1*Range then begin> Value1 =
H> Value2 = L> Value3
= 2 * C> Value4 = 2 * O>
End;>> How would I do something similar in
AFL?>> Thanks in advance,>>
Bob>>>>> Send BUG REPORTS to
bugs@xxxxxxxxxxxxx> Send 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>
Yahoo! Groups
Links>>>>>>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
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
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
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
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 the Yahoo! Terms of Service.
|