I believe that this is what you try to
do.
Some comments:
1. Instead of P=2 or 3 write P=2 or P=3.
2. Instead of = sign (assignment), use
== (equal to)
3. At every boundary/interface use >=
and <= instead of > and <. This way you prevent P and/or CL becoming 0
at those boundaries. (See commented out lines)
4. The case of Open in 3 and Close in 1
is not covered. Is this by design?
5. Equation 1 is redundant (see equation
1a).
R=(H-L);//RANGE;
FR=(H-L)/3;//THIRD OF RANGE;
S1=H-FR;//SEGMENT ONE;
S2=H-2*FR;//SEGMENT TWO;
S3=L;//SEGMENT THREE;
/*POSITION OF OPEN AND CLOSE RELATIVE TO
BAR*/
P=IIf(O>S1,1,IIf(S1>O<S2,2,IIf(S2>O<L,3,0)));// POSITION OF
OPENING PRICE ;
CL=IIf(C>S1,1,IIf(S1>C<S2,2,IIf(S2>C<L,3,0)));// POSITION OF
CLOSING PRICE;
//P=IIf(O>=S1,1,IIf(S1>=O<=S2,2,IIf(S2>=O<=L,3,0)));// POSITION OF
OPENING PRICE ; includes the various interfaces: H,L and the two 1/3 of the
range from top and bottom
//CL=IIf(C>=S1,1,IIf(S1>=C<=S2,2,IIf(S2>=C<=L,3,0)));// POSITION OF
CLOSING PRICE; includes the various interfaces: H,L and the two 1/3 of the
range from top and bottom
/*CONDITIONAL STATEMENTS */
/* Original
COND_C=(((P=2 OR 3) AND CL=1)) OR (P=3
AND (C=1 OR 2)); //CLIMBERS
COND_D=(P=1 AND (CL=2 OR 3) ) OR (P=2
AND (CL=2 OR 3));//DRIFTERS
COND_N=(P=CL=1 OR 2 OR 3); // NEUTRAL
BARS
*/
COND_C=((P==2 OR P==3) AND CL==1) OR (P==3 AND (CL==1 OR CL==2)); //CLIMBERS (eq.
1)
COND_C=(P==2 /*OR P==3)*/ AND
CL==1) OR (P==3 AND (CL==1 OR CL==2)); //CLIMBERS (eq. 1a)
COND_D=(P==1 AND (CL==2 OR CL==3)) OR (P==2 AND (CL==2 OR CL==3));//DRIFTERS
COND_N=((P==CL) AND ( P==1 OR P==2 OR P==3));
//
NEUTRAL BARS
DYNAMIC_COLOR=IIf(COND_C,colorGreen,IIf(COND_D,colorRed,IIf(COND_N,colorBlue,colorGold)));
//DYNAMIC_COLOR=IIf(COND_C,2,IIf(COND_D,2,IIf(COND_N,2,6)));
PlotOHLC( Open, High, Low,
Close, "Price chart ",DYNAMIC_COLOR, 5 );
//Plot( Close, "Price
chart ",DYNAMIC_COLOR, 5 );
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Patrick
Tobin
Sent: Sunday, February 08, 2009 6:15 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] AFL Assistance - Color Coding of Price Bars( Bill
Williams Profitunity Windows )
Hi Friends,
I've been trying to assign colors to bars based on Bill Williams'
assignments to bar structures (CLIMBERS, DRIFTERS AND NEUTARAL BARS)
without success. The colors do not come out at all. With the AFL
coding below, the only result is Green Bars.
I have limited knowledge of the AFL and definitely need help. The
logic seems in place but my expertise with AFL is wanting. I would
appreciate any assistance with the coding.
R=(H-L);//RANGE;
FR=(H-L)/3;//THIRD OF RANGE;
S1=H-FR;//SEGMENT ONE;
S2=H-2*FR;//SEGMENT TWO;
S3=L;//SEGMENT THREE;
/*POSITION OF OPEN AND CLOSE RELATIVE TO BAR*/
P=IIf(OPEN>S1,1,IIf(S1>OPEN<S2,2,IIf(S2>OPEN<L,3,0)));//
POSITION OF
OPENING PRICE ;
CL=IIf(CLOSE>S1,1,IIf(S1>CLOSE<S2,2,IIf(S2>CLOSE<L,3,0)));//
POSITION
OF CLOSING PRICE;
/*CONDITIONAL STATEMENTS */
COND_C=(((P=2 OR 3) AND CL=1)) OR (P=3 AND (C=1 OR 2)); //CLIMBERS
COND_D=(P=1 AND (CL=2 OR 3) ) OR (P=2 AND (CL=2 OR 3));//DRIFTERS
COND_N=(P=CL=1 OR 2 OR 3); // NEUTRAL BARS
DYNAMIC_COLOR=IIf(COND_C,colorGreen,IIf(COND_D,col orRed,IIf
(COND_N,colorBlue,colorWhite)));
PlotOHLC( Open, High, Low, Close, "Price chart ",DYNAMIC_COLOR,
styleBar );
Thank you,
Pat Tobin
__._,_.___
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
*********************************
__,_._,___