Amibroker assistance - coding Bill William's price bars ohlc

#1
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(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;

/*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,colorRed,IIf(COND_N,colorBlue,colorWhite)));

PlotOHLC( Open, High, Low, Close, "Price chart ",DYNAMIC_COLOR, styleBar );


Thank you,

JG
 
#2
Dear Adheer,
Thank You for your quick reply and sparing the time. Extremely grateful.

I will incorporate the correction and get back to you.

warm regards,

JG
 

rds

New Member
#4
Hi Jim,

Stumbled upon your post while I was searching for an answer to my problem.


I've written an afl that gives buy and sell signals with an ema crossover. I would like to paint the buy area bars in green and the sell area bars in red.

I think this is similar to what you were trying to do.

If you have any idea on how to do this, could you please help me.

I can post or email the afl if you need more information.

thanks
Ramesh
 

abhinkoi

Active Member
#5
Hello Jim,

Would you mind sharing this afl after the modifications incorporated by Adheer..?

Thx
Abhinav
 
#6
Hi,
Here the modified Color Coding of Price Bars( Bill Williams ) by Mr.Joris M.schuller


_SECTION_BEGIN("Bill william's Price Bars BARS");
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;

/*CONDITIONAL STATEMENTS */


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)));

PlotOHLC( Open, High, Low, Close, "Price chart ",DYNAMIC_COLOR,styleBar);

_SECTION_END();

Regards

Antony
 

rds

New Member
#7
Hi Antony,

Thank you very much for taking the trouble to post this. I really appreciate it.

Newbies like me could use all the help that we get.

I'll try this out and get back to you.

thanks again

Ramesh
 
#8
mr. antony
the last line promtes an error.
PlotOHLC( Open, High, Low, Close, "Price chart ",DYNAMIC_COLOR,styleBar);pl recheck the code and post again .i am using 5.2 verison for u r information.
with regards
ravi
 
#9
sorry antony
i have rectified my self the problem, the last butone line
DYNAMIC_COLOR=IIf(COND_C,colorGreen,IIf(COND_D,col orRed,IIf(COND_N,colorBlue,colorGold)));
remove space between colorred and every thing will be fine.
DYNAMIC_COLOR=IIf(COND_C,colorGreen,IIf(COND_D,colorRed,IIf(COND_N,colorBlue,colorGold)));

ravi
 
#10
Hi,
Sorry for the delay...
Here's the rectified Color Coding of Price Bars( Bill Williams ) by Mr.Joris M.schuller

Formula:

_SECTION_BEGIN("Bill william's Price Bars BARS");
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;

/*CONDITIONAL STATEMENTS */


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)));

PlotOHLC( Open, High, Low, Close, "Price chart ",DYNAMIC_COLOR,styleBar);

_SECTION_END();

regards

Antony
 

Similar threads