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

[amibroker] Nested IIF functions?



PureBytes Links

Trading Reference Links

I'm trying to use nested IIF functions to determine whether I want to be
long, short or flat a given asset. The way I specify the code, it seems
as though the variable I'm using (which I call "Stance") should only
take values -1, 0, or 1. However, when I plot "Stance," it takes on
continuous values between 0 and 1, which is baffling to me. I was hoping
someone could take a look at the line below to see if something jumps
out as obviously wrong:

Stance[0] = 0;
Stance = IIF( Ref(Stance, -1) == 0, IIF( A1 > A2  AND  B1 < B2  AND  C1
> C2, 1, IIF( A1 < A2  AND  B1 > B2  AND  C1 < C2, -1, 0), IIF(
Ref(Stance, -1) == 1, IIF(A1 < A2  AND  B1 > B2  AND  C1 < C2, -1, IIF(
A1 < A2  OR  B1 > B3, 0, Ref(Stance, -1))), IIF( A1 > A2  AND  B1 < B2 
AND  C1 > C2, 1, IIF( A1 > A2  OR  B1 < B4, 0, Ref(Stance, -1)))));

In words: if yesterday's stance is zero, then check to see if the
strategy wants to go long, go short, or remain flat. If yesterday's
stance is long (i.e., 1), then check to see if it wants to go short or
get flat (if neither, then stay long). Else if yesterday's stance is
short (i.e., -1), then check to see if it wants to go long or get flat
(if neither, then stay short).

The conditions  are all mutually exclusive, so I'm having a hard time
understanding why anything other than -1, 0, or 1 should be returned by
the variable Stance. I would be grateful for any insight that anyone may
have.

Regards,
Ray Micaletti





------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/