Need Help change candle type Close > Open

iif
Tags: #<Tag:0x00007f2d7b8b70b8>

#1

I have four different conditions and I colored my candle according to the conditions. My question is, how do I change these code so that when Open > Close the candle Hollow Color Coded, else the candle is Filled Color Coded. Here is my code:

cond0 = .....; //condition 0
cond1 = .....; //condition 1
cond2 = .....; //condition 2
cond3 = .....; //condition 3


_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
	
SetBarFillColor(
IIf(Cond0,ParamColor("Cond0", colorGreen),
	IIf(Cond1,ParamColor("Cond1", colorYellow),
		IIf(Cond2,ParamColor("Cond2", colorRed),ParamColor("Cond3", colorBlue)))));

Please need help, thanks a lot.


#2

Try ParamColor outside IIF

cond0 = .....; //condition 0
cond1 = .....; //condition 1
cond2 = .....; //condition 2
cond3 = .....; //condition 3

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

ColorCond0 = ParamColor("Cond0", colorGreen);	
ColorCond1 = ParamColor("Cond1", colorYellow);
ColorCond2 = ParamColor("Cond2", colorRed);
ColorCond3 = ParamColor("Cond3", colorBlue);
SetBarFillColor(
IIf(Cond0,ColorCond0,
	IIf(Cond1,ColorCond1,
		IIf(Cond2,ColorCond2,ColorCond3))));

#3

@awilson @sunarsusanto I interpreted your request as wanting to have “hollow” candles vs having “filled” candles ? I’ve never tried this but think that if that is the case maybe you need to use SetBarFillColor and for example if you want a “hollow” candle set the FillColor to match your background.

https://www.amibroker.com/guide/afl/setbarfillcolor.html

SetBarFillColor( IIf( Open > Close, colorblack, colorBlue ) ); // use your condition colors instead of colorBlue
Plot( C, "Price", IIf( C > O, colorGreen, colorRed ), styleCandle );

image


#4

Sorry for the late reply because I was on vacation. I fixed my code to follow your suggestion, but I still don’t get it how to set up Hollow Color for Close > Open , else Solid Color if Close < Open


#5

Case CLOSED, problem solved. Thank you.


#6

Hi @sunarsusanto
Care to share your solution to the problem?
Thanks :slight_smile: